Using Streams: 2.2 Using the Serial Ports: Communicating

Up: GEOS SDK TechDocs | Up | Prev: 2.1 Initializing a Serial Port | Next: 2.3 Closing a Serial Port
SerialRead(), SerialReadByte(), SerialWrite(), SerialWriteByte(), SerialQuery(), SerialFlush(), SerialGetError(), SerialSetError(), SerialError

Communicating with a serial port is very much like using any other stream. Special versions of the stream routines are provided, but they function just like their stream counterparts.

To read data from a serial port, call SerialRead() or SerialReadByte() . These routines take the same arguments as their Stream...() counterparts, except that each one must be passed the handle of the Serial Driver, not the Stream Driver, and each routine is passed the SerialUnit for the appropriate port, instead of being passed a stream token. These routines behave exactly like their Stream...() counterparts.

To write data to a serial port, call SerialWrite() or SerialWriteByte() . Again, these routines behave like their Stream...() counterparts, and take similar arguments.

To find out if you can read or write data to the port, call SerialQuery() . Again, this routine behaves like its Stream...() equivalent. To flush any data from the input or output stream, call SerialFlush() .

To send an error to the other side of a serial connection, call SerialSetError() . This routine behaves much like StreamSetError() . The only difference is that the error code passed must be a member of the SerialError enumerated type. This type has the following members:

SE_BREAK
Break condition detected on line.
SE_FRAME
Framing error (e.g. improper number of stop bits).
SE_PARITY
Parity error in received character.
SE_OVERRUN
A new byte was received before the previous byte was read; the previous byte was discarded.

To read an error condition passed by the other side of a serial connection, call SerialGetError() . This routine behaves just like StreamGetError() . The error code returned will be a member of the SerialError enumerated type.


Up: GEOS SDK TechDocs | Up | Prev: 2.1 Initializing a Serial Port | Next: 2.3 Closing a Serial Port