How to do a blocking read from a serial device?
How to do a blocking read from a serial device?
- Subject: How to do a blocking read from a serial device?
- From: "Sean McBride" <email@hidden>
- Date: Mon, 10 Jul 2006 13:34:50 -0400
- Organization: Rogue Research
Hi all,
I am writing some code to work with an RS-232 serial device (via USB
adapter). It basically works. All the IOKit parts are fine, and I end
up with a file descriptor and then use the posix read() and write() APIs.
The read() man page says "The system guarantees to read the number of
bytes requested if the descriptor references a normal file that has that
many bytes left before the end-of-file, but in no other case." Indeed
with my serial device, if I say to read 15 bytes it sometimes returns
after reading 10 bytes.
Is there anyway to have read() block until the requested length is
ready? Is my only other choice some kind of loop that calls read() and
usleep() over and over? If so, how do I choose a sleep duration?
Thanks!
--
____________________________________________________________
Sean McBride, B. Eng email@hidden
Rogue Research www.rogue-research.com
Mac Software Developer Montréal, Québec, Canada
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden