home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / visionix / vfosu.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-12-28  |  60.1 KB  |  3,011 lines

  1. {
  2.  ════════════════════════════════════════════════════════════════════════════
  3.  
  4.  Visionix Serial Communictions Unit - FOSSIL specification (VFOS)
  5.    Version 0.8
  6.  Copyright 1991,92,93 Visionix
  7.  ALL RIGHTS RESERVED
  8.  
  9.  ────────────────────────────────────────────────────────────────────────────
  10.  
  11.  ** revision history in reverse chronological order **
  12.  
  13.  Initials  Date      Comment
  14.  ────────  ────────  ────────────────────────────────────────────────────────
  15.  
  16.  mep       04/08/93  Redocumented code.
  17.  
  18.  mep       02/11/93  Cleaned up code for beta release
  19.                      Fixed for DPMI mode
  20.  
  21.  jrt       02/08/93  Sync with beta 0.12 release
  22.  
  23.  mep       01/31/93  Bug fixes.
  24.  
  25.  jrt       12/07/92  Sync with beta 0.11 release
  26.  
  27.  jrt       11/21/92  Sync with beta 0.08
  28.  
  29.  mep       11/18/92  Code re-implemented to work with VSer.  Major changes
  30.                      completed.  Second internal revision.
  31.  
  32.  mep       11/02/92  First logged revision.
  33.  
  34.  ────────────────────────────────────────────────────────────────────────────
  35. }
  36.  
  37. (*-
  38.  
  39. [TEXT]
  40.  
  41. <Overview>
  42.  
  43. This unit implements a function for all commands in the FOSSIL
  44. specification.  For more information, refer to the FOSSIL spec.
  45.  
  46. This unit also implements FOSSIL functions which are specific to the
  47. X00 FOSSIL driver.
  48.  
  49. Additionally, this unit impelements a function to interface the FOSSIL
  50. functions into the VSERu device-indepednent serial unit.  This function,
  51. FosSerDriverProc, is a serial driver procedure for VDOSu serial channels.
  52.  
  53. FosSerDriverProc can be specified as the serial-driver for a serial
  54. channel by calling VSerDriverNew and specifying FosSerDriverProc
  55. as the serial driver procedure
  56.  
  57. <<Example>>
  58.  
  59.     { create a new serial channel       }
  60.     { use the fossil serial driver proc }
  61.     { connect channl to port # 2        }
  62.  
  63.     Err := VSerchanNew( 0,
  64.                         FosSerDriverProc,
  65.                         2,
  66.                         0,
  67.                         0,
  68.                         Serh                    );
  69.  
  70.  
  71.     { Serh is now a handle for the new serial channel }
  72.  
  73.  
  74.  
  75. <Interface>
  76.  
  77. -*)
  78.  
  79.  
  80. Unit VFosu;
  81.  
  82. Interface
  83.  
  84. Uses
  85.  
  86.   VTypesu,
  87.   VSerLu,
  88.   DOS;
  89.  
  90. {────────────────────────────────────────────────────────────────────────────}
  91.  
  92. Const
  93.  
  94.   {---------------}
  95.   { FOSSIL Errors }
  96.   {---------------}
  97.  
  98.   ferr_None       = 0;
  99.   ferr_BadCopy    = 1;
  100.  
  101.   {--------------}
  102.   { Miscellanous }
  103.   {--------------}
  104.  
  105.   sfct_None       = 0;
  106.   sfct_RtsCts     = 1;
  107.   sfct_XonXoff    = 2;
  108.  
  109.   cfPortOK        = 0;
  110.  
  111. Type
  112.  
  113.   TFosStruct  = RECORD
  114.  
  115.     StrSiz    : WORD;      { Size of this structure in bytes                 }
  116.     MajVer    : BYTE;      { FOSSIL specificiation revision                  }
  117.     MinVer    : BYTE;      { Revision of this driver                         }
  118.     IDent     : POINTER;   { Far-pointer to ASCIIZ driver description        }
  119.     IBufSize  : WORD;      { Byte size of the receive buffer                 }
  120.     IFree     : WORD;      { Number of buffered (received) bytes             }
  121.     OBufSize  : WORD;      { Byte size of the transmit buffer                }
  122.     OFree     : WORD;      { Number of buffered (transmit) bytes             }
  123.     SWidth    : BYTE;      { Width of display screen                         }
  124.     SHeight   : BYTE;      { Height of display screen                        }
  125.     Baud      : BYTE;      { Baud rate, computer to modem                    }
  126.  
  127.   End;
  128.  
  129.   {---}
  130.  
  131.   PFosIData   = ^TFosIData;
  132.   TFosIData   = RECORD
  133.  
  134.     ComPort   : BYTE;      { Communications port                             }
  135.     BaudRate  : LONGINT;   { Bits per second rate                            }
  136.     Parity    : CHAR;      { Parity of hardware error checking               }
  137.     DataBits  : BYTE;      { Number of data bits                             }
  138.     StopBits  : BYTE;      { Number of stop bits                             }
  139.     PortStat  : WORD;      { Condition of UART. LoByte=MSR,HiByte=LSR        }
  140.     UsingX00  : BOOLEAN;   { True if using X00 FOSSIL                        }
  141.     Sig       : WORD;      { $1954 if FOSSIL installed                       }
  142.  
  143.     FosStruct : TFosStruct;
  144.  
  145.   END;
  146.  
  147. {────────────────────────────────────────────────────────────────────────────}
  148.  
  149. Procedure VFosSetCommParam(            ComPort      : LONGINT;
  150.                                        BaudRate     : WORD;
  151.                                        Parity       : CHAR;
  152.                                        DataBits     : BYTE;
  153.                                        StopBits     : BYTE;
  154.                                    Var PortStat     : WORD     );
  155.  
  156. Procedure VFosSendCharW(               ComPort      : WORD;
  157.                                        Ch           : CHAR;
  158.                                    Var PortStat     : WORD     );
  159.  
  160. Procedure VFosRecvCharW(               ComPort      : WORD;
  161.                                    Var Ch           : CHAR;
  162.                                    Var PortStat     : WORD     );
  163.  
  164. Function  VFosGetChar(                 ComPort      : WORD     ) : CHAR;
  165.  
  166. Procedure VFosGetPortStat(             ComPort      : WORD;
  167.                                    Var PortStat     : WORD     );
  168.  
  169. Function  VFosChkPortStat(             ComPort      : WORD;
  170.                                        Bit          : BYTE     ) : BOOLEAN;
  171.  
  172. Procedure VFosActivatePort(            ComPort      : WORD;
  173.                                    Var Sig          : WORD;
  174.                                    Var MaxFunc      : BYTE;
  175.                                    Var FosRev       : BYTE     );
  176.  
  177. Procedure VFosDeActivatePort(          ComPort      : WORD     );
  178.  
  179. Procedure VFosSetDTR(                  ComPort      : WORD;
  180.                                        OnOff        : BOOLEAN  );
  181.  
  182. Procedure VFosGetTimeTickInfo(     Var TickNo       : BYTE;
  183.                                    Var TickPSec     : BYTE;
  184.                                    Var MilPTick     : WORD     );
  185.  
  186. Procedure VFosFlushOutBuff(            ComPort      : WORD     );
  187.  
  188. Procedure VFosPurgeOutBuff(            ComPort      : WORD     );
  189.  
  190. Procedure VFosPurgeInBuff(             ComPort      : WORD     );
  191.  
  192. Procedure VFosSendChar(                ComPort      : WORD;
  193.                                        Ch           : CHAR;
  194.                                    Var BuffFull     : BOOLEAN  );
  195.  
  196. Procedure VFosPeekAhead(               ComPort      : WORD;
  197.                                    Var BuffEmpty    : BOOLEAN;
  198.                                    Var Ch           : CHAR     );
  199.  
  200. Procedure VFosKbRead(              Var ScanCode     : WORD     );
  201.  
  202. Procedure VFosKbReadW(             Var ScanCode     : WORD     );
  203.  
  204. Procedure VFosSetFlowControl(          ComPort      : WORD;
  205.                                        FlowStat     : BYTE     );
  206.  
  207. Procedure VFosControlCheck(            ComPort      : WORD;
  208.                                        CtrlStat     : BYTE;
  209.                                    Var CtrlRecv     : BOOLEAN  );
  210.  
  211. Procedure VFosSetCurLoc(               X            : BYTE;
  212.                                        Y            : BYTE     );
  213.  
  214. Procedure VFosGetCurLoc(           Var X            : BYTE;
  215.                                    Var Y            : BYTE     );
  216.  
  217. Procedure VFosWriteANSI(               Ch           : CHAR     );
  218.  
  219. Procedure VFosSetWatchDog(             ComPort      : WORD;
  220.                                        OnOff        : BOOLEAN  );
  221.  
  222. Procedure VFosWriteBIOS(               Ch           : CHAR     );
  223.  
  224. Procedure VFosReboot(                  WarmBoot     : BOOLEAN  );
  225.  
  226. Procedure VFosRecvBlock(               ComPort      : WORD;
  227.                                        Buf          : POINTER;
  228.                                        Count        : LONGINT;
  229.                                    Var Result       : LONGINT  );
  230.  
  231. Procedure VFosSendBlock(               ComPort      : WORD;
  232.                                        Buf          : POINTER;
  233.                                        Count        : LONGINT;
  234.                                    Var Result       : LONGINT  );
  235.  
  236. Procedure VFosSetBreak(                ComPort      : WORD;
  237.                                        OnOff        : BOOLEAN  );
  238.  
  239. Procedure VFosGetInfo(                 ComPort      : WORD;
  240.                                        Buf          : POINTER;
  241.                                        Count        : WORD;
  242.                                    Var Result       : WORD;
  243.                                    Var SigS         : ST4      );
  244.  
  245. Function  VFosGetFosStruct(            ComPort      : WORD;
  246.                                    Var FosStruct    : TFosStruct) : LONGINT;
  247.  
  248. Procedure VX00ActivatePort(            ComPort      : WORD;
  249.                                    Var Sig          : WORD;
  250.                                    Var MaxFunc      : BYTE;
  251.                                    Var FosRev       : BYTE     );
  252.  
  253. Procedure VX00DeActivatePort(          ComPort      : WORD     );
  254.  
  255. Procedure VX00SetExtLineCtrl(          ComPort      : WORD;
  256.                                        Break        : BOOLEAN;
  257.                                        ParityB      : BYTE;
  258.                                        StopBits     : BYTE;
  259.                                        DataBits     : BYTE;
  260.                                        BaudRateB    : BYTE;
  261.                                    Var PortStat     : WORD     );
  262.  
  263. Procedure VX00ExtGetMCR(               ComPort      : WORD;
  264.                                    Var MCRStat      : BYTE;
  265.                                    Var PortStat     : WORD     );
  266.  
  267. Procedure VX00ExtSetMCR(               ComPort      : WORD;
  268.                                        MCRStat      : BYTE;
  269.                                    Var PortStat     : WORD     );
  270.  
  271. Procedure VX00RecvCh(                  ComPort      : WORD;
  272.                                    Var Result       : BOOLEAN;
  273.                                    Var Ch           : CHAR     );
  274.  
  275. Procedure VX00StuffInBuff(             Ch           : CHAR     );
  276.  
  277. {────────────────────────────────────────────────────────────────────────────}
  278.  
  279. Procedure FosSerDriverProc(            SDP          : PSerDriverPacket );
  280.  
  281. {────────────────────────────────────────────────────────────────────────────}
  282.  
  283. IMPLEMENTATION
  284.  
  285. Const
  286.  
  287.   fosInitSig     = $1954;
  288.  
  289. {────────────────────────────────────────────────────────────────────────────}
  290.  
  291. (*-
  292.  
  293. [FUNCTION]
  294.  
  295. Procedure VFosSetCommParam(            ComPort      : LONGINT;
  296.                                        BaudRate     : WORD;
  297.                                        Parity       : CHAR;
  298.                                        DataBits     : BYTE;
  299.                                        StopBits     : BYTE;
  300.                                    Var PortStat     : WORD     );
  301.  
  302. [PARAMETERS]
  303.  
  304. ComPort     Communications port.
  305. BaudRate    Bits per second rate.
  306. Parity      Parity of hardware error checking.
  307. DataBits    Number of data bits.
  308. StopBits    Number of stop bits.
  309.  
  310. [RETURNS]
  311.  
  312. PortStat    Condition of UART (Low Byte=MSR, High Byte=LSR).
  313.  
  314. [DESCRIPTION]
  315.  
  316. Set communications parameters: baud, parity, databits, and stopbits.  This
  317. function is identical to the IBM PC BIOS call except that 110 baud and 150
  318. baud have been replaced by 19200 baud and 38400 baud respectively.
  319.  
  320. [SEE-ALSO]
  321.  
  322. [EXAMPLE]
  323.  
  324. -*)
  325.  
  326. Procedure VFosSetCommParam(            ComPort      : LONGINT;
  327.                                        BaudRate     : WORD;
  328.                                        Parity       : CHAR;
  329.                                        DataBits     : BYTE;
  330.                                        StopBits     : BYTE;
  331.                                    Var PortStat     : WORD     );
  332.  
  333. Var
  334.  
  335.   R : REGISTERS;
  336.  
  337. BEGIN
  338.  
  339.   R.AL := 0;
  340.  
  341.   {---------------------}
  342.   { Databits (bits 0-1) }
  343.   {---------------------}
  344.  
  345.   Case DataBits of
  346.  
  347.     5 : Inc(R.AL, 0);
  348.     6 : Inc(R.AL, 1);
  349.     7 : Inc(R.AL, 2);
  350.     8 : Inc(R.AL, 3);
  351.  
  352.   End;
  353.  
  354.   {------------------}
  355.   { Stopbits (Bit 2) }
  356.   {------------------}
  357.  
  358.   Case StopBits Of
  359.  
  360.     1 : Inc(R.AL, 0);
  361.     2 : Inc(R.AL, 4);
  362.  
  363.   End;
  364.  
  365.   {-------------------}
  366.   { Parity (Bits 3-4) }
  367.   {-------------------}
  368.  
  369.   Case Parity of
  370.  
  371.     'N' : Inc(R.AL, $00); { None  }
  372.     'O' : Inc(R.AL, $08); { Odd   }
  373.     'E' : Inc(R.AL, $18); { Even  }
  374.     'M' : Inc(R.AL, $28); { Mark  }
  375.     'S' : Inc(R.AL, $38); { Space }
  376.  
  377.   End;
  378.  
  379.   {----------------------}
  380.   { Baud Rate (Bits 5-7) }
  381.   {----------------------}
  382.  
  383.   Case BaudRate of
  384.  
  385.     19200 : Inc(R.AL, $00);
  386.     300   : Inc(R.AL, $40);
  387.     600   : Inc(R.AL, $60);
  388.     1200  : Inc(R.AL, $80);
  389.     2400  : Inc(R.AL, $A0);
  390.     4800  : Inc(R.AL, $C0);
  391.     9600  : Inc(R.AL, $E0);
  392.  
  393.     Else
  394.     BEGIN
  395.  
  396.       If BaudRate = 38400 Then
  397.         Inc(R.AL, $20);
  398.  
  399.     END;
  400.  
  401.   End;
  402.  
  403.   R.AH := 0;
  404.   R.DX := ComPort;
  405.  
  406.   R.DS := 0;
  407.   R.ES := 0;
  408.  
  409.   Intr( $14, R );
  410.  
  411.   PortStat := R.AX;
  412.  
  413. END;
  414.  
  415. {────────────────────────────────────────────────────────────────────────────}
  416.  
  417. (*-
  418.  
  419. [FUNCTION]
  420.  
  421. Procedure VFosSendCharW(               ComPort      : WORD;
  422.                                        Ch           : CHAR;
  423.                                    Var PortStat     : WORD     );
  424.  
  425. [PARAMETERS]
  426.  
  427. ComPort     Communications port.
  428. Ch          Charcter to transmit.
  429.  
  430. [RETURNS]
  431.  
  432. PortStat    Condition of UART (Low Byte=MSR, High Byte=LSR).
  433.  
  434. [DESCRIPTION]
  435.  
  436. Places a character into the transmit buffer.  If no room is available, then
  437. function will loop until room becomes available or a timeout occurs (30
  438. seconds).  If a timeout occurs, the timeout bit in PortStat will be set.
  439.  
  440. [SEE-ALSO]
  441.  
  442. [EXAMPLE]
  443.  
  444. -*)
  445.  
  446. Procedure VFosSendCharW(               ComPort      : WORD;
  447.                                        Ch           : CHAR;
  448.                                    Var PortStat     : WORD     );
  449.  
  450. Var
  451.  
  452.   R : REGISTERS;
  453.  
  454. BEGIN
  455.  
  456.   R.AH := $01;
  457.   R.AL := Byte( Ch );
  458.   R.DX := ComPort;
  459.  
  460.   R.DS := 0;
  461.   R.ES := 0;
  462.  
  463.   Intr( $14, R );
  464.  
  465.   PortStat := R.AX;
  466.  
  467. END;
  468.  
  469. {────────────────────────────────────────────────────────────────────────────}
  470.  
  471. (*-
  472.  
  473. [FUNCTION]
  474.  
  475. Procedure VFosRecvCharW(               ComPort      : WORD;
  476.                                    Var Ch           : CHAR;
  477.                                    Var PortStat     : WORD     );
  478.  
  479. [PARAMETERS]
  480.  
  481. ComPort     Communications port.
  482.  
  483. [RETURNS]
  484.  
  485. Ch          Character to receive.
  486. PortStat    Condition of UART (Low Byte=MSR, High Byte=LSR)
  487.  
  488. [DESCRIPTION]
  489.  
  490. Retrieves a character from the receive buffer.  If buffer is empty, then
  491. function will wait until a character is received or a timeout occurs (30
  492. seconds).  If a timeout occurs, the timeout bit in PortStat will be set.
  493.  
  494. [SEE-ALSO]
  495.  
  496. [EXAMPLE]
  497.  
  498. -*)
  499.  
  500. Procedure VFosRecvCharW(               ComPort      : WORD;
  501.                                    Var Ch           : CHAR;
  502.                                    Var PortStat     : WORD     );
  503.  
  504. Var
  505.  
  506.   R : REGISTERS;
  507.  
  508. BEGIN
  509.  
  510.   R.AH := $02;
  511.   R.DX := ComPort;
  512.  
  513.   R.DS := 0;
  514.   R.ES := 0;
  515.  
  516.   Intr( $14, R );
  517.  
  518.   Ch       := Char( R.AL );
  519.   PortStat := (PortStat AND $FF) + (R.AH SHL 8);
  520.  
  521. END;
  522.  
  523. {────────────────────────────────────────────────────────────────────────────}
  524.  
  525. (*-
  526.  
  527. [FUNCTION]
  528.  
  529. Function  VFosGetChar(                 ComPort      : WORD     ) : CHAR;
  530.  
  531. [PARAMETERS]
  532.  
  533. ComPort     Communications port.
  534.  
  535. [RETURNS]
  536.  
  537. Character from ComPort.
  538.  
  539. [DESCRIPTION]
  540.  
  541. Convienent function to retrieve one character from ComPort.
  542.  
  543. [SEE-ALSO]
  544.  
  545. [EXAMPLE]
  546.  
  547. -*)
  548.  
  549. Function  VFosGetChar(                 ComPort      : WORD     ) : CHAR;
  550.  
  551. Var
  552.  
  553.   Ch       : CHAR;
  554.   PortStat : WORD;
  555.  
  556. BEGIN
  557.  
  558.   VFosRecvCharW( ComPort, Ch, PortStat );
  559.   VFosGetChar := Ch;
  560.  
  561. END;
  562.  
  563. {────────────────────────────────────────────────────────────────────────────}
  564.  
  565. (*-
  566.  
  567. [FUNCTION]
  568.  
  569. Procedure VFosGetPortStat(             ComPort      : WORD;
  570.                                    Var PortStat     : WORD     );
  571.  
  572. [PARAMETERS]
  573.  
  574. ComPort     Communications port.
  575.  
  576. [RETURNS]
  577.  
  578. PortStat    Condition of UART (Low Byte=MSR, High Byte=LSR).
  579.  
  580. [DESCRIPTION]
  581.  
  582. Returns serial port status.  The PortStat bitfield is to be used by the
  583. MSR/LSR constants.
  584.  
  585. [SEE-ALSO]
  586.  
  587. [EXAMPLE]
  588.  
  589. -*)
  590.  
  591. Procedure VFosGetPortStat(             ComPort      : WORD;
  592.                                    Var PortStat     : WORD     );
  593.  
  594. Var
  595.  
  596.   R : REGISTERS;
  597.  
  598. BEGIN
  599.  
  600.   R.AH := $03;
  601.   R.DX := ComPort;
  602.  
  603.   R.DS := 0;
  604.   R.ES := 0;
  605.  
  606.   Intr( $14, R );
  607.  
  608.   PortStat := R.AX;
  609.  
  610. END;
  611.  
  612. {────────────────────────────────────────────────────────────────────────────}
  613.  
  614. (*-
  615.  
  616. [FUNCTION]
  617.  
  618. Function  VFosChkPortStat(             ComPort      : WORD;
  619.                                        Bit          : BYTE     ) : BOOLEAN;
  620.  
  621. [PARAMETERS]
  622.  
  623. ComPort     Communications port.
  624. Bit         Bit in Port Status to check.
  625.  
  626. [RETURNS]
  627.  
  628. BOOLEAN condition of bitfield.
  629.  
  630. [DESCRIPTION]
  631.  
  632. Checks whether a bit location is set inside PortStat.
  633.  
  634. [SEE-ALSO]
  635.  
  636. [EXAMPLE]
  637.  
  638. -*)
  639.  
  640. Function  VFosChkPortStat(             ComPort      : WORD;
  641.                                        Bit          : BYTE     ) : BOOLEAN;
  642.  
  643. Var
  644.  
  645.   PortStat : WORD;
  646.  
  647. BEGIN
  648.  
  649.   VFosGetPortStat( ComPort, PortStat );
  650.   VFosChkPortStat := ( PortStat AND CBitMapW[Bit] ) <> 0;
  651.  
  652. END;
  653.  
  654. {────────────────────────────────────────────────────────────────────────────}
  655.  
  656. (*-
  657.  
  658. [FUNCTION]
  659.  
  660. Procedure VFosActivatePort(            ComPort      : WORD;
  661.                                    Var Sig          : WORD;
  662.                                    Var MaxFunc      : BYTE;
  663.                                    Var FosRev       : BYTE     );
  664.  
  665. [PARAMETERS]
  666.  
  667. ComPort     Communications port.
  668.  
  669. [RETURNS]
  670.  
  671. Sig         Signature of communications driver installed.
  672. MaxFunc     Number of functions supported by driver.
  673. FosRev      Revision of the installed FOSSIL specification.
  674.  
  675. [DESCRIPTION]
  676.  
  677. This installs FOSSIL functions for the specified ComPort.  Use this before
  678. any use of other ComPort dependant functions.  When called, DTR is raised,
  679. but baud rate is not effected.  Any additional call to this function to an
  680. installed ComPort will clear all buffers and flow control.
  681.  
  682. [SEE-ALSO]
  683.  
  684. [EXAMPLE]
  685.  
  686. -*)
  687.  
  688. Procedure VFosActivatePort(            ComPort      : WORD;
  689.                                    Var Sig          : WORD;
  690.                                    Var MaxFunc      : BYTE;
  691.                                    Var FosRev       : BYTE     );
  692.  
  693. Var
  694.  
  695.   R : REGISTERS;
  696.  
  697. BEGIN
  698.  
  699.   R.AH := $04;
  700.   R.DX := ComPort;
  701.  
  702.   R.DS := 0;
  703.   R.ES := 0;
  704.  
  705.   Intr( $14, R );
  706.  
  707.   Sig     := R.AX;
  708.   MaxFunc := R.BL;
  709.   FosRev  := R.BH;
  710.  
  711. END;
  712.  
  713. {────────────────────────────────────────────────────────────────────────────}
  714.  
  715. (*-
  716.  
  717. [FUNCTION]
  718.  
  719. Procedure VFosDeActivatePort(          ComPort      : WORD     );
  720.  
  721. [PARAMETERS]
  722.  
  723. ComPort     Communications port.
  724.  
  725. [RETURNS]
  726.  
  727. [DESCRIPTION]
  728.  
  729. Deactivates FOSSIL functions for the specified ComPort.
  730.  
  731. [SEE-ALSO]
  732.  
  733. [EXAMPLE]
  734.  
  735. -*)
  736.  
  737. Procedure VFosDeActivatePort(          ComPort      : WORD     );
  738.  
  739. Var
  740.  
  741.   R : REGISTERS;
  742.  
  743. BEGIN
  744.  
  745.   R.AH := $05;
  746.   R.DX := ComPort;
  747.  
  748.   R.DS := 0;
  749.   R.ES := 0;
  750.  
  751.   Intr( $14, R );
  752.  
  753. END;
  754.  
  755. {────────────────────────────────────────────────────────────────────────────}
  756.  
  757. (*-
  758.  
  759. [FUNCTION]
  760.  
  761. Procedure VFosSetDTR(                  ComPort      : WORD;
  762.                                        OnOff        : BOOLEAN  );
  763.  
  764. [PARAMETERS]
  765.  
  766. ComPort     Communications port.
  767. OnOff       On/Off (True/False) switch for this function.
  768.  
  769. [RETURNS]
  770.  
  771. [DESCRIPTION]
  772.  
  773. Controls the DTR signal.
  774.  
  775. [SEE-ALSO]
  776.  
  777. [EXAMPLE]
  778.  
  779. -*)
  780.  
  781. Procedure VFosSetDTR(                  ComPort      : WORD;
  782.                                        OnOff        : BOOLEAN  );
  783.  
  784. Var
  785.  
  786.   R : REGISTERS;
  787.  
  788. BEGIN
  789.  
  790.   R.AH := $06;
  791.   R.AL := Byte( OnOff );
  792.   R.DX := ComPort;
  793.  
  794.   R.DS := 0;
  795.   R.ES := 0;
  796.  
  797.   Intr( $14, R );
  798.  
  799. END;
  800.  
  801. {────────────────────────────────────────────────────────────────────────────}
  802.  
  803. (*-
  804.  
  805. [FUNCTION]
  806.  
  807. Procedure VFosGetTimeTickInfo(     Var TickNo       : BYTE;
  808.                                    Var TickPSec     : BYTE;
  809.                                    Var MilPTick     : WORD     );
  810.  
  811. [PARAMETERS]
  812.  
  813. [RETURNS]
  814.  
  815. TickNo      Timer tick interrupt number.
  816. TickPSec    Approximate interrupts per second (18 on IBM).
  817. MilPTick    Approximate number of milliseconds per tick.
  818.  
  819. [DESCRIPTION]
  820.  
  821. Returns the properties of the CPU's timer ticks.
  822.  
  823. [SEE-ALSO]
  824.  
  825. [EXAMPLE]
  826.  
  827. -*)
  828.  
  829. Procedure VFosGetTimeTickInfo(     Var TickNo       : BYTE;
  830.                                    Var TickPSec     : BYTE;
  831.                                    Var MilPTick     : WORD     );
  832.  
  833. Var
  834.  
  835.   R : REGISTERS;
  836.  
  837. BEGIN
  838.  
  839.   R.AH := $07;
  840.  
  841.   R.DS := 0;
  842.   R.ES := 0;
  843.  
  844.   Intr( $14, R );
  845.  
  846.   TickNo   := R.AL;
  847.   TickPSec := R.AH;
  848.   MilPTick := R.DX;
  849.  
  850. END;
  851.  
  852. {────────────────────────────────────────────────────────────────────────────}
  853.  
  854. (*-
  855.  
  856. [FUNCTION]
  857.  
  858. Procedure VFosFlushOutBuff(            ComPort      : WORD     );
  859.  
  860. [PARAMETERS]
  861.  
  862. ComPort     Communications port.
  863.  
  864. [RETURNS]
  865.  
  866. [DESCRIPTION]
  867.  
  868. Flushs the transmit buffer.  Waits until all the output is sent.
  869.  
  870. [SEE-ALSO]
  871.  
  872. [EXAMPLE]
  873.  
  874. -*)
  875.  
  876. Procedure VFosFlushOutBuff(            ComPort      : WORD     );
  877.  
  878. Var
  879.  
  880.   R : REGISTERS;
  881.  
  882. BEGIN
  883.  
  884.   R.AH := $08;
  885.   R.DX := ComPort;
  886.  
  887.   R.DS := 0;
  888.   R.ES := 0;
  889.  
  890.   Intr( $14, R );
  891.  
  892. END;
  893.  
  894. {────────────────────────────────────────────────────────────────────────────}
  895.  
  896. (*-
  897.  
  898. [FUNCTION]
  899.  
  900. Procedure VFosPurgeOutBuff(            ComPort      : WORD     );
  901.  
  902. [PARAMETERS]
  903.  
  904. ComPort     Communications port.
  905.  
  906. [RETURNS]
  907.  
  908. [DESCRIPTION]
  909.  
  910. Emptys the transmit buffer by removing all characters.
  911.  
  912. [SEE-ALSO]
  913.  
  914. [EXAMPLE]
  915.  
  916. -*)
  917.  
  918. Procedure VFosPurgeOutBuff(            ComPort      : WORD     );
  919.  
  920. Var
  921.  
  922.   R : REGISTERS;
  923.  
  924. BEGIN
  925.  
  926.   R.AH := $09;
  927.   R.DX := ComPort;
  928.  
  929.   R.DS := 0;
  930.   R.ES := 0;
  931.  
  932.   Intr( $14, R );
  933.  
  934. END;
  935.  
  936. {────────────────────────────────────────────────────────────────────────────}
  937.  
  938. (*-
  939.  
  940. [FUNCTION]
  941.  
  942. Procedure VFosPurgeInBuff(             ComPort      : WORD     );
  943.  
  944. [PARAMETERS]
  945.  
  946. ComPort     Communications port.
  947.  
  948. [RETURNS]
  949.  
  950. [DESCRIPTION]
  951.  
  952. Emptys the receive buffer by removing all characters.
  953.  
  954. [SEE-ALSO]
  955.  
  956. [EXAMPLE]
  957.  
  958. -*)
  959.  
  960. Procedure VFosPurgeInBuff(             ComPort      : WORD     );
  961.  
  962. Var
  963.  
  964.   R : REGISTERS;
  965.  
  966. BEGIN
  967.  
  968.   R.AH := $0A;
  969.   R.DX := ComPort;
  970.  
  971.   R.DS := 0;
  972.   R.ES := 0;
  973.  
  974.   Intr( $14, R );
  975.  
  976. END;
  977.  
  978. {────────────────────────────────────────────────────────────────────────────}
  979.  
  980. (*-
  981.  
  982. [FUNCTION]
  983.  
  984. Procedure VFosSendChar(                ComPort      : WORD;
  985.                                        Ch           : CHAR;
  986.                                    Var BuffFull     : BOOLEAN  );
  987.  
  988. [PARAMETERS]
  989.  
  990. ComPort     Communications port.
  991. Ch          Charcter to transmit.
  992.  
  993. [RETURNS]
  994.  
  995. BuffFull    Is the transmit buffer full?
  996.  
  997. [DESCRIPTION]
  998.  
  999. Places a character into the transmit buffer.  If no room is available (the
  1000. character was not buffered), the BuffFull will be set.
  1001.  
  1002. [SEE-ALSO]
  1003.  
  1004. [EXAMPLE]
  1005.  
  1006. -*)
  1007.  
  1008. Procedure VFosSendChar(                ComPort      : WORD;
  1009.                                        Ch           : CHAR;
  1010.                                    Var BuffFull     : BOOLEAN  );
  1011.  
  1012. Var
  1013.  
  1014.   R : REGISTERS;
  1015.  
  1016. BEGIN
  1017.  
  1018.   R.AH := $0B;
  1019.   R.AL := Byte( Ch );
  1020.   R.DX := ComPort;
  1021.  
  1022.   R.DS := 0;
  1023.   R.ES := 0;
  1024.  
  1025.   Intr( $14, R );
  1026.  
  1027.   BuffFull := (R.AX = 0);
  1028.  
  1029. END;
  1030.  
  1031. {────────────────────────────────────────────────────────────────────────────}
  1032.  
  1033. (*-
  1034.  
  1035. [FUNCTION]
  1036.  
  1037. Procedure VFosPeekAhead(               ComPort      : WORD;
  1038.                                    Var BuffEmpty    : BOOLEAN;
  1039.                                    Var Ch           : CHAR     );
  1040.  
  1041. [PARAMETERS]
  1042.  
  1043. ComPort     Communications port.
  1044.  
  1045. [RETURNS]
  1046.  
  1047. BuffEmpty   Is the receive buffer empty?
  1048. Ch          Character to get from receive buffer.
  1049.  
  1050. [DESCRIPTION]
  1051.  
  1052. Issues a non-destructive read-ahead (peek) through the recieve buffer and
  1053. returns the next character from the receive buffer.  If the buffer is empty,
  1054. then BuffEmpty is set.
  1055.  
  1056. [SEE-ALSO]
  1057.  
  1058. [EXAMPLE]
  1059.  
  1060. -*)
  1061.  
  1062. Procedure VFosPeekAhead(               ComPort      : WORD;
  1063.                                    Var BuffEmpty    : BOOLEAN;
  1064.                                    Var Ch           : CHAR     );
  1065.  
  1066. Var
  1067.  
  1068.   R : REGISTERS;
  1069.  
  1070. BEGIN
  1071.  
  1072.   R.AH := $0C;
  1073.   R.DX := ComPort;
  1074.  
  1075.   R.DS := 0;
  1076.   R.ES := 0;
  1077.  
  1078.   Intr( $14, R );
  1079.  
  1080.   Ch        := Char( R.AL );
  1081.   BuffEmpty := ( R.AX = $FFFF );
  1082.  
  1083. END;
  1084.  
  1085. {────────────────────────────────────────────────────────────────────────────}
  1086.  
  1087. (*-
  1088.  
  1089. [FUNCTION]
  1090.  
  1091. Procedure VFosKbRead(              Var ScanCode     : WORD     );
  1092.  
  1093. [PARAMETERS]
  1094.  
  1095. [RETURNS]
  1096.  
  1097. ScanCode    Scancode from local keyboard.
  1098.  
  1099. [DESCRIPTION]
  1100.  
  1101. Returns a keyboard scancode of the next character in keyboard buffer. This
  1102. will not remove the character from the buffer - only "peeks".  If no
  1103. character is available, ScanCode will return as $FFFF.
  1104.  
  1105. [SEE-ALSO]
  1106.  
  1107. [EXAMPLE]
  1108.  
  1109. -*)
  1110.  
  1111. Procedure VFosKbRead(              Var ScanCode     : WORD     );
  1112.  
  1113. Var
  1114.  
  1115.   R : REGISTERS;
  1116.  
  1117. BEGIN
  1118.  
  1119.   R.AH := $0D;
  1120.  
  1121.   R.DS := 0;
  1122.   R.ES := 0;
  1123.  
  1124.   Intr( $14, R );
  1125.  
  1126.   ScanCode := R.AX;
  1127.  
  1128. END;
  1129.  
  1130. {────────────────────────────────────────────────────────────────────────────}
  1131.  
  1132. (*-
  1133.  
  1134. [FUNCTION]
  1135.  
  1136. Procedure VFosKbReadW(             Var ScanCode     : WORD     );
  1137.  
  1138. [PARAMETERS]
  1139.  
  1140. [RETURNS]
  1141.  
  1142. ScanCode    Scancode from local keyboard.
  1143.  
  1144. [DESCRIPTION]
  1145.  
  1146. Returns next character available from keyboard.  If no character is
  1147. available, then function will loop until a scancode is available.
  1148.  
  1149. [SEE-ALSO]
  1150.  
  1151. [EXAMPLE]
  1152.  
  1153. -*)
  1154.  
  1155. Procedure VFosKbReadW(             Var ScanCode     : WORD     );
  1156.  
  1157. Var
  1158.  
  1159.   R : REGISTERS;
  1160.  
  1161. BEGIN
  1162.  
  1163.   R.AH := $0E;
  1164.  
  1165.   R.DS := 0;
  1166.   R.ES := 0;
  1167.  
  1168.   Intr( $14, R );
  1169.  
  1170.   ScanCode := R.AX;
  1171.  
  1172. END;
  1173.  
  1174. {────────────────────────────────────────────────────────────────────────────}
  1175.  
  1176. (*-
  1177.  
  1178. [FUNCTION]
  1179.  
  1180. Procedure VFosSetFlowControl(          ComPort      : WORD;
  1181.                                        FlowStat     : BYTE     );
  1182.  
  1183. [PARAMETERS]
  1184.  
  1185. ComPort     Communications port.
  1186. FlowStat    Flow control bitfield as defined:
  1187.  
  1188.               Bit 0 = 1 Enable receiving of Xon/Xoff. This will stop
  1189.                         transmitting when Xoff is received.
  1190.  
  1191.               Bit 1 = 1 Enable RTS/CTS flow control. This will drop RTS
  1192.                         when receive buffer is 3/4 full and will be
  1193.                         raised when buffer is emptied to 1/4 full.  If
  1194.                         the baud rate is locked, then RTS/CTS will be
  1195.                         forced.
  1196.  
  1197.               Bit 2 = 0 Reserved.  Should always be 0.
  1198.  
  1199.               Bit 3 = 1 Enable transmitting of Xon/Xoff.  This will
  1200.                         send an Xoff when the buffers are 3/4 full, and
  1201.                         will send an Xon when they return to 1/4 full.
  1202.  
  1203. [RETURNS]
  1204.  
  1205. [DESCRIPTION]
  1206.  
  1207. Sets flow control for the serial I/O.  Xon/XOff (Software) and
  1208. RTS/CTS (Hardware) can both be enabled at the same time.
  1209.  
  1210. [SEE-ALSO]
  1211.  
  1212. [EXAMPLE]
  1213.  
  1214. -*)
  1215.  
  1216. Procedure VFosSetFlowControl(          ComPort      : WORD;
  1217.                                        FlowStat     : BYTE     );
  1218.  
  1219. Var
  1220.  
  1221.   R : REGISTERS;
  1222.  
  1223. BEGIN
  1224.  
  1225.   R.AH := $0F;
  1226.   R.AL := FlowStat;
  1227.   R.DX := ComPort;
  1228.  
  1229.   R.DS := 0;
  1230.   R.ES := 0;
  1231.  
  1232.   Intr( $14, R );
  1233.  
  1234. END;
  1235.  
  1236. {────────────────────────────────────────────────────────────────────────────}
  1237.  
  1238. (*-
  1239.  
  1240. [FUNCTION]
  1241.  
  1242. Procedure VFosControlCheck(            ComPort      : WORD;
  1243.                                        CtrlStat     : BYTE;
  1244.                                    Var CtrlRecv     : BOOLEAN  );
  1245.  
  1246. [PARAMETERS]
  1247.  
  1248. ComPort     Communications port.
  1249. CtrlStat    bitfield as defined:
  1250.  
  1251.             Bit 0 = 1  Enable Ctrl-C/Ctrl-K checking.  If a Ctrl-C
  1252.                        or a Ctrl-K is received, this will set an
  1253.                        internal flag to be used as software needs.
  1254.  
  1255.             Bit 1 = 1  Disable the transmitter buffer.  This is not
  1256.                        absolute, as other functions re-enable the
  1257.                        transmitter.
  1258.  
  1259. [RETURNS]
  1260.  
  1261. CtrlRecv    True if a Ctrl-C or Ctrl-K has been received.
  1262.  
  1263. [DESCRIPTION]
  1264.  
  1265. Sets internal Control-C and Control-K checking.
  1266.  
  1267. [SEE-ALSO]
  1268.  
  1269. [EXAMPLE]
  1270.  
  1271. -*)
  1272.  
  1273. Procedure VFosControlCheck(            ComPort      : WORD;
  1274.                                        CtrlStat     : BYTE;
  1275.                                    Var CtrlRecv     : BOOLEAN  );
  1276.  
  1277. Var
  1278.  
  1279.   R : REGISTERS;
  1280.  
  1281. BEGIN
  1282.  
  1283.   R.AH := $10;
  1284.   R.AL := CtrlStat;
  1285.   R.DX := ComPort;
  1286.  
  1287.   R.DS := 0;
  1288.   R.ES := 0;
  1289.  
  1290.   Intr( $14, R );
  1291.  
  1292.   CtrlRecv := ( R.AX = 1 );
  1293.  
  1294. END;
  1295.  
  1296. {────────────────────────────────────────────────────────────────────────────}
  1297.  
  1298. (*-
  1299.  
  1300. [FUNCTION]
  1301.  
  1302. Procedure VFosSetCurLoc(               X            : BYTE;
  1303.                                        Y            : BYTE     );
  1304.  
  1305. [PARAMETERS]
  1306.  
  1307. X           Column to set cursor location.
  1308. Y           Row to set cursor location.
  1309.  
  1310. [RETURNS]
  1311.  
  1312. [DESCRIPTION]
  1313.  
  1314. Sets the current cursor location on the local screen.  The coordinates are
  1315. zero-based.
  1316.  
  1317. [SEE-ALSO]
  1318.  
  1319. [EXAMPLE]
  1320.  
  1321. -*)
  1322.  
  1323. Procedure VFosSetCurLoc(               X            : BYTE;
  1324.                                        Y            : BYTE     );
  1325. Var
  1326.  
  1327.   R : REGISTERS;
  1328.  
  1329. BEGIN
  1330.  
  1331.   R.AH := $11;
  1332.   R.DH := Y;  { Row }
  1333.   R.DL := X;  { Column }
  1334.  
  1335.   R.DS := 0;
  1336.   R.ES := 0;
  1337.  
  1338.   Intr( $14, R );
  1339.  
  1340. END;
  1341.  
  1342. {────────────────────────────────────────────────────────────────────────────}
  1343.  
  1344. (*-
  1345.  
  1346. [FUNCTION]
  1347.  
  1348. Procedure VFosGetCurLoc(           Var X            : BYTE;
  1349.                                    Var Y            : BYTE     );
  1350.  
  1351. [PARAMETERS]
  1352.  
  1353. [RETURNS]
  1354.  
  1355. X           Column of cursor location.
  1356. Y           Row of cursor location.
  1357.  
  1358. [DESCRIPTION]
  1359.  
  1360. Gets the current cursor location on the local screen.  The coordinates are
  1361. zero-based.
  1362.  
  1363. [SEE-ALSO]
  1364.  
  1365. [EXAMPLE]
  1366.  
  1367. -*)
  1368.  
  1369. Procedure VFosGetCurLoc(           Var X            : BYTE;
  1370.                                    Var Y            : BYTE     );
  1371. Var
  1372.  
  1373.   R : REGISTERS;
  1374.  
  1375. BEGIN
  1376.  
  1377.   R.AH := $12;
  1378.  
  1379.   R.DS := 0;
  1380.   R.ES := 0;
  1381.  
  1382.   Intr( $14, R );
  1383.  
  1384.   Y := R.DH;
  1385.   X := R.DL;
  1386.  
  1387. END;
  1388.  
  1389. {────────────────────────────────────────────────────────────────────────────}
  1390.  
  1391. (*-
  1392.  
  1393. [FUNCTION]
  1394.  
  1395. Procedure VFosWriteANSI(               Ch           : CHAR     );
  1396.  
  1397. [PARAMETERS]
  1398.  
  1399. Ch          Character for screen.
  1400.  
  1401. [RETURNS]
  1402.  
  1403. [DESCRIPTION]
  1404.  
  1405. Prints a single character to the local screen using ANSI writes.  An ANSI
  1406. device driver is required.
  1407.  
  1408. [SEE-ALSO]
  1409.  
  1410. [EXAMPLE]
  1411.  
  1412. -*)
  1413.  
  1414. Procedure VFosWriteANSI(               Ch           : CHAR     );
  1415.  
  1416. Var
  1417.  
  1418.   R : REGISTERS;
  1419.  
  1420. BEGIN
  1421.  
  1422.   R.AH := $13;
  1423.   R.AL := Byte( CH );
  1424.  
  1425.   R.DS := 0;
  1426.   R.ES := 0;
  1427.  
  1428.   Intr( $14, R );
  1429.  
  1430. END;
  1431.  
  1432. {────────────────────────────────────────────────────────────────────────────}
  1433.  
  1434. (*-
  1435.  
  1436. [FUNCTION]
  1437.  
  1438. Procedure VFosSetWatchDog(             ComPort      : WORD;
  1439.                                        OnOff        : BOOLEAN  );
  1440.  
  1441. [PARAMETERS]
  1442.  
  1443. ComPort     Communications port.
  1444. OnOff       On/Off (True/False) switch for this function.
  1445.  
  1446. [RETURNS]
  1447.  
  1448. [DESCRIPTION]
  1449.  
  1450. The DCD WatchDog monitors carrier detection of a specified ComPort.  If
  1451. enabled, upon a carrier drop, the system will reboot.
  1452.  
  1453. [SEE-ALSO]
  1454.  
  1455. [EXAMPLE]
  1456.  
  1457. -*)
  1458.  
  1459. Procedure VFosSetWatchDog(             ComPort      : WORD;
  1460.                                        OnOff        : BOOLEAN  );
  1461.  
  1462. Var
  1463.  
  1464.   R : REGISTERS;
  1465.  
  1466. BEGIN
  1467.  
  1468.   R.AH := $14;
  1469.   R.AL := Byte( OnOff );
  1470.   R.DX := ComPort;
  1471.  
  1472.   R.DS := 0;
  1473.   R.ES := 0;
  1474.  
  1475.   Intr( $14, R );
  1476.  
  1477. END;
  1478.  
  1479. {────────────────────────────────────────────────────────────────────────────}
  1480.  
  1481. (*-
  1482.  
  1483. [FUNCTION]
  1484.  
  1485. Procedure VFosWriteBIOS(               Ch           : CHAR     );
  1486.  
  1487. [PARAMETERS]
  1488.  
  1489. Ch          Charcter for the local screen.
  1490.  
  1491. [RETURNS]
  1492.  
  1493. [DESCRIPTION]
  1494.  
  1495. Writes a single character to the local screen using a BIOS-level routine.
  1496.  
  1497. [SEE-ALSO]
  1498.  
  1499. [EXAMPLE]
  1500.  
  1501. -*)
  1502.  
  1503. Procedure VFosWriteBIOS(               Ch           : CHAR     );
  1504.  
  1505. Var
  1506.  
  1507.   R : REGISTERS;
  1508.  
  1509. BEGIN
  1510.  
  1511.   R.AH := $15;
  1512.   R.AL := Byte( Ch );
  1513.  
  1514.   R.DS := 0;
  1515.   R.ES := 0;
  1516.  
  1517.   Intr( $14, R );
  1518.  
  1519. END;
  1520.  
  1521. {────────────────────────────────────────────────────────────────────────────}
  1522.  
  1523. {----------------------------------------------------------------------------}
  1524. {                                                                            }
  1525. { Function 16h - Add or delete a routine from the timer tick                 }
  1526. {                                                                            }
  1527. { FUNCTION NOT SUPPORTED.  See VMULTI.                                       }
  1528. {                                                                            }
  1529. {----------------------------------------------------------------------------}
  1530.  
  1531. {
  1532. Procedure VFosSetTimerProc(        OnOff    : BOOLEAN;
  1533.                                    ProcPtr  : POINTER;
  1534.                                Var Success  : BOOLEAN             );
  1535.  
  1536. BEGIN
  1537. END;
  1538. }
  1539.  
  1540. {────────────────────────────────────────────────────────────────────────────}
  1541.  
  1542. (*-
  1543.  
  1544. [FUNCTION]
  1545.  
  1546. Procedure VFosReboot(                  WarmBoot     : BOOLEAN  );
  1547.  
  1548. [PARAMETERS]
  1549.  
  1550. WarmBoot    Warmboot if true, Coldboot if false.
  1551.  
  1552. [RETURNS]
  1553.  
  1554. [DESCRIPTION]
  1555.  
  1556. Reboots the system, allowing for a warm or cold boot.
  1557.  
  1558. [SEE-ALSO]
  1559.  
  1560. [EXAMPLE]
  1561.  
  1562. -*)
  1563.  
  1564. Procedure VFosReboot(                  WarmBoot     : BOOLEAN  );
  1565.  
  1566. Var
  1567.  
  1568.   R : REGISTERS;
  1569.  
  1570. BEGIN
  1571.  
  1572.   R.AH := $17;
  1573.   R.AL := Byte(WarmBoot);
  1574.  
  1575.   R.DS := 0;
  1576.   R.ES := 0;
  1577.  
  1578.   Intr( $14, R );
  1579.  
  1580. END;
  1581.  
  1582. {────────────────────────────────────────────────────────────────────────────}
  1583.  
  1584. (*-
  1585.  
  1586. [FUNCTION]
  1587.  
  1588. Procedure VFosRecvBlock(               ComPort      : WORD;
  1589.                                        Buf          : POINTER;
  1590.                                        Count        : LONGINT;
  1591.                                    Var Result       : LONGINT  );
  1592.  
  1593. [PARAMETERS]
  1594.  
  1595. ComPort     Communications port.
  1596. Buf         Any variable.
  1597. Count       An expression of bytes to read.
  1598.  
  1599. [RETURNS]
  1600.  
  1601. Result      A variable of bytes actually read.
  1602.  
  1603. [DESCRIPTION]
  1604.  
  1605. Gets an stream of characters from the receive buffer to an internal buffer.
  1606.  
  1607. [SEE-ALSO]
  1608.  
  1609. [EXAMPLE]
  1610.  
  1611. -*)
  1612.  
  1613. Procedure VFosRecvBlock(               ComPort      : WORD;
  1614.                                        Buf          : POINTER;
  1615.                                        Count        : LONGINT;
  1616.                                    Var Result       : LONGINT  );
  1617.  
  1618. Var
  1619.  
  1620.   R : REGISTERS;
  1621.  
  1622. BEGIN
  1623.  
  1624.   R.AH := $18;
  1625.   R.CX := Count;
  1626.   R.DX := ComPort;
  1627.   R.ES := Seg( Buf^ );
  1628.   R.DI := Ofs( Buf^ );
  1629.  
  1630.   R.DS := 0;
  1631.  
  1632.   Intr( $14, R );
  1633.  
  1634.   Result := R.AX;
  1635.  
  1636. END;
  1637.  
  1638. {────────────────────────────────────────────────────────────────────────────}
  1639.  
  1640. (*-
  1641.  
  1642. [FUNCTION]
  1643.  
  1644. Procedure VFosSendBlock(               ComPort      : WORD;
  1645.                                        Buf          : POINTER;
  1646.                                        Count        : LONGINT;
  1647.                                    Var Result       : LONGINT  );
  1648.  
  1649. [PARAMETERS]
  1650.  
  1651. ComPort     Communications port.
  1652. Buf         Any variable.
  1653. Count       An expression of bytes to write.
  1654.  
  1655. [RETURNS]
  1656.  
  1657. Result      A variable of bytes actually wrote.
  1658.  
  1659. [DESCRIPTION]
  1660.  
  1661. Puts a stream of characters from an internal buffer into the transmit buffer.
  1662.  
  1663. [SEE-ALSO]
  1664.  
  1665. [EXAMPLE]
  1666.  
  1667. -*)
  1668.  
  1669. Procedure VFosSendBlock(               ComPort      : WORD;
  1670.                                        Buf          : POINTER;
  1671.                                        Count        : LONGINT;
  1672.                                    Var Result       : LONGINT  );
  1673.  
  1674. Var
  1675.  
  1676.   R : REGISTERS;
  1677.  
  1678. BEGIN
  1679.  
  1680.   R.AH := $19;
  1681.   R.CX := Count;
  1682.   R.DX := ComPort;
  1683.   R.ES := Seg( Buf^ );
  1684.   R.DI := Ofs( Buf^ );
  1685.  
  1686.   R.DS := 0;
  1687.  
  1688.   Intr( $14, R );
  1689.  
  1690.   Result := R.AX;
  1691.  
  1692. END;
  1693.  
  1694. {────────────────────────────────────────────────────────────────────────────}
  1695.  
  1696. (*-
  1697.  
  1698. [FUNCTION]
  1699.  
  1700. Procedure VFosSetBreak(                ComPort      : WORD;
  1701.                                        OnOff        : BOOLEAN  );
  1702.  
  1703. [PARAMETERS]
  1704.  
  1705. ComPort     Communications port.
  1706. OnOff       On/Off (True/False) switch for this function.
  1707.  
  1708. [RETURNS]
  1709.  
  1710. [DESCRIPTION]
  1711.  
  1712. Sends a break signal to ComPort - useful for activating command mode on
  1713. some modems.  If Xoff is currently active, this function will clear that
  1714. flag.  Break durations should be less than 1/10th of a second.
  1715.  
  1716. [SEE-ALSO]
  1717.  
  1718. [EXAMPLE]
  1719.  
  1720. -*)
  1721.  
  1722. Procedure VFosSetBreak(                ComPort      : WORD;
  1723.                                        OnOff        : BOOLEAN  );
  1724.  
  1725. Var
  1726.  
  1727.   R : REGISTERS;
  1728.  
  1729. BEGIN
  1730.  
  1731.   R.AH := $1A;
  1732.   R.AL := Byte( OnOff );
  1733.   R.DX := ComPort;
  1734.  
  1735.   R.DS := 0;
  1736.   R.ES := 0;
  1737.  
  1738.   Intr( $14, R );
  1739.  
  1740. END;
  1741.  
  1742. {────────────────────────────────────────────────────────────────────────────}
  1743.  
  1744. (*-
  1745.  
  1746. [FUNCTION]
  1747.  
  1748. Procedure VFosGetInfo(                 ComPort      : WORD;
  1749.                                        Buf          : POINTER;
  1750.                                        Count        : WORD;
  1751.                                    Var Result       : WORD;
  1752.                                    Var SigS         : ST4      );
  1753.  
  1754. [PARAMETERS]
  1755.  
  1756. ComPort     Communications port.
  1757. Buf         Variable of type TFosStruct.
  1758. Count       An expression of bytes to read.
  1759.  
  1760. [RETURNS]
  1761.  
  1762. Result      A variable of bytes actually read.
  1763. SigS        Signature of FOSSIL driver installed.
  1764.  
  1765. [DESCRIPTION]
  1766.  
  1767. Gets information about the current FOSSIL environment.
  1768.  
  1769. [SEE-ALSO]
  1770.  
  1771. [EXAMPLE]
  1772.  
  1773. -*)
  1774.  
  1775. Procedure VFosGetInfo(                 ComPort      : WORD;
  1776.                                        Buf          : POINTER;
  1777.                                        Count        : WORD;
  1778.                                    Var Result       : WORD;
  1779.                                    Var SigS         : ST4      );
  1780.  
  1781. Var
  1782.  
  1783.   R : REGISTERS;
  1784.  
  1785. BEGIN
  1786.  
  1787.   R.AH := $1B;
  1788.   R.CX := Count;
  1789.   R.DX := ComPort;
  1790.   R.ES := Seg( Buf^ );
  1791.   R.DI := Ofs( Buf^ );
  1792.  
  1793.   R.DS := 0;
  1794.  
  1795.   Intr( $14, R );
  1796.  
  1797.   Result := R.AX;
  1798.   SigS   := Char(Lo(R.CX)) + Char(Hi(R.CX)) +
  1799.             Char(Lo(R.DX)) + Char(Hi(R.DX));
  1800.  
  1801. END;
  1802.  
  1803. {────────────────────────────────────────────────────────────────────────────}
  1804.  
  1805. (*-
  1806.  
  1807. [FUNCTION]
  1808.  
  1809. Function VFosGetFosStruct(             ComPort      : WORD;
  1810.                                    Var FosStruct    : TFosStruct) : LONGINT;
  1811.  
  1812. [PARAMETERS]
  1813.  
  1814. ComPort     Communications port.
  1815.  
  1816. [RETURNS]
  1817.  
  1818. FosStruct   FOSSIL environment table.
  1819.  
  1820. [DESCRIPTION]
  1821.  
  1822. Gets information about the current FOSSIL environment using a simpler format.
  1823.  
  1824. [SEE-ALSO]
  1825.  
  1826. [EXAMPLE]
  1827.  
  1828. -*)
  1829.  
  1830. Function VFosGetFosStruct(             ComPort      : WORD;
  1831.                                    Var FosStruct    : TFosStruct) : LONGINT;
  1832.  
  1833. Var
  1834.  
  1835.   Result : WORD;
  1836.   Sig    : ST4;
  1837.  
  1838. BEGIN
  1839.  
  1840.   VFosGetInfo(ComPort, @FosStruct, SizeOf(FosStruct), Result, Sig );
  1841.  
  1842.   If Result = SizeOf(FosStruct) Then
  1843.     VFosGetFosStruct := ferr_None
  1844.   Else
  1845.     VFosGetFosStruct := ferr_BadCopy;
  1846.  
  1847. END;
  1848.  
  1849. {────────────────────────────────────────────────────────────────────────────}
  1850.  
  1851. (*-
  1852.  
  1853. [FUNCTION]
  1854.  
  1855. Procedure VX00ActivatePort(            ComPort      : WORD;
  1856.                                    Var Sig          : WORD;
  1857.                                    Var MaxFunc      : BYTE;
  1858.                                    Var FosRev       : BYTE     );
  1859.  
  1860. [PARAMETERS]
  1861.  
  1862. ComPort     Communications port.
  1863.  
  1864. [RETURNS]
  1865.  
  1866. Sig         Signature of communications driver installed.
  1867. MaxFunc     Number of functions supported by driver.
  1868. FosRev      Revision of the installed FOSSIL specification.
  1869.  
  1870. [DESCRIPTION]
  1871.  
  1872. Activates a port as VFosActivatePort does.
  1873.  
  1874. [SEE-ALSO]
  1875.  
  1876. VFosActivePort
  1877.  
  1878. [EXAMPLE]
  1879.  
  1880. -*)
  1881.  
  1882. Procedure VX00ActivatePort(            ComPort      : WORD;
  1883.                                    Var Sig          : WORD;
  1884.                                    Var MaxFunc      : BYTE;
  1885.                                    Var FosRev       : BYTE     );
  1886.  
  1887. Var
  1888.  
  1889.   R : REGISTERS;
  1890.  
  1891. BEGIN
  1892.  
  1893.   R.AH := $1C;
  1894.   R.DX := ComPort;
  1895.  
  1896.   R.DS := 0;
  1897.   R.ES := 0;
  1898.  
  1899.   Intr( $14, R );
  1900.  
  1901.   Sig     := R.AX;
  1902.   MaxFunc := R.BL;
  1903.   FosRev  := R.BH;
  1904.  
  1905. END;
  1906.  
  1907. {────────────────────────────────────────────────────────────────────────────}
  1908.  
  1909. (*-
  1910.  
  1911. [FUNCTION]
  1912.  
  1913. Procedure VX00DeActivatePort(          ComPort      : WORD     );
  1914.  
  1915. [PARAMETERS]
  1916.  
  1917. ComPort     Communications port.
  1918.  
  1919. [RETURNS]
  1920.  
  1921. [DESCRIPTION]
  1922.  
  1923. Deactivates a port as VFosDeActivatePort does.
  1924.  
  1925. [SEE-ALSO]
  1926.  
  1927. VFosDeActivatePort
  1928.  
  1929. [EXAMPLE]
  1930.  
  1931. -*)
  1932.  
  1933. Procedure VX00DeActivatePort(          ComPort      : WORD     );
  1934.  
  1935. Var
  1936.  
  1937.   R : REGISTERS;
  1938.  
  1939. BEGIN
  1940.  
  1941.   R.AH := $1D;
  1942.   R.DX := ComPort;
  1943.  
  1944.   R.DS := 0;
  1945.   R.ES := 0;
  1946.  
  1947.   Intr( $14, R );
  1948.  
  1949. END;
  1950.  
  1951. {────────────────────────────────────────────────────────────────────────────}
  1952.  
  1953. (*-
  1954.  
  1955. [FUNCTION]
  1956.  
  1957. Procedure VX00SetExtLineCtrl(          ComPort      : WORD;
  1958.                                        Break        : BOOLEAN;
  1959.                                        ParityB      : BYTE;
  1960.                                        StopBits     : BYTE;
  1961.                                        DataBits     : BYTE;
  1962.                                        BaudRateB    : BYTE;
  1963.                                    Var PortStat     : WORD     );
  1964.  
  1965. [PARAMETERS]
  1966.  
  1967. ComPort     Communications port.
  1968. ParityB     Parity of hardware error checking
  1969. StopBits    Number of stop bits
  1970. DataBits    Number of data bits
  1971. BaudRate    Bits per second rate
  1972.  
  1973. [RETURNS]
  1974.  
  1975. PortStat    Condition of UART (Low Byte=MSR, High Byte=LSR)
  1976.  
  1977. [DESCRIPTION]
  1978.  
  1979. Performs an extended line control initialization using ordinal values for
  1980. parameters as defined:
  1981.  
  1982.   Parity:   0 = None, 1 = Odd, 2 = Even, 3 = Mark (1), 4 = Space (0)
  1983.   Stopbits: 0 = One stop,
  1984.             1 = Two stops for 6,7 and 8 bits; and, 1.5 stops for 5 bits
  1985.   Databits: 0 = 5 bits, 1 = 6 bits, 2 = 7 bits, 3 = 8 bits
  1986.   Baudrate: 0..8 = 110, 150, 300, 600, 1200, 2400, 4800, 9600, 19200.
  1987.  
  1988. [SEE-ALSO]
  1989.  
  1990. [EXAMPLE]
  1991.  
  1992. -*)
  1993.  
  1994. Procedure VX00SetExtLineCtrl(          ComPort      : WORD;
  1995.                                        Break        : BOOLEAN;
  1996.                                        ParityB      : BYTE;
  1997.                                        StopBits     : BYTE;
  1998.                                        DataBits     : BYTE;
  1999.                                        BaudRateB    : BYTE;
  2000.                                    Var PortStat     : WORD     );
  2001.  
  2002. Var
  2003.  
  2004.   R : REGISTERS;
  2005.  
  2006. BEGIN
  2007.  
  2008.   R.AH := $1E;
  2009.   R.AL := Byte(Break);
  2010.   R.BH := ParityB;
  2011.   R.BL := StopBits;
  2012.   R.CH := DataBits;
  2013.   R.CL := BaudRateB;
  2014.   R.DX := ComPort;
  2015.  
  2016.   R.DS := 0;
  2017.   R.ES := 0;
  2018.  
  2019.   Intr( $14, R );
  2020.  
  2021.   PortStat := R.AX;
  2022.  
  2023. END;
  2024.  
  2025. {────────────────────────────────────────────────────────────────────────────}
  2026.  
  2027. (*-
  2028.  
  2029. [FUNCTION]
  2030.  
  2031. Procedure VX00ExtGetMCR(               ComPort      : WORD;
  2032.                                    Var MCRStat      : BYTE;
  2033.                                    Var PortStat     : WORD     );
  2034.  
  2035. [PARAMETERS]
  2036.  
  2037. ComPort     Communications port.
  2038.  
  2039. [RETURNS]
  2040.  
  2041. MCRStat     Condition of MCR.
  2042. PortStat    Condition of UART (Low Byte=MSR, High Byte=LSR).
  2043.  
  2044. [DESCRIPTION]
  2045.  
  2046. Performs an extended serial port MCR (status/control) read operation.
  2047.  
  2048. [SEE-ALSO]
  2049.  
  2050. [EXAMPLE]
  2051.  
  2052. -*)
  2053.  
  2054. Procedure VX00ExtGetMCR(               ComPort      : WORD;
  2055.                                    Var MCRStat      : BYTE;
  2056.                                    Var PortStat     : WORD     );
  2057.  
  2058. Var
  2059.  
  2060.   R : REGISTERS;
  2061.  
  2062. BEGIN
  2063.  
  2064.   R.AH := $1F;
  2065.   R.AL := $00;
  2066.   R.DX := ComPort;
  2067.  
  2068.   R.DS := 0;
  2069.   R.ES := 0;
  2070.  
  2071.   Intr( $14, R );
  2072.  
  2073.   MCRStat := R.BL;
  2074.   PortStat := R.AX;
  2075.  
  2076. END;
  2077.  
  2078. {────────────────────────────────────────────────────────────────────────────}
  2079.  
  2080. (*-
  2081.  
  2082. [FUNCTION]
  2083.  
  2084. Procedure VX00ExtSetMCR(               ComPort      : WORD;
  2085.                                        MCRStat      : BYTE;
  2086.                                    Var PortStat     : WORD     );
  2087.  
  2088. [PARAMETERS]
  2089.  
  2090. ComPort     Communications port.
  2091. MCRStat     Condition of MCR.
  2092.  
  2093. [RETURNS]
  2094.  
  2095. PortStat    Condition of UART (Low Byte=MSR, High Byte=LSR).
  2096.  
  2097. [DESCRIPTION]
  2098.  
  2099. Performs an extended serial port MCR (status/control) write operation.
  2100.  
  2101. [SEE-ALSO]
  2102.  
  2103. [EXAMPLE]
  2104.  
  2105. -*)
  2106.  
  2107. Procedure VX00ExtSetMCR(               ComPort      : WORD;
  2108.                                        MCRStat      : BYTE;
  2109.                                    Var PortStat     : WORD     );
  2110.  
  2111. Var
  2112.  
  2113.   R : REGISTERS;
  2114.  
  2115. BEGIN
  2116.  
  2117.   R.AH := $1F;
  2118.   R.AL := $01;
  2119.   R.BL := MCRStat;
  2120.   R.DX := ComPort;
  2121.  
  2122.   R.DS := 0;
  2123.   R.ES := 0;
  2124.  
  2125.   Intr( $14, R );
  2126.  
  2127.   PortStat := R.AX;
  2128.  
  2129. END;
  2130.  
  2131. {────────────────────────────────────────────────────────────────────────────}
  2132.  
  2133. (*-
  2134.  
  2135. [FUNCTION]
  2136.  
  2137. Procedure VX00RecvCh(                  ComPort      : WORD;
  2138.                                    Var Result       : BOOLEAN;
  2139.                                    Var Ch           : CHAR     );
  2140.  
  2141. [PARAMETERS]
  2142.  
  2143. ComPort     Communications port.
  2144.  
  2145. [RETURNS]
  2146.  
  2147. Result      True if Ch holds a new character.
  2148. Ch          Character to receive.
  2149.  
  2150. [DESCRIPTION]
  2151.  
  2152. Reads a character from the receive buffer with no wait (destructive).  Works
  2153. the same as VFosPeekAhead except the character is removed from the receive
  2154. buffer.
  2155.  
  2156. [SEE-ALSO]
  2157.  
  2158. [EXAMPLE]
  2159.  
  2160. VFosPeekAhead
  2161.  
  2162. -*)
  2163.  
  2164. Procedure VX00RecvCh(                  ComPort      : WORD;
  2165.                                    Var Result       : BOOLEAN;
  2166.                                    Var Ch           : CHAR     );
  2167.  
  2168. Var
  2169.  
  2170.   R : REGISTERS;
  2171.  
  2172. BEGIN
  2173.  
  2174.   R.AH := $20;
  2175.   R.DX := ComPort;
  2176.  
  2177.   R.DS := 0;
  2178.   R.ES := 0;
  2179.  
  2180.   Intr( $14, R );
  2181.  
  2182.   Ch := Char( R.AL );
  2183.   Result := ( R.AH = $00 );
  2184.  
  2185. END;
  2186.  
  2187. {───────────────────────────────────────────────────────────────────────────}
  2188.  
  2189. (*-
  2190.  
  2191. [FUNCTION]
  2192.  
  2193. Procedure VX00StuffInBuff(             Ch           : CHAR     );
  2194.  
  2195. [PARAMETERS]
  2196.  
  2197. Ch          Character to put into the receive buffer.
  2198.  
  2199. [RETURNS]
  2200.  
  2201. [DESCRIPTION]
  2202.  
  2203. Stuffs/Pokes a character into (at the end of) the receive buffer.
  2204.  
  2205. [SEE-ALSO]
  2206.  
  2207. [EXAMPLE]
  2208.  
  2209. -*)
  2210.  
  2211. Procedure VX00StuffInBuff(             Ch           : CHAR     );
  2212.  
  2213. Var
  2214.  
  2215.   R : REGISTERS;
  2216.  
  2217. BEGIN
  2218.  
  2219.   R.AH := $20;
  2220.   R.AL := Byte( Ch );
  2221.  
  2222.   R.DS := 0;
  2223.   R.ES := 0;
  2224.  
  2225.   Intr( $14, R );
  2226.  
  2227. END;
  2228.  
  2229. {════════════════════════════════════════════════════════════════════════════}
  2230. {════════════════════════════════════════════════════════════════════════════}
  2231. {════════════════════════════════════════════════════════════════════════════}
  2232.  
  2233. Procedure FosSerDriverProc( SDP : PSerDriverPacket );
  2234.  
  2235. Var
  2236.  
  2237.   IData : PFosIData;
  2238.  
  2239.   {---------------------}
  2240.   { Temporary variables }
  2241.   {---------------------}
  2242.  
  2243.   teB1,
  2244.   teB2  : BYTE;
  2245.  
  2246.   teW1,
  2247.   teW2  : WORD;
  2248.  
  2249.   tebool : BOOLEAN;
  2250.  
  2251.   {-----------------------------------------------------}
  2252.  
  2253.   Procedure MyGetBuffInfo( BuffType : BYTE );
  2254.  
  2255.   Var
  2256.  
  2257.     fs : TFosStruct;
  2258.  
  2259.   BEGIN
  2260.  
  2261.     If VFosGetFosStruct( IData^.ComPort, fs )=0 Then
  2262.     BEGIN
  2263.  
  2264.       Case BuffType of
  2265.  
  2266.         1 :
  2267.         BEGIN
  2268.  
  2269.           if fs.ifree<>4096 then
  2270.             fs:=fs;
  2271.  
  2272.           SDP^.BuffInfo.Size       := fs.IBufSize;
  2273.           SDP^.BuffInfo.Used       := fs.IBufSize-fs.IFree;
  2274.           SDP^.BuffInfo.Free       := fs.IFree;
  2275.           SDP^.BuffInfo.Changeable := FALSE;
  2276.  
  2277.           SDP^.Error         := 0;
  2278.  
  2279.         END;
  2280.  
  2281.         2 :
  2282.         BEGIN
  2283.  
  2284.           SDP^.BuffInfo.Size       := fs.OBufSize;
  2285.           SDP^.BuffInfo.Used       := fs.OBufSize-Fs.OFree;
  2286.           SDP^.BuffInfo.Free       := fs.OFree;
  2287.           SDP^.BuffInfo.Changeable := FALSE;
  2288.  
  2289.           SDP^.Error         := 0;
  2290.  
  2291.         END;
  2292.  
  2293.       ELSE
  2294.  
  2295.         SDP^.Error := $FFFF0000;
  2296.  
  2297.       END; { Case BuffType / else }
  2298.  
  2299.     END { if vfosgetstruct = 0 }
  2300.     ELSE
  2301.       SDP^.Error := $FFFF0000;
  2302.  
  2303.   END; { MyGetBuffInfo }
  2304.  
  2305.   {-----------------------------------------------------}
  2306.  
  2307.  
  2308. BEGIN  { FosSerDriverProc }
  2309.  
  2310.   IData := SDP^.IData;
  2311.  
  2312.   If SDP^.Error = 0 Then
  2313.   BEGIN
  2314.  
  2315.     Case SDP^.Func of
  2316.  
  2317.       {--------}
  2318.  
  2319.       SDFDriverNew:
  2320.       BEGIN
  2321.  
  2322.         IF @SDP^.SerDriverProc = @FosSerDriverProc Then
  2323.         BEGIN
  2324.  
  2325.           New( IData );
  2326.  
  2327.           FillChar( IData^, SizeOf(TFosIData), 0 );
  2328.  
  2329.           {--------------------------}
  2330.           { build instance data here }
  2331.           {--------------------------}
  2332.  
  2333.           IData^.ComPort := Pred( SDP^.DriverInfo1 );
  2334.  
  2335.           SDP^.IData := IData;
  2336.  
  2337.           SDP^.Error := 0;
  2338.  
  2339.         END;
  2340.  
  2341.       END; { Case SDF_DriverNew }
  2342.  
  2343.       {--------}
  2344.  
  2345.       SDFDriverOff:
  2346.       BEGIN
  2347.       END;
  2348.  
  2349.       {--------}
  2350.  
  2351.       SDFDriverOn:
  2352.       BEGIN
  2353.       END;
  2354.  
  2355.       {--------}
  2356.  
  2357.       SDFDriverDispose:
  2358.       BEGIN
  2359.  
  2360.         {--------------------------------}
  2361.         { Resolve any instance data here }
  2362.         {--------------------------------}
  2363.  
  2364.  
  2365.         {---------------------------}
  2366.         { Dispose all instance data }
  2367.         {---------------------------}
  2368.  
  2369.         If SDP^.IData <> NIL Then
  2370.         BEGIN
  2371.  
  2372.           Dispose( SDP^.IData );
  2373.           SDP^.IData := NIL;
  2374.  
  2375.         END;
  2376.  
  2377.       END;
  2378.  
  2379.       {--------}
  2380.  
  2381.       SDFActivate:
  2382.       BEGIN
  2383.  
  2384.         { clear out error, set comport to proper value }
  2385.  
  2386.         SDP^.Error := 0;
  2387.  
  2388.         { IData^.ComPort := Pred( SDP^.CommParam^.ComPort ); }
  2389.  
  2390.         { try to activate with the X00 enhanced function }
  2391.  
  2392.         VX00ActivatePort( IData^.ComPort, IData^.Sig, teB1, teB2 );
  2393.  
  2394.         { did we successfully init with the X00 function? }
  2395.  
  2396.         IData^.UsingX00 := (IData^.Sig = fosInitSig);
  2397.  
  2398.         { if not using x00, try the normal fossil init }
  2399.  
  2400.         If Not IData^.UsingX00 Then
  2401.         BEGIN
  2402.  
  2403.           VFosActivatePort( IData^.ComPort, IData^.Sig, teB1, teB2 );
  2404.  
  2405.           { if we still couldn't init, we have an error }
  2406.  
  2407.           If IData^.Sig <> fosInitSig Then
  2408.             SDP^.Error := $FFFF0000;
  2409.  
  2410.         END;
  2411.  
  2412.         { if error is still clear, set the comm params }
  2413.  
  2414.         If SDP^.Error = 0 Then
  2415.         BEGIN
  2416.  
  2417.           IData^.BaudRate := SDP^.CommParam^.BaudRate;
  2418.           IData^.Parity   := SDP^.CommParam^.Parity;
  2419.           IData^.DataBits := SDP^.CommParam^.DataBits;
  2420.           IData^.StopBits := SDP^.CommParam^.StopBits;
  2421.  
  2422.           VFosSetCommParam( IData^.ComPort,
  2423.                             IData^.BaudRate,
  2424.                             IData^.Parity,
  2425.                             IData^.DataBits,
  2426.                             IData^.StopBits,
  2427.                             IData^.PortStat );
  2428.  
  2429.         END; { if sdp^.error = 0 }
  2430.  
  2431.       END; { SDFActivate }
  2432.  
  2433.       {--------}
  2434.  
  2435.       SDFDeActivate:
  2436.       BEGIN
  2437.  
  2438.         If IData^.Sig = fosInitSig Then
  2439.         BEGIN
  2440.  
  2441.           { call the appropriate deactivate function }
  2442.  
  2443.           If IData^.UsingX00 Then
  2444.             VX00DeActivatePort( IData^.ComPort )
  2445.           Else
  2446.             VFosDeActivatePort( IData^.ComPort );
  2447.  
  2448.           { clear the signature and return "no error" }
  2449.  
  2450.           IData^.Sig := 0;
  2451.  
  2452.           SDP^.Error := 0;
  2453.  
  2454.         END
  2455.         Else
  2456.  
  2457.           { no valid signature, return an error }
  2458.  
  2459.           SDP^.Error := $FFFF0000;
  2460.  
  2461.       END; { SDFDeActivatePort }
  2462.  
  2463.       {--------}
  2464.  
  2465.       SDFSetCommParam:
  2466.       BEGIN
  2467.  
  2468.         IData^.BaudRate := SDP^.CommParam^.BaudRate;
  2469.         IData^.Parity   := SDP^.CommParam^.Parity;
  2470.         IData^.DataBits := SDP^.CommParam^.DataBits;
  2471.         IData^.StopBits := SDP^.CommParam^.StopBits;
  2472.  
  2473. (*
  2474.         { x00 extended line control is failing.  I think its }
  2475.         { because the port must be activated first.          }
  2476.  
  2477.         If IData^.UsingX00 Then  { !! X00's not functioning properly }
  2478.         BEGIN
  2479.  
  2480.           Case UpCase(IData^.Parity) of
  2481.  
  2482.             'N' : teB1 := 0;
  2483.             'O' : teB1 := 1;
  2484.             'E' : teB1 := 2;
  2485.             'M' : teB1 := 3;
  2486.             'S' : teB1 := 4;
  2487.  
  2488.           End;
  2489.  
  2490.           teB2 := Pred( IData^.StopBits );
  2491.           teW1 := IData^.DataBits - 5;
  2492.  
  2493.           Case IData^.BaudRate of
  2494.  
  2495.             110   : teW2 := 0;
  2496.             150   : teW2 := 1;
  2497.             300   : teW2 := 2;
  2498.             600   : teW2 := 3;
  2499.             1200  : teW2 := 4;
  2500.             2400  : teW2 := 5;
  2501.             4800  : teW2 := 6;
  2502.             9600  : teW2 := 7;
  2503.             19200 : teW2 := 8;
  2504.  
  2505.           End;
  2506.  
  2507.           VX00SetExtLineCtrl( IData^.ComPort,
  2508. {                              SDP^.CommParam^.Break,}
  2509.                               FALSE,
  2510.                               teB1,
  2511.                               teB2,
  2512.                               teW1,
  2513.                               teW2,
  2514.                               IData^.PortStat );
  2515.  
  2516.  
  2517.         END
  2518.         Else
  2519.         BEGIN
  2520.  
  2521. *)
  2522.  
  2523.           VFosSetCommParam( IData^.ComPort,
  2524.                             IData^.BaudRate,
  2525.                             IData^.Parity,
  2526.                             IData^.DataBits,
  2527.                             IData^.StopBits,
  2528.                             IData^.PortStat );
  2529.  
  2530. (*
  2531.         END;
  2532. *)
  2533.  
  2534.         SDP^.Status := IData^.PortStat;
  2535.  
  2536.         SDP^.Error  := 0;
  2537.  
  2538.       END;
  2539.  
  2540.       {--------}
  2541.  
  2542.       SDFGetCommParam:
  2543.       BEGIN
  2544.  
  2545.         SDP^.CommParam^.BaudRate := IData^.BaudRate;
  2546.         SDP^.CommParam^.Parity   := IData^.Parity;
  2547.         SDP^.CommParam^.DataBits := IData^.DataBits;
  2548.         SDP^.CommParam^.StopBits := IData^.StopBits;
  2549.  
  2550.         SDP^.Error := 0;
  2551.  
  2552.       END;
  2553.  
  2554.       {--------}
  2555.       {--------}
  2556.       {--------}
  2557.  
  2558.       SDFGetFlowConType:
  2559.       BEGIN
  2560.  
  2561.         SDP^.Error := $FFFF0000;
  2562.  
  2563.       END;
  2564.  
  2565.       {--------}
  2566.  
  2567.       SDFSetFlowConType:
  2568.       BEGIN
  2569.  
  2570.         VFosSetFlowControl( IData^.ComPort, SDP^.FlowConType );
  2571.  
  2572.         SDP^.Error := 0;
  2573.  
  2574.       END;
  2575.  
  2576.       {--------}
  2577.  
  2578.       SDFTurnSendOnOff:
  2579.       BEGIN
  2580.  
  2581.         If IData^.UsingX00 Then
  2582.         BEGIN
  2583.  
  2584.           VX00ExtGetMCR(  IData^.ComPort,
  2585.                           teB1,
  2586.                           IData^.PortStat  );
  2587.  
  2588.           If IData^.PortStat = cfPortOK Then
  2589.           BEGIN
  2590.  
  2591.             If SDP^.OnOff Then
  2592.               teB1 := ( teB1 AND (NOT MCRrts) )
  2593.             ELSE
  2594.               teB1 := ( teB1 OR MCRrts );
  2595.  
  2596.  
  2597.             VX00ExtSetMCR(  IData^.ComPort,
  2598.                             teB1,
  2599.                             IData^.PortStat  );
  2600.  
  2601.           END;
  2602.  
  2603.           SDP^.Error  := 0;
  2604.           SDP^.Status := IData^.PortStat;
  2605.  
  2606.         END
  2607.         Else
  2608.         BEGIN
  2609.  
  2610.           { cant do this on non x00 fossils }
  2611.  
  2612.           SDP^.Error := $FFFF0000;
  2613.  
  2614.         END;
  2615.  
  2616.       END; { SDFTurnSendOnOff }
  2617.  
  2618.       {--------}
  2619.  
  2620.       SDFTurnReceiveOnOff:
  2621.       BEGIN
  2622.  
  2623.         SDP^.Error := $FFFF0000;
  2624.  
  2625.       END;
  2626.  
  2627.       {--------}
  2628.  
  2629.       sdfGetFlowConChars:
  2630.       BEGIN
  2631.  
  2632.         SDP^.Error := $FFFF0000;
  2633.  
  2634.       END;
  2635.  
  2636.       {--------}
  2637.  
  2638.       sdfSetFlowConChars:
  2639.       BEGIN
  2640.  
  2641.         SDP^.Error := $FFFF0000;
  2642.  
  2643.       END;
  2644.  
  2645.       {--------}
  2646.       {--------}
  2647.       {--------}
  2648.  
  2649.       sdfGetLineControl:
  2650.       BEGIN
  2651.  
  2652.         SDP^.Error := $FFFF0000;
  2653.  
  2654.       END;
  2655.  
  2656.       {--------}
  2657.  
  2658.       sdfGetLineStatus:
  2659.       BEGIN
  2660.  
  2661.         VFosGetPortStat( IData^.ComPort, IData^.PortStat );
  2662.  
  2663.         SDP^.Status := IData^.PortStat;
  2664.         SDP^.Error  := 0;
  2665.  
  2666.       END;
  2667.  
  2668.       {--------}
  2669.  
  2670.       sdfGetModemControl:
  2671.       BEGIN
  2672.  
  2673.         If IData^.UsingX00 Then
  2674.         BEGIN
  2675.  
  2676.           VX00ExtGetMCR(  IData^.ComPort,
  2677.                           teB1,
  2678.                           IData^.PortStat  );
  2679.  
  2680.           SDP^.Error := 0;
  2681.           SDP^.Val   := teb1;
  2682.  
  2683.         END
  2684.         ELSE
  2685.           SDP^.Error := $FFFF0000;
  2686.  
  2687.       END;
  2688.  
  2689.       {--------}
  2690.  
  2691.       sdfGetModemStatus:
  2692.       BEGIN
  2693.  
  2694.         VFosGetPortStat( IData^.ComPort, IData^.PortStat );
  2695.  
  2696.         SDP^.Status := IData^.PortStat;
  2697.         SDP^.Error  := 0;
  2698.  
  2699.       END;
  2700.  
  2701.       {--------}
  2702.  
  2703.       sdfGetBothStatus:
  2704.       BEGIN
  2705.  
  2706.         {---------------------------}
  2707.         { set first 16 LSR/MSR bits }
  2708.         {---------------------------}
  2709. (*
  2710.         IData^.PortStat := SDP^.Status AND $FFFF;
  2711.  
  2712.         VFosGetPortStat( IData^.ComPort, IData^.PortStat );
  2713.  
  2714.         SDP^.Status := (SDP^.Status AND NOT $FFFF) + IData^.PortStat;
  2715. *)
  2716.  
  2717.         VFosGetPortStat( IData^.ComPort, IData^.PortStat );
  2718.  
  2719.         SDP^.Status := IData^.PortStat;
  2720.         SDP^.Error  := 0;
  2721.  
  2722.         {----------------------}
  2723.         { set rest of bitfield }
  2724.         {----------------------}
  2725.  
  2726.       END;
  2727.  
  2728.       {--------}
  2729.       {--------}
  2730.       {--------}
  2731.  
  2732.       SDFDTROnOff:
  2733.       BEGIN
  2734.  
  2735.         VFosSetDTR( IData^.ComPort, SDP^.OnOff );
  2736.  
  2737.         SDP^.Error := 0;
  2738.  
  2739.       END;
  2740.  
  2741.       {--------}
  2742.  
  2743.       SDFBreakOnOff:
  2744.       BEGIN
  2745.  
  2746.         VFosSetBreak( IData^.ComPort, SDP^.OnOff );
  2747.  
  2748.         SDP^.Error := 0;
  2749.  
  2750.       END;
  2751.  
  2752.       {--------}
  2753.  
  2754.       SDFRTSOnOff:
  2755.       BEGIN
  2756.  
  2757.         If IData^.UsingX00 Then
  2758.         BEGIN
  2759.  
  2760.           VX00ExtGetMCR(  IData^.ComPort,
  2761.                           teB1,
  2762.                           IData^.PortStat  );
  2763.  
  2764.           If IData^.PortStat = cfPortOK Then
  2765.           BEGIN
  2766.  
  2767.             If SDP^.OnOff Then
  2768.               teB1 := ( teB1 AND (NOT MCRrts) )
  2769.             ELSE
  2770.               teB1 := ( teB1 OR MCRrts );
  2771.  
  2772.  
  2773.             VX00ExtSetMCR(  IData^.ComPort,
  2774.                             teB1,
  2775.                             IData^.PortStat  );
  2776.  
  2777.           END;
  2778.  
  2779.           SDP^.Error  := 0;
  2780.           SDP^.Status := IData^.PortStat;
  2781.  
  2782.         END
  2783.         Else
  2784.         BEGIN
  2785.  
  2786.           { cant do this on non x00 fossils }
  2787.  
  2788.           SDP^.Error := $FFFF0000;
  2789.  
  2790.         END;
  2791.  
  2792.       END;
  2793.  
  2794.       {--------}
  2795.       {--------}
  2796.       {--------}
  2797.  
  2798.  
  2799.       SDFFlushOutBuff:
  2800.       BEGIN
  2801.  
  2802.         VFosFlushOutBuff( IData^.ComPort );
  2803.  
  2804.         SDP^.Error := 0;
  2805.  
  2806.       END;
  2807.  
  2808.       {--------}
  2809.  
  2810.       SDFPurgeOutBuff:
  2811.       BEGIN
  2812.  
  2813.         VFosPurgeOutBuff( IData^.ComPort );
  2814.  
  2815.         SDP^.Error := 0;
  2816.  
  2817.       END;
  2818.  
  2819.       {--------}
  2820.  
  2821.       SDFPurgeInBuff:
  2822.       BEGIN
  2823.  
  2824.         VFosPurgeInBuff( IData^.ComPort );
  2825.  
  2826.         SDP^.Error := 0;
  2827.  
  2828.       END;
  2829.  
  2830.       {--------}
  2831.  
  2832.       sdfGetOutBuffInfo:
  2833.       BEGIN
  2834.  
  2835.         MyGetBuffInfo( 2 );
  2836.  
  2837.       END;
  2838.  
  2839.       {--------}
  2840.  
  2841.       sdfSetOutBuffInfo:
  2842.       BEGIN
  2843.  
  2844.         SDP^.Error := $FFFF0000;
  2845.  
  2846.       END;
  2847.  
  2848.       {--------}
  2849.  
  2850.       sdfGetInBuffInfo:
  2851.       BEGIN
  2852.  
  2853.         MyGetBuffInfo( 1 );
  2854.  
  2855.       END;
  2856.  
  2857.       {--------}
  2858.  
  2859.       sdfSetInBuffInfo:
  2860.       BEGIN
  2861.  
  2862.         SDP^.Error := $FFFF0000;
  2863.  
  2864.       END;
  2865.  
  2866.       {--------}
  2867.       {--------}
  2868.       {--------}
  2869.  
  2870.  
  2871.       SDFEventProcNew:
  2872.       BEGIN
  2873.  
  2874.         SDP^.Error := $FFFF0000;
  2875.  
  2876.       END;
  2877.  
  2878.       {--------}
  2879.  
  2880.       SDFEventProcOff:
  2881.       BEGIN
  2882.  
  2883.         SDP^.Error := $FFFF0000;
  2884.  
  2885.       END;
  2886.  
  2887.       {--------}
  2888.  
  2889.       SDFEventProcOn:
  2890.       BEGIN
  2891.  
  2892.         SDP^.Error := $FFFF0000;
  2893.  
  2894.       END;
  2895.  
  2896.       {--------}
  2897.  
  2898.       SDFEventProcDispose:
  2899.       BEGIN
  2900.  
  2901.         SDP^.Error := $FFFF0000;
  2902.  
  2903.       END;
  2904.  
  2905.       {--------}
  2906.  
  2907.       sdfEventProcMaskSet:
  2908.       BEGIN
  2909.  
  2910.         SDP^.Error := $FFFF0000;
  2911.  
  2912.       END;
  2913.  
  2914.       {--------}
  2915.       {--------}
  2916.       {--------}
  2917.  
  2918.       SDFWriteCh:
  2919.       BEGIN
  2920.  
  2921.         SDP^.Error := 0;
  2922.  
  2923.         VFosSendChar( IData^.ComPort, SDP^.Ch, Boolean(teB1) );
  2924.  
  2925.         If teB1 <> 0 Then
  2926.           SDP^.Error := $FFFF;
  2927.  
  2928.       END;
  2929.  
  2930.       {--------}
  2931.  
  2932.       SDFWriteBlock:
  2933.       BEGIN
  2934.  
  2935.         VFosSendBlock( IData^.ComPort,
  2936.                        SDP^.Buf,
  2937.                        SDP^.Count,
  2938.                        SDP^.Result );
  2939.  
  2940.         SDP^.Error := 0;
  2941.  
  2942.       END;
  2943.  
  2944.       {--------}
  2945.  
  2946.       SDFReadCh:
  2947.       BEGIN
  2948.  
  2949.         SDP^.Error := 0;
  2950.  
  2951.         IData^.UsingX00 := FALSE;
  2952.  
  2953.         If IData^.UsingX00 Then
  2954.         BEGIN
  2955.  
  2956.           VX00RecvCh( IData^.ComPort, Boolean(teB1), SDP^.Ch );
  2957.  
  2958.           If teB1 = 0 Then
  2959.             SDP^.Error := $FFFF;
  2960.  
  2961.         END
  2962.         Else
  2963.           VFosRecvCharW( IData^.ComPort, SDP^.Ch, IData^.PortStat );
  2964.  
  2965.       END;
  2966.  
  2967.       {--------}
  2968.  
  2969.       SDFReadBlock:
  2970.       BEGIN
  2971.  
  2972.         VFosRecvBlock( IData^.ComPort,
  2973.                        SDP^.Buf,
  2974.                        SDP^.Count,
  2975.                        SDP^.Result );
  2976.  
  2977.         SDP^.Error := 0;
  2978.  
  2979.       END;
  2980.  
  2981.       {--------}
  2982.  
  2983.       sdfPeekCh:
  2984.       BEGIN
  2985.  
  2986.         VFosPeekAhead( Idata^.ComPort,
  2987.                        tebool,
  2988.                        SDP^.Ch          );
  2989.  
  2990.         IF Tebool Then
  2991.           SDP^.Error := $FFFF
  2992.         Else
  2993.           SDP^.Error := 0;
  2994.  
  2995.       END;
  2996.  
  2997.       {--------}
  2998.  
  2999.     End;
  3000.  
  3001.   END;
  3002.  
  3003. END;
  3004.  
  3005. {════════════════════════════════════════════════════════════════════════════}
  3006. {────────────────────────────────────────────────────────────────────────────}
  3007. {────────────────────────────────────────────────────────────────────────────}
  3008.  
  3009. BEGIN
  3010. END.
  3011.