read API is blocked
Hi,
I'm reading some data off the serial port known as /dev/ttyS1
when I am reading it like this
res = read (fd, buff, 255);
(fd is opened with the Open API.)
the read was blocked and the debugger did not come thru. Here is the asynchronize code I have
fd = open (MODEMDEVICE, O_RDWR | O_NOCTTY | O_NONBLOCK);
// check for errors
saio.sa_handler = signal_handler_IO;
saio.sa_mask = 0l
saio.sa_flags = 0;
saio.sa_restorer = NULL;
sigaction (SIGIO, &saio, NULL);
fcntl (fd, F_SETOWN, getpid());
fcntl (fd, F_SETFL, FASYNC);
tcgetattr (fd, &oldtio);
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD);
newtio.c_iflag = IGNPAR | ICRNL;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
newtio.c_cc[VMIN] = 1;
newtio.c_cc[VTIME] = 0;
tcflush (fd, TCIFLUSH);
tcsetattr (fd, TCSANOW, &newtio);
while (STOP == FALSE)
{
printf (".\n")
if (wait_flag == FALSE)
{
res = read (fd, buf, 255);
// blocked here
buf[res] = 0;
printf (....) etc...
if (res == 1) STOP=TRUE;
wait_flag = TRUE;
}
}
tcsetattr (fd, TCSANOW, &oldtio);
}
void signal_handler_IO(int status)
{
printf ("received SIGIO signal\n");
wait_flag = FALSE;
}
But "received SIGIO Signal" keeps popping up endlessly
Thanks
Jack
|