RS232Driver.mesa
RS232 driver enables Cedar clients to drive Dicentra serial IO port via RPC - note that there is nothing to protect against multiple access!
Mik Lamming - August 26, 1983 4:18 pm
RS232Driver: DEFINITIONS = BEGIN
BYTE: TYPE = [0..255];
Open: PUBLIC PROC[baudRate:CARDINAL] ;
Open RS232 connection and establish baud rate. Do this once only!.
Read: PROC[] RETURNS[BYTE] = INLINE {UNTIL RXFull[] DO ENDLOOP; RETURN[RX[]]} ;
Write: PROC[b:BYTE] = INLINE {TX[b]; UNTIL TXEmpty[] DO ENDLOOP} ;
Synchronised read and write routines.
TX: PROC[b:BYTE] ;
Send a byte of data and return without waiting for TX to finish
RX: PROC[] RETURNS[BYTE];
Read the input data register - should check data present using RXReady
TXEmpty: PROC[] RETURNS[BOOLEAN];
Check to see if last character transmitted has departed
RXFull: PROC[] RETURNS[BOOLEAN];
Check to see if there is anything in the input buffer
WriteString: PROC[string:LONG STRING];
write out a string one char at a time
WriteInt: PROC[int: INT, base: NAT ← 10, minDigits: NAT ← 1];
write out an integer
END.