I have connected a DWM1001-dev board to a Raspberry and can succesfully obtain terminal access to it through minicom. I want it to act as a listener and extract all the location information that can get with the use of the “lec” command of the board.
I am developing a litle C program to open this connection. I can open a terminal and send data:
int sfd = open("/dev/serial0", O_RDWR);
if (sfd == -1) {
printf("Error no is : %d\n", errno);
printf("Error description is : %s\n", strerror(errno));
return (-1);
};
struct termios options;
tcgetattr(sfd, &options);
cfsetspeed(&options, B115200);
cfmakeraw(&options);
options.c_cflag &= ~CSTOPB;
options.c_cflag |= CLOCAL;
options.c_cflag |= CREAD;
options.c_cc[VTIME]=1;
options.c_cc[VMIN]=100;
tcsetattr(sfd, TCSANOW, &options);
char buf2[100];
int count = write(sfd, "\r\n",2);
I can succesfully read data from the terminal.
emptyString(buf2);
ioctl(sfd, FIONREAD, &bytes);
if(bytes!=0){
count = read(sfd, buf2, 100);
}
if (strlen(buf2) > 0) {
printf("*%s\n", buf2);
}
If the board shows the dwm> cursor I can interact with it correctly sending commands and obtaining the response. What I am not being able to get is the initial cursor open when the system is reseted. I can detect the @ but it does not detect the double ENTER that is needed to get to the command mode. I have tried different combinations of this code (using \r\n, \r or \n) but I alwas get the @ and never the dwm> cursor:
count = write(sfd, "\r\n",2);
usleep(100);
count = write(sfd, "\r\n",2);
sleep(4);
How can I get to the command mode?
Thanks.