serial.pas 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. {
  2. This file is part of the Free Pascal run time library.
  3. A file in Amiga system run time library.
  4. Copyright (c) 1998 by Nils Sjoholm
  5. member of the Amiga RTL development team.
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. unit serial;
  13. INTERFACE
  14. uses exec;
  15. Type
  16. { array of termination char's }
  17. { to use,see serial.doc setparams }
  18. pIOTArray = ^tIOTArray;
  19. tIOTArray = record
  20. TermArray0 : ULONG;
  21. TermArray1 : ULONG;
  22. end;
  23. Const
  24. SER_DEFAULT_CTLCHAR = $11130000; { default chars for xON,xOFF }
  25. { You may change these via SETPARAMS. At this time, parity is not
  26. calculated for xON/xOFF characters. You must supply them with the
  27. desired parity. }
  28. {****************************************************************}
  29. { CAUTION !! IF YOU ACCESS the serial.device, you MUST (!!!!) use an
  30. IOExtSer-sized structure or you may overlay innocent memory !! }
  31. {****************************************************************}
  32. Type
  33. pIOExtSer = ^tIOExtSer;
  34. tIOExtSer = record
  35. IOSer : tIOStdReq;
  36. { STRUCT MsgNode
  37. * 0 APTR Succ
  38. * 4 APTR Pred
  39. * 8 UBYTE Type
  40. * 9 UBYTE Pri
  41. * A APTR Name
  42. * E APTR ReplyPort
  43. * 12 UWORD MNLength
  44. * STRUCT IOExt
  45. * 14 APTR io_Device
  46. * 18 APTR io_Unit
  47. * 1C UWORD io_Command
  48. * 1E UBYTE io_Flags
  49. * 1F UBYTE io_Error
  50. * STRUCT IOStdExt
  51. * 20 ULONG io_Actual
  52. * 24 ULONG io_Length
  53. * 28 APTR io_Data
  54. * 2C ULONG io_Offset
  55. *
  56. * 30 }
  57. io_CtlChar : ULONG; { control char's (order = xON,xOFF,INQ,ACK) }
  58. io_RBufLen : ULONG; { length in bytes of serial port's read buffer }
  59. io_ExtFlags : ULONG; { additional serial flags (see bitdefs below) }
  60. io_Baud : ULONG; { baud rate requested (true baud) }
  61. io_BrkTime : ULONG; { duration of break signal in MICROseconds }
  62. io_TermArray : tIOTArray; { termination character array }
  63. io_ReadLen : Byte; { bits per read character (# of bits) }
  64. io_WriteLen : Byte; { bits per write character (# of bits) }
  65. io_StopBits : Byte; { stopbits for read (# of bits) }
  66. io_SerFlags : Byte; { see SerFlags bit definitions below }
  67. io_Status : Word;
  68. end;
  69. { status of serial port, as follows:
  70. * BIT ACTIVE FUNCTION
  71. * 0 --- reserved
  72. * 1 --- reserved
  73. * 2 high Connected to parallel "select" on the A1000.
  74. * Connected to both the parallel "select" and
  75. * serial "ring indicator" pins on the A500 &
  76. * A2000. Take care when making cables.
  77. * 3 low Data Set Ready
  78. * 4 low Clear To Send
  79. * 5 low Carrier Detect
  80. * 6 low Ready To Send
  81. * 7 low Data Terminal Ready
  82. * 8 high read overrun
  83. * 9 high break sent
  84. * 10 high break received
  85. * 11 high transmit x-OFFed
  86. * 12 high receive x-OFFed
  87. * 13-15 reserved
  88. }
  89. Const
  90. SDCMD_QUERY = CMD_NONSTD;
  91. SDCMD_BREAK = CMD_NONSTD + 1;
  92. SDCMD_SETPARAMS = CMD_NONSTD + 2;
  93. SERB_XDISABLED = 7; { io_SerFlags xOn-xOff feature disabled bit }
  94. SERF_XDISABLED = 128; { " xOn-xOff feature disabled mask }
  95. SERB_EOFMODE = 6; { " EOF mode enabled bit }
  96. SERF_EOFMODE = 64; { " EOF mode enabled mask }
  97. SERB_SHARED = 5; { " non-exclusive access bit }
  98. SERF_SHARED = 32; { " non-exclusive access mask }
  99. SERB_RAD_BOOGIE = 4; { " high-speed mode active bit }
  100. SERF_RAD_BOOGIE = 16; { " high-speed mode active mask }
  101. SERB_QUEUEDBRK = 3; { " queue this Break ioRqst }
  102. SERF_QUEUEDBRK = 8; { " queue this Break ioRqst }
  103. SERB_7WIRE = 2; { " RS232 7-wire protocol }
  104. SERF_7WIRE = 4; { " RS232 7-wire protocol }
  105. SERB_PARTY_ODD = 1; { " parity feature enabled bit }
  106. SERF_PARTY_ODD = 2; { " parity feature enabled mask }
  107. SERB_PARTY_ON = 0; { " parity-enabled bit }
  108. SERF_PARTY_ON = 1; { " parity-enabled mask }
  109. { These now refect the actual bit positions in the io_Status UWORD }
  110. IO_STATB_XOFFREAD = 12; { io_Status receive currently xOFF'ed bit }
  111. IO_STATF_XOFFREAD = $1000; { " receive currently xOFF'ed mask }
  112. IO_STATB_XOFFWRITE = 11; { " transmit currently xOFF'ed bit }
  113. IO_STATF_XOFFWRITE = $0800; { " transmit currently xOFF'ed mask }
  114. IO_STATB_READBREAK = 10; { " break was latest input bit }
  115. IO_STATF_READBREAK = $0400; { " break was latest input mask }
  116. IO_STATB_WROTEBREAK = 9; { " break was latest output bit }
  117. IO_STATF_WROTEBREAK = $0200; { " break was latest output mask }
  118. IO_STATB_OVERRUN = 8; { " status word RBF overrun bit }
  119. IO_STATF_OVERRUN = $0100; { " status word RBF overrun mask }
  120. SEXTB_MSPON = 1; { io_ExtFlags. Use mark-space parity, }
  121. { instead of odd-even. }
  122. SEXTF_MSPON = 2; { " mark-space parity mask }
  123. SEXTB_MARK = 0; { " if mark-space, use mark }
  124. SEXTF_MARK = 1; { " if mark-space, use mark mask }
  125. SerErr_DevBusy = 1;
  126. SerErr_BaudMismatch = 2; { baud rate not supported by hardware }
  127. SerErr_BufErr = 4; { Failed to allocate new read buffer }
  128. SerErr_InvParam = 5;
  129. SerErr_LineErr = 6;
  130. SerErr_ParityErr = 9;
  131. SerErr_TimerErr = 11; {(See the serial/OpenDevice autodoc)}
  132. SerErr_BufOverflow = 12;
  133. SerErr_NoDSR = 13;
  134. SerErr_DetectedBreak = 15;
  135. { These defines refer to the HIGH ORDER byte of io_Status. They have
  136. been replaced by the new, corrected ones above }
  137. IOSTB_XOFFREAD = 4; { iost_hob receive currently xOFF'ed bit }
  138. IOSTF_XOFFREAD = 16; { " receive currently xOFF'ed mask }
  139. IOSTB_XOFFWRITE = 3; { " transmit currently xOFF'ed bit }
  140. IOSTF_XOFFWRITE = 8; { " transmit currently xOFF'ed mask }
  141. IOSTB_READBREAK = 2; { " break was latest input bit }
  142. IOSTF_READBREAK = 4; { " break was latest input mask }
  143. IOSTB_WROTEBREAK= 1; { " break was latest output bit }
  144. IOSTF_WROTEBREAK= 2; { " break was latest output mask }
  145. IOSTB_OVERRUN = 0; { " status word RBF overrun bit }
  146. IOSTF_OVERRUN = 1; { " status word RBF overrun mask }
  147. IOSERB_BUFRREAD = 7 ; { io_Flags from read buffer bit }
  148. IOSERF_BUFRREAD = 128; { " from read buffer mask }
  149. IOSERB_QUEUED = 6 ; { " rqst-queued bit }
  150. IOSERF_QUEUED = 64 ; { " rqst-queued mask }
  151. IOSERB_ABORT = 5 ; { " rqst-aborted bit }
  152. IOSERF_ABORT = 32 ; { " rqst-aborted mask }
  153. IOSERB_ACTIVE = 4 ; { " rqst-qued-OR-current bit }
  154. IOSERF_ACTIVE = 16 ; { " rqst-qued-OR-current mask }
  155. SERIALNAME : PChar = 'serial.device';
  156. IMPLEMENTATION
  157. end.