This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

problem with reading off windows serial port


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;
  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!


Unsubscribe info:
Bug reporting:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]