public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* problem with reading off windows serial port
@ 2002-01-02 16:09 nzissopo
  0 siblings, 0 replies; only message in thread
From: nzissopo @ 2002-01-02 16:09 UTC (permalink / raw)
  To: cygwin

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/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-01-03  0:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-02 16:09 problem with reading off windows serial port nzissopo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).