Mail Archives: cygwin/2002/01/02/19:10:24
Hi,
I have a query in regards to reading data off the serial port on a Windows
98 machine with cygwin. The scenario is as follows:
I have a test program that opens a file descriptor (fd) on com1 via:
fd = open("com1", O_BINARY);
The port opens successfully. Now there is a hardware device attached to
com1 that sends 1 byte of data at a time. The test program attemps to read
the data from the serial port via:
no_of_bytes_received = read(fd, buffer, 1);
if (no_of_bytes_received == -1)
{
cerr << "Read failed" << endl;
}
else
{
cerr << "Read succeeded" << endl;
}
However, the read() call never completes, ie. in this case the if statement
is never executed.
Now I understand that read() behaves differently in cygwin than it does in
unix, as cygwin will block until the read completes. However, in this case
because I am sending only 1 byte across the serial port, I would expect
cygwin to read the one byte, and complete, and hence execute the above if
statement. This does not occur. I may be overlooking something, but if
anyone can lead me in the right direction, I would be greatful!
Nick
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -