Serial communications problem.
I am trying to read data from my SUN workstation's ttya port.
int n, i=0, j=0;
char message[64, buffer, c;
*fd = open("/dev/ttya", O_RDWR | O_NOCTTY | O_NDELAY);
if(n = read(fd, &c, 1) == 1)
buffer[i] = c;
if((buffer[i] == '\r') || (buffer[i] == '\n'))
buffer[i] = '\0';
memset(message, '\0', sizeof(message));
for(j=0; j<i; j++)
message[j] = buffer[j];
printf("Buffer %s", buffer);
i = 0;
memset(buffer, '\0', sizeof(buffer));
Sometimes this code, fails to detect the \n or \r characters in the incoming stream. It fails to apprpriately detect them, and hence does not correctly give me the printf. It will sometimes combine two streams together, seperately detecting the \n or \r character in each of them.
Basically my question, why would the serial driver sometimes fail to report or detect the \n, \r characters?
Any help is greatly appreciated...