Code:
char buff[255];
fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY |O_TRUNC);
if (fd == -1){
printf("Can't open port!\n");
return 1;
}
else {
while (1)
{
send(fd,"NULL");
char st[100];
memset(st,'\0',sizeof(st));
buff[0] = '\0';
send(fd, "AT\r\n");
sleep(1);
size = read(fd,buff,255);
printf("GOT:%s",buff);
if(buff[0]=='E')
{
return -1;
}
}