home *** CD-ROM | disk | FTP | other *** search
- {*--------------------------------------------------------------------------*}
- {* *}
- {* Status byte definition (C_Status): *}
- {* *}
- {* 7 6 5 4 3 2 1 0 *}
- {* | | | | | | | |____ Input buffer empty *}
- {* | | | | | | |________ Input buffer full *}
- {* | | | | | |____________ Output buffer empty *}
- {* | | | | |________________ Output buffer full *}
- {* | | | |____________________ Input buffer overflow *}
- {* | | |________________________ Output buffer overflow *}
- {* | |____________________________ Hard handshake active (xmit stopped) *}
- {* |________________________________ Soft handshake active (xmit stopped) *}
- {* *}
- {* Control byte definition (C_Ctrl): *}
- {* *}
- {* 7 6 5 4 3 2 1 0 *}
- {* | | | | | | | |____ Enable RTS handshake *}
- {* | | | | | | |________ Enable CTS handshake *}
- {* | | | | | |____________ Enable software handshake *}
- {* | | | | |________________ *}
- {* | | | |____________________ *}
- {* | | |________________________ *}
- {* | |____________________________ *}
- {* |________________________________ *}
- {* *}
- {****************************************************************************}
-
- {$R-,V-,B-,S-}
-
- Unit ASYNC;
-
- INTERFACE
-
- {----------------------------------------------------------------------------}
-
- Const
- C_MinBaud = 50;
- C_MaxBaud = 115200;
-
- { Base port addresses & interrupt usage }
-
- C_MaxPort = 4;
- C_MaxCom : Byte = C_MaxPort;
- C_PortAddr : Array[1..C_MaxPort] Of Word = ($03F8,$02F8,$03E8,$02E8);
- C_PortInt : Array[1..C_MaxPort] Of Byte = (4,3,4,3);
-
- {----------------------------------------------------------------------------}
-
- Type
- C_PointerArray = Array[1..C_MaxPort] Of Pointer;
- C_WordArray = Array[1..C_MaxPort] Of Word;
- C_ByteArray = Array[1..C_MaxPort] Of Byte;
- C_CharArray = Array[1..C_MaxPort] Of Char;
- C_BooleanArray = Array[1..C_MaxPort] Of Boolean;
-
- {----------------------------------------------------------------------------}
-
- Var
- C_InBufPtr,C_OutBufPtr : C_PointerArray; { Input/output buffer pointers }
- C_InHead,C_OutHead : C_WordArray; { Input/output head pointers }
- C_InTail,C_OutTail : C_WordArray; { Input/output tail pointers }
- C_InSize,C_OutSize : C_WordArray; { Input/output buffer sizes }
- C_RTSOn,C_RTSOff : C_WordArray; { RTS assert/drop buffer points }
- C_StartChar,C_StopChar : C_CharArray; { Soft hndshake start/stop char }
- C_Status,C_Ctrl : C_ByteArray; { STATUS and CONTROL registers }
- C_XL3Ptr : C_ByteArray;
- C_PortOpen : C_BooleanArray; { Port open/close flags }
- C_Temp : Word; { Used for debugging }
- C_msrport: word;
- oldier,oldmcr: byte;
- c_buffull: c_wordarray;
-
- {----------------------------------------------------------------------------}
-
- Function ComReadCh(ComPort:Byte) : Char;
- Function ComReadChW(ComPort:Byte) : Char;
- Procedure ComWriteCh(ComPort:Byte; Ch:Char);
- Procedure ComWriteChW(ComPort:Byte; Ch:Char);
- Procedure SetDTR(ComPort:Byte; Assert:Boolean);
- Procedure SetRTS(ComPort:Byte; Assert:Boolean);
- Procedure SetOUT1(ComPort:Byte; Assert:Boolean);
- Procedure SetOUT2(ComPort:Byte; Assert:Boolean);
- Function CTSStat(ComPort:Byte) : Boolean;
- Function DSRStat(ComPort:Byte) : Boolean;
- Function RIStat(ComPort:Byte) : Boolean;
- Function DCDStat(ComPort:Byte) : Boolean;
- Procedure SetRTSMode(ComPort:Byte; Mode:Boolean; RTSOn,RTSOff:Word);
- Procedure SetCTSMode(ComPort:Byte; Mode:Boolean);
- Procedure SoftHandshake(ComPort:Byte; Mode:Boolean; Start,Stop:Char);
- Procedure ClearCom(ComPort:Byte; IO:Char);
- Function ComBufferLeft(ComPort:Byte; IO:Char) : Word;
- Procedure ComWaitForClear(ComPort:Byte);
- Procedure ComWrite(ComPort:Byte; St:String);
- Procedure ComWriteln(ComPort:Byte; St:String);
- Procedure ComWriteWithDelay(ComPort:Byte; St:String; Dly:Word);
- Procedure ComReadln(ComPort:Byte; Var St:String; Size:Byte; Echo:Boolean);
- Function ComExist(ComPort:Byte) : Boolean;
- Function ComTrueBaud(Baud:Longint) : Real;
- Procedure ComParams(ComPort:Byte; Baud:LongInt; WordSize:Byte; Parity:Char; StopBits:Byte);
- Function OpenCom(ComPort:Byte; InBufferSize,OutBufferSize:Word) : Boolean;
- Procedure CloseCom(ComPort:Byte);
- Procedure CloseAllComs;
-
- {----------------------------------------------------------------------------}
-
-