[comp.sys.mac.programmer] Reading Serial Port : Think C

rc05@gte.com (Ramesh Chandak) (06/28/91)

I'm using FSRead procedure to read the serial port. What I'd like to
do is read the serial port once, if there is any character, then do
something else do something. Currently what it does is waits until
it gets a character.

The code reads like this :
err = FSRead( AinRefNum, count, inbuf )

any ideas on how I do it ? please email your responses to Ramesh
at rc05@gte.com. Thank You.

- Ramesh

peterc@Sugar.NeoSoft.com (Peter Creath) (06/29/91)

You're right.  FSRead does wait.  You need to do a SerGetBuf call to get
the # of bytes in the buffer.
 
SerGetBuf(portInRef,&in);
 
portInRef would be "AinRefNum" from your sample code, and &in would be
"&count".  portInRef is a short int, and "in" is a long int.


--