Results 1 to 1 of 1
Dear All,
with the following code i am expecting modem out put to buffer.
here its not responding.
Is it delay problem ??
kindly suggest the same.
char buffer[255]; /* ...
- 09-15-2009 #1Just Joined!
- Join Date
- Jul 2009
- Posts
- 16
expecting Serial port output to a buffer
Dear All,
with the following code i am expecting modem out put to buffer.
here its not responding.
Is it delay problem ??
kindly suggest the same.
char buffer[255]; /* Input buffer */
/* send an AT command followed by a CR */
write(fd, "AT\r", 3);
sleep(2);
printf("res1= %d\n",res);
/* read characters into our string buffer until we get a CR or NL */
bufptr = buffer;
while ((nbytes = read(fd, bufptr, buffer + sizeof(buffer) - bufptr - 1)) > 0)
{
bufptr += nbytes;
printf("nbytes = %d\n",nbytes);
if (bufptr[-1] == '\n' || bufptr[-1] == '\r')
break;
}
/* nul terminate the string and see if we got an OK response */
*bufptr = '\0';
if (strncmp(buffer, "OK", 2) == 0)
return (0);
Thanks in advance
John


Reply With Quote