RS232.DEF 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. (* Release 3.10 *)
  2. (*-------------------------------------------------------------------------*
  3. * *
  4. * RS232.DEF - COMMS Toolkit interrupt-driven serial I/O handler *
  5. * *
  6. * COPYRIGHT (C) 1988..1992 Clarion Software Corporation. *
  7. * All Rights Reserved *
  8. * *
  9. *--------------------------------------------------------------------------*)
  10. DEFINITION MODULE RS232;
  11. CONST
  12. XOFF = CHR(19);
  13. XON = CHR(17);
  14. TYPE
  15. PortNos = [1..4];
  16. Bits = [5..8];
  17. Stops = [1..2];
  18. ParityCodes = (None,Odd,dontUse1,Even,dontUse2,Mark,dontUse3,Space);
  19. FlowControls = (NoFlowControl,XonXoff,RtsCts);
  20. TxHookProc = PROCEDURE(VAR ARRAY OF CHAR,VAR CARDINAL);
  21. RxHookProc = PROCEDURE(VAR CHAR);
  22. VAR
  23. Base,IntLevel : CARDINAL;
  24. TxHook : TxHookProc;
  25. RxHook : RxHookProc;
  26. Hooked : BOOLEAN;
  27. PROCEDURE SelectPort(Port:PortNos);
  28. (* Change serial port being used. Defaults to COM1. This disables *)
  29. (* any previously installed interrupt handler, so Install will need *)
  30. (* to be called again. *)
  31. PROCEDURE InitPort(Baud:CARDINAL;DataBits:Bits;StopBits:Stops;Parity:ParityCodes);
  32. (* Initialise serial hardware *)
  33. PROCEDURE SetFlowControl(Which:FlowControls);
  34. (* Select kind of flow control required - defaults to RTS/CTS *)
  35. PROCEDURE Install;
  36. (* Install interrupt handlers *)
  37. PROCEDURE CarrierDetect():BOOLEAN;
  38. (* True if Carrier (DCD) signal is asserted *)
  39. PROCEDURE UnInstall;
  40. (* Uninstall serial interrupt handler - forces line drop *)
  41. (*# save, call(o_a_copy => off) *)
  42. PROCEDURE SerialWrite(b:ARRAY OF CHAR; Lnth:CARDINAL);
  43. (* Copy "Lnth" characters from the array to the transmitter ring buffer *)
  44. (*# restore *)
  45. PROCEDURE SerialRead(VAR c:CHAR;t:CARDINAL):BOOLEAN;
  46. (* Attempt to read a char from the serial port, timing out after "t" *)
  47. (* tenth/seconds. "t" may be zero, in which case it returns *)
  48. (* immediately. The function result is TRUE if a char was read. *)
  49. PROCEDURE FlushInBuf;
  50. (* Flushes the input buffer of all waiting characters. *)
  51. PROCEDURE SetBreak(Tenths:CARDINAL);
  52. (* Assert break signal for the specified number of tenth/secs *)
  53. PROCEDURE AddTxHook(Hook:TxHookProc;VAR OldHook:TxHookProc);
  54. PROCEDURE AddRxHook(Hook:RxHookProc;VAR OldHook:RxHookProc);
  55. (* Adds a new hook to the chain and returns the address of the hook *)
  56. (* to chain to at the end of the new hook. *)
  57. (* N.B. - Remember not to chain if OldHook = NIL *)
  58. END RS232.
  59.