(* Release 3.10 *) (*-------------------------------------------------------------------------* * * * RS232.DEF - COMMS Toolkit interrupt-driven serial I/O handler * * * * COPYRIGHT (C) 1988..1992 Clarion Software Corporation. * * All Rights Reserved * * * *--------------------------------------------------------------------------*) DEFINITION MODULE RS232; CONST XOFF = CHR(19); XON = CHR(17); TYPE PortNos = [1..4]; Bits = [5..8]; Stops = [1..2]; ParityCodes = (None,Odd,dontUse1,Even,dontUse2,Mark,dontUse3,Space); FlowControls = (NoFlowControl,XonXoff,RtsCts); TxHookProc = PROCEDURE(VAR ARRAY OF CHAR,VAR CARDINAL); RxHookProc = PROCEDURE(VAR CHAR); VAR Base,IntLevel : CARDINAL; TxHook : TxHookProc; RxHook : RxHookProc; Hooked : BOOLEAN; PROCEDURE SelectPort(Port:PortNos); (* Change serial port being used. Defaults to COM1. This disables *) (* any previously installed interrupt handler, so Install will need *) (* to be called again. *) PROCEDURE InitPort(Baud:CARDINAL;DataBits:Bits;StopBits:Stops;Parity:ParityCodes); (* Initialise serial hardware *) PROCEDURE SetFlowControl(Which:FlowControls); (* Select kind of flow control required - defaults to RTS/CTS *) PROCEDURE Install; (* Install interrupt handlers *) PROCEDURE CarrierDetect():BOOLEAN; (* True if Carrier (DCD) signal is asserted *) PROCEDURE UnInstall; (* Uninstall serial interrupt handler - forces line drop *) (*# save, call(o_a_copy => off) *) PROCEDURE SerialWrite(b:ARRAY OF CHAR; Lnth:CARDINAL); (* Copy "Lnth" characters from the array to the transmitter ring buffer *) (*# restore *) PROCEDURE SerialRead(VAR c:CHAR;t:CARDINAL):BOOLEAN; (* Attempt to read a char from the serial port, timing out after "t" *) (* tenth/seconds. "t" may be zero, in which case it returns *) (* immediately. The function result is TRUE if a char was read. *) PROCEDURE FlushInBuf; (* Flushes the input buffer of all waiting characters. *) PROCEDURE SetBreak(Tenths:CARDINAL); (* Assert break signal for the specified number of tenth/secs *) PROCEDURE AddTxHook(Hook:TxHookProc;VAR OldHook:TxHookProc); PROCEDURE AddRxHook(Hook:RxHookProc;VAR OldHook:RxHookProc); (* Adds a new hook to the chain and returns the address of the hook *) (* to chain to at the end of the new hook. *) (* N.B. - Remember not to chain if OldHook = NIL *) END RS232.