home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / PASCAL / LTCOMM50.ZIP / LCTP.PRN < prev    next >
Encoding:
Text File  |  1989-05-15  |  138.9 KB  |  3,895 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.                                      Chapter 1                                     Chapter 1
  14.  
  15.                                       OVERVIEW                                      OVERVIEW
  16.  
  17.  
  18.        1.1  FEATURES       1.1  FEATURES
  19.  
  20.  
  21.        The LiteComm-TP Toolbox(Tm) is a set of powerful routines designed to
  22.        provide easy access to the full capabilities of the PC's asynchronous
  23.        communications ports. The LiteComm-TP ToolBox supports fully
  24.        interrupt-driven and buffered communications support on COM1 through
  25.        COM4 simultaneously. Now you can quickly incorporate sophisticated
  26.        communications support in your applications without having in-depth
  27.        knowledge of how the hardware functions.
  28.  
  29.        LiteComm-TP is implemented as a set of 4 units for the basic product,
  30.        with additional units providing the protocol-engine capability.  The
  31.        protocol engines are a part of the registered version of the package.
  32.  
  33.        The LiteComm ToolBox was originally developed in the C language for
  34.        use in CAD/CAM applications that required the ability to have PC
  35.        compatible systems communicating with a variety of devices.
  36.        LiteComm-TP extends the same capabilities to the PASCAL programmer.
  37.  
  38.  
  39.        1.2  THE SHAREWARE CONCEPT       1.2  THE SHAREWARE CONCEPT
  40.  
  41.  
  42.        Shareware is a "try before you buy" means of software distribution. If
  43.        you find a shareware product useful, pay the registration fee, and let
  44.        the authors know that you support their efforts.
  45.  
  46.        Information Technology is a member of the Association of Shareware
  47.        Professionals (ASP).  ASP wants to make sure that the shareware
  48.        principle works for you.  If you are unable to resolve a shareware-
  49.        related problem with an ASP member by contacting the member directly,
  50.        ASP may be able to help.  The ASP Ombudsman can help you resolve a
  51.        dispute or problem with an ASP member, but does not provide technical
  52.        support for members' products.  Please write to the ASP Ombudsman at
  53.        P.O.  Box 5786, Bellevue, WA 98006 or send a Compuserve message via
  54.        easyplex to ASP Ombudsman 70007,3536.
  55.  
  56.  
  57.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.                                     Page 2
  119.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  120.  
  121.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.                                      Chapter 2                                     Chapter 2
  132.  
  133.                          LICENSE, WARRANTY AND REGISTRATION                         LICENSE, WARRANTY AND REGISTRATION
  134.  
  135.  
  136.        2.1  LICENSE       2.1  LICENSE
  137.  
  138.  
  139.        The LiteComm-TP ToolBox, is distributed as a shareware product. We
  140.        urge you to register your copy today. See the registration form at the
  141.        end of this manual.
  142.  
  143.        Information Technology, Ltd, grants to registered users a
  144.        nonexclusive, perpetual license to the LiteComm-TP ToolBox, subject to
  145.        these terms and conditions:
  146.  
  147.           1.  You must treat your copy of the LiteComm-TP Toolbox as you
  148.               would a book.  You may install the LiteComm-TP ToolBox on more
  149.               than one machine, but you may use only one copy at a time.  If
  150.               you desire, site licenses are available at a reduced cost.  You
  151.               may make as many copies of the LiteComm-TP ToolBox as you
  152.               require for the sole purpose of backup.
  153.  
  154.           2.  You may incorporate portions of the LiteComm-TP ToolBox into
  155.               products that you develop without the payment of additional
  156.               royalties or license fees.  You must include the statement
  157.               'Portions Copyright 1987, 1988, Information Technology, Ltd' in
  158.               your product's documentation.
  159.  
  160.           3.  You may copy and redistribute the shareware portion of the
  161.               LiteComm-TP ToolBox, commonly known as LCOMMTP.ARC, but you may
  162.               not modify in any way, the contents of the shareware package.
  163.  
  164.           4.  Information Technology grants to ASP-approved vendors only the
  165.               right to charge a duplication fee, not to exceed $8.00 for
  166.               providing a copy of the shareware version of the product.  No
  167.               other individual or vendor is permitted to charge a fee for
  168.               providing such a copy without the express, written consent of
  169.               Information Technology, Ltd,
  170.  
  171.           5.  You may not redistribute, in any form, the source code for the
  172.               LiteComm-TP ToolBox.  Further, you may not translate the source
  173.               code for the LiteComm-TP ToolBox into any other language
  174.               without the express, written consent of Information Technology,
  175.               Ltd.
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.                                     Page 3
  183.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  184.  
  185.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  186.  
  187.  
  188.  
  189.           6.  Information Technology reserves the right to change both the
  190.               LiteComm-TP ToolBox or its documentation without prior notice,
  191.               with no obligation to you, the licensee.
  192.  
  193.           7.  You agree that any disputes arising from this license will be
  194.               subject to the laws of the state of Rhode Island.
  195.  
  196.           8.  You agree to hold the developer and distributors of the
  197.               LiteComm-TP ToolBox harmless for any damages, either direct or
  198.               consequential, that might arise from the use of this product.
  199.  
  200.           9.  You acknowledge that the LiteComm-TP ToolBox, libraries, source
  201.               code, and documentation are the copyrighted property of
  202.               Information Technology, Ltd.
  203.  
  204.          10.  By your use of the LiteComm-TP ToolBox, you acknowledge that
  205.               you have read, and understand the terms and conditions of this
  206.               license.
  207.  
  208.  
  209.        2.2  WARRANTY       2.2  WARRANTY
  210.  
  211.  
  212.        The LiteComm-TP ToolBox is distributed as-is and without warranty,
  213.        including, but not limited to, the implied warranties of
  214.        merchantability and fitness for a particular purpose.
  215.  
  216.        Information Technology, Ltd does warrant the distribution media for a
  217.        period of 30 days.  During that period, Information Technology, Ltd
  218.        will replace the distribution media or provide a refund at its option.
  219.  
  220.  
  221.        2.3  REGISTERING YOUR COPY       2.3  REGISTERING YOUR COPY
  222.  
  223.  
  224.        Registration of your copy of the LiteComm-TP ToolBox provides you with
  225.        several benefits:
  226.  
  227.           1.  Puts you on our mailing list for low-cost updates,
  228.               enhancements, and alert bulletins when they occur.
  229.  
  230.           2.  Gives you access to telephone support. Sorry, but we cannot
  231.               provide support by telephone to unregistered user's of the
  232.               ToolBox. Unregistered users can leave EMAIL on Compuserve to
  233.               70166,1152 and on GEnie to I.TECH. We will respond to EMAIL on
  234.               an as-available basis.
  235.  
  236.           3.  Helps to further the shareware concept.
  237.  
  238.        You can order directly from us or from the Public (Software) Library
  239.        1-800-2424-PSL (for orders only. For information call 1-713-665-7017)
  240.        or by writing PSL; P.O.Box 35705; Houston, TX 77235-5705.  MC/Visa
  241.        Accepted.
  242.  
  243.  
  244.  
  245.  
  246.                                     Page 4
  247.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  248.  
  249.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  250.  
  251.  
  252.  
  253.        If you want to order directly from us, print the file REG.FRM and
  254.        follow the instructions there.
  255.  
  256.  
  257.        2.4  NOTE       2.4  NOTE
  258.  
  259.  
  260.        LiteComm-TP is a package undergoing continuing development.
  261.        Registered users of the product receive, in addition to the fully-
  262.        functional base package, units that provide protocol engines
  263.        supporting XModem, XModem-1K, and YModem protocols.
  264.  
  265.        We plan to follow these with similar engines for CompuServe B, Telink,
  266.        and other protocols. These engines, as they are released, will only be
  267.        made available to registered ToolBox users. The shareware version, as
  268.        enhanced but without the protocol engines, will continue to be
  269.        offered.
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.                                     Page 5
  311.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  312.  
  313.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.                                     Page 6
  375.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  376.  
  377.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.                                      Chapter 3                                     Chapter 3
  388.  
  389.                               Serial Port Fundamentals                              Serial Port Fundamentals
  390.  
  391.  
  392.        3.1  The 8250 UART family       3.1  The 8250 UART family
  393.  
  394.  
  395.           This portion of the manual provides you with some details about the
  396.           working of the 8250 (and related) UART'S, the basic component of
  397.           your system's serial port.  Some close compatibles use enhanced
  398.           versions of this chip, such as the Intel 16450.  LiteComm is known
  399.           to work successfully with such devices.  If you have questions
  400.           about the kind of serial port you are using, refer to the
  401.           manufacturer's documentation.  If your serial port does not use an
  402.           8250 or similar chip, LiteComm will not function.
  403.  
  404.  
  405.        3.2  Purpose of the port       3.2  Purpose of the port
  406.  
  407.  
  408.           The purpose of the serial port is to convert information from the
  409.           form in which it is used within your system, to a form that can be
  410.           easily used outside your system.  Modern computers, by design, are
  411.           parallel in nature.  By this we mean that information travels
  412.           through the computer's circuitry as whole units or as multiples of
  413.           whole units. In the IBM PC and related systems, information travels
  414.           as bytes (8 bits at a time), as words (16 bits at a time), or, on
  415.           80386 based systems, as double words (32 bits at a time).
  416.  
  417.           Within the computer, such arrangements are convenient and fast. But
  418.           when the computer must transfer information to an external device,
  419.           the problem of data path width is introduced.  To provide a true,
  420.           parallel path between the computer and external devices, there
  421.           would have to be, at a minimum, enough data lines or circuits
  422.           between the two to satisfy the data path.  For most modern computer
  423.           systems, this would mean a minimum of 8 data lines, not counting
  424.           any additional control information that might also be required.
  425.           For certain newer systems, the requirement might be for as many as
  426.           32 data lines.  In effect, it might be necessary to have several
  427.           different versions of a device, dependent upon the data path width
  428.           of the computer to which it is connected.
  429.  
  430.           The purpose of a serial port is to convert the information from its
  431.           internal, parallel form, to a more common, external form and back
  432.           again.  By using such an approach, we simplify the interconnection
  433.           of devices, reducing information to its lowest common denominator,
  434.           the bit. And it allows us to transfer information 1 bit at a time,
  435.  
  436.  
  437.  
  438.                                     Page 7
  439.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  440.  
  441.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  442.  
  443.  
  444.  
  445.           using a single data path, between devices. The real beauty of this
  446.           approach is that, by 'agreeing' on how this external form appears,
  447.           each device can hide the details of how it works, and still
  448.           accomplish the required task.
  449.  
  450.  
  451.        3.3  Internal Details       3.3  Internal Details
  452.  
  453.  
  454.           In this section we discuss the fundamental working of serial ports
  455.           as they are implemented of the IBM PC and close compatible systems.
  456.           It is not essential that you understand this material thoroughly to
  457.           be successful with LiteComm. However, it may help to answer some of
  458.           the more important questions that may arise as you proceed with
  459.           your development.
  460.  
  461.        3.3.1  The Interrupt Connection       3.3.1  The Interrupt Connection
  462.  
  463.           The PC is an interrupt driven system. This is a sophisticated way
  464.           of saying that the PC can 'pay attention' to a number of internal
  465.           devices without the necessity of having to check on them
  466.           periodically.
  467.  
  468.           When we describe interrupts to clients, we use the school room as a
  469.           metaphor. Think of a teacher lecturing to a group of students
  470.           during a class.  The teacher knows that, on occasion, one or more
  471.           students may not understand the material that is being presented.
  472.           So the teacher has the choice of either asking each student
  473.           periodically if they understand or permitting the students to raise
  474.           a hand to ask a question.  As you can imagine, stopping the class
  475.           to 'poll' each student will waste valuable time, particularly if no
  476.           one wants to ask a question. Not only is it wasteful of time, but
  477.           the last student polled may have forgotten the question he or she
  478.           wanted to ask by the time the teacher gets to him.  If the teacher
  479.           permits students to 'interrupt' his lecture by raising a hand, much
  480.           less time is wasted, but the teacher has to be careful to identify
  481.           each raised hand by name and answer the question quickly and
  482.           accurately, lest some student forget his question or looses
  483.           interest altogether.
  484.  
  485.           The internal working of most modern computers is identical to the
  486.           teacher that permits hand raising.  The computer focuses on the
  487.           task at hand, stopping only to identify and pay attention to
  488.           devices when they signal that they require this attention.  So much
  489.           for the hardware end of things.  The PC has this same capability.
  490.           But at least some of the work that has to be done requires software
  491.           in a general purpose computer, otherwise the computer wouldn't be
  492.           general purpose.
  493.  
  494.           The serial port on the PC is no less capable of asking for
  495.           attention from the computer, at least from the standpoint of
  496.           hardware.  But, for whatever the reason, MS-DOS and PC-DOS do not
  497.           provide the needed software to exploit the full capabilities of the
  498.           serial port. OS/2 does provide such support, we are told, but, at
  499.  
  500.  
  501.  
  502.                                     Page 8
  503.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  504.  
  505.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  506.  
  507.  
  508.  
  509.           least for the foreseeable future, its an MS-DOS world. On PC's and
  510.           true compatibles, the only support for the serial port that is
  511.           provided is through the system's ROM BIOS.  And that support is
  512.           only for the polled mode of operation.
  513.  
  514.           The method by which 80x86 family systems, of which the PC is a
  515.           part, is elegant in its simplicity.  When a device needs the
  516.           attention of the system, its asserts a control signal and
  517.           identifies itself with a number ranging from 0 to 255. On the basic
  518.           PC, the numbers used actually range from 8 through 15 decimal.  The
  519.           identification is translated to a memory location by multiplying
  520.           the identification by 4, and the system simulates a special form of
  521.           a call to the routine whose address is stored at that location.
  522.           Since it is impossible to predict when a device will require
  523.           attention, the full address of the routine is stored, both segment
  524.           and offset, hence the 4.
  525.  
  526.           Once the routine, called the Interrupt Service Routine or ISR is
  527.           invoked, it has a duty to save the state of the system when the
  528.           interrupt occurred, take care of the interrupt as quickly as
  529.           possible, and return control to the interrupted process.  But it
  530.           must also be aware that, while it is doing its work, other, more
  531.           important devices may require attention, too.
  532.  
  533.           One such device that is likely to require attention is the system
  534.           clock which ticks roughly 18 times per second.  In part, the PC
  535.           makes provision for this by prioritizing the interrupt scheme.  The
  536.           ISR must allow for this by re- enabling the interrupt control
  537.           system as rapidly as it is practical to do so.  The PC's interrupt
  538.           structure, if left undisturbed, will prevent interrupts of the same
  539.           or lower priority from occurring. To help your organize your
  540.           thoughts, the standard identification for the first two serial
  541.           ports on the system are 12 (0C) and 11 (0B) for ports 1 and 2
  542.           respectively.
  543.  
  544.           As you can see, dealing with the PC's interrupt structure is not
  545.           for the faint of heart.  It requires a significant amount of
  546.           knowledge, and close attention to detail.  With LiteComm, these
  547.           details have already been taken care of for you.  You are free to
  548.           focus on your application, treating the serial port in much the
  549.           same way that you would any DOS file.
  550.  
  551.        3.3.2  The Programmable Port Registers       3.3.2  The Programmable Port Registers
  552.  
  553.           The 8250 port, and its close relatives, are fully programmable.
  554.           You are fortunate that LiteComm has already taken care of the
  555.           intricacies of this programming. But some additional information
  556.           about each of the registers used in the serial port may be of use
  557.           when you are attempting to communicate with an external device. For
  558.           the sake of this discussion, we use the basic register numbers,
  559.           although the register number that is employed in programming is
  560.           actually the register number referenced below used as an offset to
  561.           a base port number. In the case of COM1 (port 1), this base is
  562.           3F8(hexadecimal).
  563.  
  564.  
  565.  
  566.                                     Page 9
  567.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  568.  
  569.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  570.  
  571.  
  572.  
  573.           3.3.2.1  register 0 - transmit/receive          3.3.2.1  register 0 - transmit/receive
  574.  
  575.           In normal operation, individual characters are read from register 0
  576.           when the become available, and are written to register 0 when the
  577.           transmitter portion of the 8250 is ready to accept a character.
  578.  
  579.           3.3.2.2  register 0 - baud rate selection          3.3.2.2  register 0 - baud rate selection
  580.  
  581.           During initialization, register 0 is used as part of the mechanism
  582.           that sets baud rate.  During this process, register 0 and its
  583.           companion register 1 are used to specify the baud rate divisor (not
  584.           the actual baud rate). The baud rate divisor is a value which, when
  585.           divided into a given, preset constant, yields the desired baud
  586.           rate.  To use registers 0 and 1 to set the baud rate, access to
  587.           this mode must be first enabled by writing a value of 80H to
  588.           register 3, the line control register.  Once access is enabled, the
  589.           least significant byte (LSB) of the divisor is written to register
  590.           0; the most significant byte is written to register 1.  Access to
  591.           the normal modes of registers 0 and 1 are re- enabled by writing
  592.           any value less than 80H to the line control register.  Of course,
  593.           only certain values less than 80H would be meaningful (see the line
  594.           control register description below).
  595.  
  596.           3.3.2.3  register 1 - interrupt enable          3.3.2.3  register 1 - interrupt enable
  597.  
  598.           Values written to register 1 control which conditions will cause
  599.           the 8250 to interrupt the system. There are four possible
  600.           conditions that can cause interrupts:
  601.  
  602.              1.  A character has been received (RDI)
  603.  
  604.              2.  The transmitter is ready to send a character (TDI)
  605.  
  606.              3.  An error or BREAK signal has been detected (ERI)
  607.  
  608.              4.  A modem status  signal has changed (MSI)
  609.  
  610.           The designations, in parentheses, are for our purposes only. They
  611.           are not 'standard' designations. To enable a particular type of
  612.           interrupt, you must set the corresponding bit in a byte to a 1,
  613.           then write the byte to register 1.  To reset (ignore) the
  614.           condition, set the corresponding bit to 0.  The diagram that
  615.           follows shows the bit positions the correspond to the various
  616.           conditions described above.
  617.  
  618.           +------+------+------+------+------+------+------+------+
  619.           |      |      |      |      |      |      |      |      |
  620.           |  N/A |  N/A |  N/A |  N/A |Modem |Error/| Xmit | Recv |
  621.           |      |      |      |      |Status|Break |Ready | Char |
  622.           +------+------+------+------+------+------+------+------+
  623.               7     6      5      4       3      2      1      0
  624.                         Figure 3.1: Register 1 Bit Definitions                        Figure 3.1
  625.  
  626.  
  627.  
  628.  
  629.  
  630.                                     Page 10
  631.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  632.  
  633.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  634.  
  635.  
  636.  
  637.           3.3.2.4  register 1 - baud rate selection          3.3.2.4  register 1 - baud rate selection
  638.  
  639.           See the description under register 0, baud rate selection.
  640.  
  641.           3.3.2.5  register 2 - interrupt identification          3.3.2.5  register 2 - interrupt identification
  642.  
  643.           Register 2, in normal operation, acts as a companion to register 1.
  644.           Register 1 determines the conditions that can cause an interrupt.
  645.           Register 2 is used to determine which condition actually caused the
  646.           interrupt, when more than one condition has been enabled.  Only
  647.           least significant 3 bits of the register are actually employed.
  648.           See the diagram of register 2 below.
  649.  
  650.           +------+------+------+------+------+------+------+------+
  651.           |      |      |      |      |      |      |      |      |
  652.           |  N/A |  N/A |  N/A |  N/A |  N/A |  see |below |  Int |
  653.           |      |      |      |      |      |      |      | pend |
  654.           +------+------+------+------+------+------+------+------+
  655.               7      6      5      4      3      2      1      0
  656.                         Figure 3.2: Register 2 Bit Definitions                        Figure 3.2
  657.  
  658.           Since it is possible, even likely, that more than one condition may
  659.           occur at the same time, bit 0 is used to determine whether all
  660.           conditions that currently exist have been handled.  When bit 0 has
  661.           a value of 0 (yes zero), there are conditions waiting to be
  662.           handled.  When bit 0 has a value of 1, all outstanding conditions
  663.           have been handled.  Bits 2 and 1 taken together identify the actual
  664.           cause of the interrupt.
  665.  
  666.           Again, because of the multiple conditions which may occur, the 8250
  667.           presents the conditions in a prioritized order.  When bits 2 and 1
  668.           have a value of 3 (the most important), an ERI condition has been
  669.           identified. The actual error is determined by reading the line
  670.           status register(register 5). Reading this register also clears the
  671.           condition.
  672.  
  673.           When a value of 2 is present, an RDI condition has occurred, and a
  674.           character should be read. from port 0. If the character is not read
  675.           quickly enough, a data overrun error may occur, indicating that a
  676.           character was lost.
  677.  
  678.           When bits 2 and 1 have a value of 1, a TDI condition has occurred
  679.           and a character may be written to register 0.
  680.  
  681.           A value of zero in bits 2 and 1(least important) indicates that one
  682.           or more of the modem status lines (so called) have changed. The
  683.           condition is cleared by reading the contents of the modem status
  684.           register, register 6.
  685.  
  686.           3.3.2.6  register 3 - line control          3.3.2.6  register 3 - line control
  687.  
  688.           The line control register provides the means for setting those
  689.           values that affect the way in which the serial port appears to the
  690.           outside world.  It is through this register that character length,
  691.  
  692.  
  693.  
  694.                                     Page 11
  695.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  696.  
  697.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  698.  
  699.  
  700.  
  701.           parity, and other significant values are established. Indirectly,
  702.           register 3 also plays a role in setting the speed (baud rate) of
  703.           the port. (See the description of registers 0 and 1 above.)
  704.  
  705.           +------+------+------+------+------+------+------+------+
  706.           | Baud |      |      |      |      |      |      |      |
  707.           |  Div | Send |Force |Parity|Enable| Stop |  Character  |
  708.           |Enable|Break |Parity| Type |Parity| Bits |    Length   |
  709.           +------+------+------+------+------+------+------+------+
  710.               7     6      5      4       3      2      1      0
  711.                         Figure 3.3: Register 3 Bit Definitions                        Figure 3.3
  712.  
  713.           3.3.2.7  register 4 - modem control          3.3.2.7  register 4 - modem control
  714.  
  715.           The modem control register permits control of the two modem-
  716.           related signals that the serial port generates as an output.  The
  717.           signals are RTS and DTR.
  718.  
  719.           These two signals are called 'handshaking' signals, since they, in
  720.           part, help a connected device determine the state of the
  721.           connection.  You should be aware that although these signals were
  722.           originally designated to be used in a specific fashion,
  723.           manufacturers of specific devices have used them to meet their own
  724.           needs. Your success or failure in dealing with any specific device
  725.           may depend, in part, on your understanding of how the device's
  726.           manufacturer uses these signals. LiteComm provides you the means
  727.           for manipulating these signals in a variety of ways.
  728.  
  729.           You will notice in the register 4 diagram, below that some
  730.           additional positions are identified.
  731.  
  732.           +------+------+------+------+------+------+------+------+
  733.           |      |      |      |      |      |      |      |      |
  734.           |  N/A |  N/A |  N/A |Enable| OUT2 |  N/A |Enable|Enable|
  735.           |      |      |      |Loopbk|(reqd)|      | RTS  | DTR  |
  736.           +------+------+------+------+------+------+------+------+
  737.               7     6       5     4      3       2      1      0
  738.                         Figure 3.4: Register 4 Bit Definitions                        Figure 3.4
  739.  
  740.           LiteComm controls all of these additional positions for your
  741.           benefit.  Only one deserves mention, the position labeled OUT2.  It
  742.           is necessary for this position to have a value of 1 for the serial
  743.           port to function as an interrupting device. Since LiteComm relies
  744.           on interrupts to perform it's job, it insures that this position is
  745.           always set correctly.
  746.  
  747.           3.3.2.8  register 5 - line status          3.3.2.8  register 5 - line status
  748.  
  749.           The line status register is read normally when an ERI condition
  750.           occurs.  Each bit of the character returned when the port is read
  751.           has significance, as shown in the accompanying diagram. Using the
  752.           appropriate functions in LiteComm, you can interrogate the value in
  753.           this register, and test for the various conditions using the
  754.           LiteComm- provided definitions. Note that, due to the special
  755.  
  756.  
  757.  
  758.                                     Page 12
  759.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  760.  
  761.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  762.  
  763.  
  764.  
  765.           nature of the BREAK signal, LiteComm treats this one condition as a
  766.           separate entity.
  767.  
  768.           +------+------+------+------+------+------+------+------+
  769.           |      |Shift | Hold |      |      |      |      |      |
  770.           | Time |Reg   | Reg  | Recd |Frame |Parity| Data | Char |
  771.           | Out  |Empty |Empty |Break |Error |Error |OvrRun| Recd |
  772.           +------+------+------+------+------+------+------+------+
  773.               7     6      5      4      3       2      1      0
  774.                         Figure 3.5: Register 5 Bit Definitions                        Figure 3.5
  775.  
  776.           3.3.2.9  register 6 - modem status          3.3.2.9  register 6 - modem status
  777.  
  778.           Just as the serial port can generate certain 'handshaking' signals,
  779.           it can also read, and report on the status of similar signals that
  780.           are generated by an external device.  In their original form, these
  781.           signals had special significance when a terminal was connected to a
  782.           modem. We refer you to our comments, above, about present day use
  783.           of the handshaking signals.
  784.  
  785.           One special note is appropriate here.  The modem status register
  786.           actually provides two types of information.  The most significant 4
  787.           bits (see the diagram) show the current state of the 4 covered
  788.           signals.  The least significant 4 bits indicate which, if any, of
  789.           the signals have changed state (from zero to one, or vice-versa),
  790.           since the last time the register was interrogated.  LiteComm
  791.           updates its internal tables with this value in real-time, and
  792.           reports the results when asked to do so.  You can test the signals
  793.           individually or in combination using the LiteComm-provided
  794.           definitions.
  795.  
  796.           +------+------+------+------+------+------+------+------+
  797.           |  DCD |  RI  |  DSR |  CTS |      |      |      |      |
  798.           | carr | ring |data  |clr to|DELTA |DELTA |DELTA |DELTA |
  799.           |detect|indic |set rd| send | DCD  |  RI  | DSR  | CTS  |
  800.           +------+------+------+------+------+------+------+------+
  801.               7      6      5      4     3       2      1      0
  802.  
  803.  
  804.        3.4  The LiteComm Connection       3.4  The LiteComm Connection
  805.  
  806.  
  807.                         Figure 3.6: Register 6 Bit Definitions                        Figure 3.6
  808.  
  809.           In the design of LiteComm, we have purposely 'hidden' many of the
  810.           underlying details we presented above. In many cases, you will have
  811.           little use for this additional information. This is particularly
  812.           true of most of the applications with which come into contact.  In
  813.           fact, in the majority of applications, you will probably open the
  814.           port or ports, set the necessary parameters and modem control
  815.           signals, and do nothing more than read and write characters using
  816.           one or more of the LiteComm functions.  The beauty of LiteComm's
  817.           design is that its high degree of granularity doesn't force you to
  818.           pay the price of dragging along functions that you are not using.
  819.  
  820.  
  821.  
  822.                                     Page 13
  823.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  824.  
  825.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  826.  
  827.  
  828.  
  829.           The information that we presented above will help you when  it is
  830.           necessary to communicate with a device that requires special
  831.           handshaking considerations, such as a cash drawer.  You may also
  832.           need some of the information we presented if you intend to use
  833.           serial ports beyond COM2 (serial port 2).
  834.  
  835.           Finally, by presenting the information that we have supplied, we
  836.           hope to gain a more informed user.  Communications programming is
  837.           not the black art that some would have you believe, although it can
  838.           easily seem that way at times.  Of all of the calls we receive who
  839.           need  questions answered, more than 75 per cent could have been
  840.           answered by the caller himself with a more thorough understanding
  841.           of the underlying concepts and rules.
  842.  
  843.  
  844.        3.5  TOOLBOX NOTES AND WARNINGS       3.5  TOOLBOX NOTES AND WARNINGS
  845.  
  846.  
  847.           Before you can send or receive information on a serial port using
  848.           the ToolBox, you must use the open function to enable the line.
  849.           This function initializes the 8250 UART with the correct
  850.           parameters, and introduces the UART into the interrupt structure of
  851.           the PC. The ToolBox will detect, and report, any errors that you
  852.           may make in selecting the port or specifying the initial
  853.           parameters. The ToolBox cannot and will not detect an attempt to
  854.           open a nonexistent serial port.
  855.  
  856.           The ToolBox interfaces directly with the interrupt structure of the
  857.           PC. It is critical before exiting a program that has opened a
  858.           serial port that the serial port is closed with the close function.
  859.           Because a program may terminate abnormally, the open function
  860.           installs an exit routine that will automatically close any open
  861.           ports. Good programming practice demands, however, the your program
  862.           should close the ports explicitly.  By so doing, you may avoid
  863.           problems in the future if we find it necessary to remove the auto-
  864.           close functionality. Further, the auto-close functionality drops
  865.           all modem handshaking signals absolutely, while an explicit close
  866.           can decide whether or not to drop these signals. You should review
  867.           Borland's documentation about installing exit routines in the Turbo
  868.           PASCAL Reference, and you should review the documentation for
  869.           CommClose for further information about the features of that
  870.           procedure.
  871.  
  872.           Failure of the open function can be the result of either improper
  873.           parameters to the open function, or insufficient memory available
  874.           to allocate the requested buffers and related control structures
  875.           for the port. Memory for the transmit and receive buffers as well
  876.           as the port control block are allocated from the heap. It is your
  877.           responsibility to insure that adequate memory is available for this
  878.           purpose.
  879.  
  880.           The 8250 serial chip and its descendants will not transmit
  881.           information until, at a minimum, the DTR (Data Terminal Ready)
  882.           signal is asserted. The ToolBox will, at your option, assert both
  883.  
  884.  
  885.  
  886.                                     Page 14
  887.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  888.  
  889.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  890.  
  891.  
  892.  
  893.           the DTR and RTS signals when you open the port.  If you do not
  894.           select this option  you must use the SetModem function to assert
  895.           (raise) this signal.  In addition, some modems and other devices
  896.           may require you to assert the RTS (Request To Send) signal before
  897.           they will respond to data.  The use of this, and other handshaking
  898.           signals is HIGHLY hardware-dependant.  The ToolBox provides all the
  899.           functionality necessary for you to implement virtually any
  900.           handshaking scheme that might be required.
  901.  
  902.           Due to the use of all available interrupt modes of the 8250, one
  903.           user has discovered an unusual set of circumstances that can be
  904.           troublesome.  If the 8250 chip detects an error condition, such as
  905.           a parity error, framing error, or data overrun error, it causes an
  906.           interrupt to which the ToolBox will respond.  If these errors occur
  907.           frequently enough, the ToolBox code will spend too much time
  908.           handling the errors, and lose characters as a result, causing
  909.           additional errors.  If you encounter a situation in which your
  910.           application appears to behave erratically, especially at higher
  911.           speeds, investigate the following table.
  912.  
  913.                          Table 3.1: Possible Error Conditions                         Table 3.1
  914.  
  915.               -  Is the cabling to the other device sound and solidly
  916.                  connected.
  917.  
  918.               -  Are any of the signals in the cable 'floating' or are they
  919.                  all properly terminated.
  920.  
  921.               -  Is the other device known to be functioning properly. We
  922.                  have encountered situations in which a serial port on some
  923.                  devices tend to be sloppy in terms of voltage levels, bit
  924.                  timings, and similar problems.  Any or all of these
  925.                  situations can cause the erratic operation to which we
  926.                  referred.
  927.  
  928.           Unless you are very familiar with the interrupt structure of the
  929.           PC, do not attempt to manipulate the interrupt enable flag outside
  930.           of the ToolBox. The ToolBox sets and clears the interrupt enable
  931.           flag at appropriate times and assumes that it has sole control over
  932.           the flag.
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.                                     Page 15
  951.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  952.  
  953.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.  
  998.  
  999.  
  1000.  
  1001.  
  1002.  
  1003.  
  1004.  
  1005.  
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.                                     Page 16
  1015.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1016.  
  1017.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.                                      Chapter 4                                     Chapter 4
  1028.  
  1029.                                 LITECOMM-TP HISTORY                                LITECOMM-TP HISTORY
  1030.  
  1031.  
  1032.        4.1  VERSION 3.0       4.1  VERSION 3.0
  1033.  
  1034.  
  1035.           Version 3 of LiteComm-TP was a departure from the precedent
  1036.           established in previous version.  In versions 1 and 2, LiteComm-TP
  1037.           was implemented strictly in Turbo-PASCAL.  The advantages to a
  1038.           strictly high-level language implementation are obvious...as is the
  1039.           drawback of speed.  In version 3.0, the kernel interrupt handlers
  1040.           were re-implemented in assembly language.  In addition, version 3
  1041.           contained some fundamental function additions that will be of use
  1042.           to those attempting to develop bulletin board systems.  In
  1043.           addition, we feel that these routines will serve as a tutorial on
  1044.           how to approach certain communications problems.
  1045.  
  1046.           With version 3, we also included interrupt chaining for COM3 and
  1047.           COM4, that users of the C version of LiteComm have enjoyed since
  1048.           version 2.
  1049.  
  1050.  
  1051.        4.2  NEW IN VERSION 5       4.2  NEW IN VERSION 5
  1052.  
  1053.  
  1054.           There will be no version 4 of the LiteComm-TP ToolBox.  We have
  1055.           opted to bring out the next revision as Revision 5 to maintain
  1056.           consistency with the C version.
  1057.  
  1058.           Version 5 features significant enhancement to the kernel interrupt
  1059.           handlers and supporting code, resulting in higher baud rates on
  1060.           older, slower systems.  In addition, the tighter code should result
  1061.           in smaller applications.
  1062.  
  1063.           And with version 5, we have also upgraded and enhanced the XModem
  1064.           and YModem protocol engines with additional capabilities.  If you
  1065.           are interested in the protocol engines, see the separate
  1066.           documentation for them.  Note that the protocol engines are a part
  1067.           of the registered version of LiteComm-TP only.
  1068.  
  1069.           Due to a lack of interest in Windowed XModem, we have decided to
  1070.           drop support for that engine, in favor of the other, more advanced
  1071.           protocols.  For your convenience, we will continue to provide the
  1072.           source code for the WXModem engine, but we cannot answer questions
  1073.           or support it.
  1074.  
  1075.  
  1076.  
  1077.  
  1078.                                     Page 17
  1079.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1080.  
  1081.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1082.  
  1083.  
  1084.  
  1085.           We had originally planned to include a ZModem protocol engine as
  1086.           part of version 5.  While that engine is nearing completion, we did
  1087.           not want to hold up the newest version of the main package. Nor did
  1088.           we want to release something like ZModem until we are satisfied
  1089.           with its performance. ZModem is coming in the next major release.
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130.  
  1131.  
  1132.  
  1133.  
  1134.  
  1135.  
  1136.  
  1137.  
  1138.  
  1139.  
  1140.  
  1141.  
  1142.                                     Page 18
  1143.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1144.  
  1145.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.                                      Chapter 5                                     Chapter 5
  1156.  
  1157.                                     BEYOND COM2                                    BEYOND COM2
  1158.  
  1159.  
  1160.        5.1  THE TOOLBOX METHODOLOGY       5.1  THE TOOLBOX METHODOLOGY
  1161.  
  1162.  
  1163.           In the design of the original PC, and in subsequent variations such
  1164.           as the PC/AT, there were only provision for two serial ports. Many
  1165.           manufacturers of add-in products, both serial ports and internal
  1166.           modems have added the capability to support 1 or more additional
  1167.           ports beyond the COM2 limit. Generally, this can cause problems in
  1168.           the PC since there is no room in the interrupt request scheme for
  1169.           additional levels of interrupts, and there are no designated
  1170.           interrupt vectors for other additional ports.
  1171.  
  1172.           The ToolBox approach to resolving these issues is to permit the
  1173.           programmer a degree of control over the parameters that govern the
  1174.           interrupt mechanism for COM3 and COM4. Specifically, these
  1175.           parameters are:
  1176.  
  1177.              1.  The interrupt request (IRQ) bit that is used to mask the
  1178.                  8259 interrupt controller.
  1179.  
  1180.              2.  The interrupt vector number (not address) to which the port
  1181.                  is attached.
  1182.  
  1183.              3.  The base i/o register for the port itself. Of course, it is
  1184.                  assumed that the port is based upon the 8250 UART or
  1185.                  compatible device.
  1186.  
  1187.           Before you attempt to use COM3 and/or COM4, you must determine from
  1188.           the port's documentation, the appropriate values for these three
  1189.           parameters. As distributed, the ToolBox assumes the following:
  1190.  
  1191.                        Table 5.1: COM3 and COM4 Default Settings                       Table 5.1
  1192.  
  1193.                                            COM3             COM4                                           ____             ____
  1194.  
  1195.           IRQ Bit                          4                3
  1196.           Vector #                         0Ch              0Bh
  1197.           Base Reg                         3E8h             2E8h
  1198.  
  1199.           You may change any or all of these values by using the PortChange
  1200.           function described below, but only before you open the port with
  1201.           CommOpen. Once the port has been opened, PortChange is ineffective,
  1202.           and PortChange will not work at all on COM1 or COM2.
  1203.  
  1204.  
  1205.  
  1206.                                     Page 19
  1207.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1208.  
  1209.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1210.  
  1211.  
  1212.  
  1213.           At present, LiteComm is not compatible with multiport boards such
  1214.           as the Digiboard.  The structure of these boards generally require
  1215.           additional programming to be used effectively.  If you want to use
  1216.           such a board with LiteComm, please contact us directly for
  1217.           information on custom modifications to LiteComm.  We have performed
  1218.           such modifications for other LiteComm users.
  1219.  
  1220.  
  1221.        5.2  CAUTIONS       5.2  CAUTIONS
  1222.  
  1223.  
  1224.           There is an intimate relationship between the IRQ setting and the
  1225.           interrupt vector to which it relates. In the PC, this relationship
  1226.           is controlled, in part, by the 8259 interrupt controller that is
  1227.           set during BIOS initialization.
  1228.           In brief, the BIOS settings for the PC (and most close compatibles)
  1229.           establish IRQ0 as being vector number 08h, and subsequent IRQ
  1230.           levels at increasing vector numbers. These vector numbers (or types
  1231.           in INTEL terms) act as a cpu-directed call table to locations in
  1232.           the lowest 1K of system memory. We can alter how the system
  1233.           responds to a given interrupt by replacing or changing the values
  1234.           in the associated vector position to point to a routine which we
  1235.           supply.
  1236.  
  1237.           COM3 and COM4 share two critical parameters with COM1 and COM2
  1238.           respectively, the IRQ bit and the interrupt vector number. If you
  1239.           use COM3 and COM4 with the default IRQ and Vector values, and you
  1240.           have a COM1 or COM2 installed in your system, LiteComm will chain
  1241.           (share) the interrupt vector. Otherwise you must change both the
  1242.           IRQ and Vector using the PortChange facility. Please remember, the
  1243.           ability for your add-on ports to handle such a change is highly
  1244.           hardware dependent, so check your port's documentation carefully.
  1245.           Failure to do so will result in loss of data at best, and a system
  1246.           lockup at worst.
  1247.  
  1248.           Judging from the questions asked by some users of LiteComm-TP,
  1249.           there is evidently some misunderstanding about using ports beyond
  1250.           COM2, and how this all relates to your hardware. Before you can
  1251.           successfully use COM3 or COM4, you must consider the following:
  1252.  
  1253.              1.  Does the hardware permit a change to the base port and/or
  1254.                  the interrupt vector to which the port responds.  Some
  1255.                  expansion cards will support changing one and not the other,
  1256.                  giving rise to potential hardware conflicts and lost data.
  1257.  
  1258.              2.  Does the hardware permit  reassignment of the IRQ priority.
  1259.                  Some expansion cards permit you to alter the IRQ priority,
  1260.                  some won't. Suffice it to say from the previous discussion
  1261.                  the any change to the IRQ priority must allow a
  1262.                  corresponding change to the interrupt vector number. Without
  1263.                  this capability, reprogramming of the 8259 chip would be
  1264.                  required.
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.                                     Page 20
  1271.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1272.  
  1273.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1274.  
  1275.  
  1276.  
  1277.              3.  In fact, many add-on cards permit this dual change simply by
  1278.                  making a single switch or jumper setting. Unfortunately, the
  1279.                  documentation for these cards  generally assume that you are
  1280.                  aware of the dual nature of the IRQ vector relationship, and
  1281.                  may leave you with the impression that you are changing one
  1282.                  and not the other. In most circumstances, this is not the
  1283.                  case.
  1284.  
  1285.           The point to all of this is that LiteComm-TP can only provide as
  1286.           much support as the hardware permits, or is capable of responding
  1287.           to. If you wish to use other than the default base port, interrupt
  1288.           vector, or irq priority for COM3 or COM4, then your expansion card
  1289.           must be capable of supporting the new values; in other words, these
  1290.           values are all hardware-provided, and are recognized by the
  1291.           LiteComm-TP software. If your hardware does not permit changing a
  1292.           value, LiteComm-TP cannot improve the situation.
  1293.  
  1294.           We should, at this point, add one final caution about how interrupt
  1295.           priorities function, and their relationship to the irq bit the you
  1296.           may select. The standard PC permits 8 interrupt priority levels,
  1297.           with the programmable timer having the highest priority, and the
  1298.           parallel printer port having the lowest priority. When an interrupt
  1299.           occurs, the interrupt controller (8259 chip) masks out all other
  1300.           interrupts from the priority of the interrupting device and all
  1301.           lower priority devices.
  1302.           As an aid to making COM3 and COM4 "fit", LiteComm-TP supports
  1303.           interrupt chaining for the COM3 and COM4 ports. If you use COM3 or
  1304.           COM4, when an interrupt occurs, the kernel will attempt to
  1305.           determine if the interrupt was caused by the supported port or from
  1306.           some other source.
  1307.  
  1308.           If the kernel determines that the supported port did not cause the
  1309.           interrupt, an automatic chain to the original interrupt handler for
  1310.           that interrupt level (IRQ level) will take place, allowing you to
  1311.           "patch in" or share the available interrupt vectors.
  1312.  
  1313.           If you intend to use other than the provided defaults, be sure that
  1314.           you understand the interrupt mechanism. The use of the automatic
  1315.           chaining described above can be particularly troublesome under some
  1316.           circumstances, resulting in loss of interrupts and, potentially, a
  1317.           system crash.
  1318.  
  1319.           DO NOT attempt to mix the ToolBox functions with other seemingly-
  1320.           related functions (such as the serial port BIOS routines in Turbo
  1321.           PASCAL).  At least two users have attempted to only use the receive
  1322.           portions of LiteComm, while resorting to the BIOS functions to send
  1323.           characters or adjust port parameters such as baud rate. The
  1324.           results, at best, have been failure of the user's application to
  1325.           function, and, at worst, total system lockup.  This mix of
  1326.           functions is NOT supported and must not be used.  If you attempt
  1327.           such a mix, we cannot help you.
  1328.  
  1329.           One final caution is in order.  One or two users have attempted to
  1330.           trace through the interrupts as they occur using debuggers.  This
  1331.  
  1332.  
  1333.  
  1334.                                     Page 21
  1335.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1336.  
  1337.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1338.  
  1339.  
  1340.  
  1341.           is a risky proposition at best since most debuggers work by tapping
  1342.           into, and disturbing, the interrupt mechanism.  If you feel you
  1343.           must use a debugger, try to stay away from the kernel routines of
  1344.           LiteComm, or use a hardware-based debugger such as Periscope.
  1345.  
  1346.  
  1347.        5.3  OTHER GENERAL NOTES AND WARNINGS       5.3  OTHER GENERAL NOTES AND WARNINGS
  1348.  
  1349.  
  1350.           In the discussion of the various functions which follow, you should
  1351.           assume that any references to the 'port' variable refer to a
  1352.           variable or constant that may take on a value of from 1 to 4. No
  1353.           other values are acceptable, and will be rejected.
  1354.  
  1355.           While we feel that LiteComm-TP is written in the most efficient way
  1356.           possible, commensurate with good programming practice, we cannot be
  1357.           responsible for variations caused by hardware configurations or
  1358.           other factors beyond our control. LiteComm-TP has been tested, and
  1359.           is known to perform on, the IBM PC-AT and several compatible
  1360.           systems such as the Zenith and Wyse equivalents. LiteComm-TP has
  1361.           not been tested in environments in which other software, most
  1362.           significantly TSR (terminate and stay resident) modules exist. Some
  1363.           TSR programs that "steal" interrupts for their own purposes present
  1364.           an unfavorable environment to other programs that rely on the
  1365.           interrupt structure of the computer.
  1366.  
  1367.           Should you experience erratic behavior with LiteComm-TP in a TSR-
  1368.           type situation, try executing your application without the TSR
  1369.           module being present. If the problems you have experienced
  1370.           disappear, suspect the TSR module.
  1371.  
  1372.           Conversely, LiteComm-TP provides an excellent vehicle for
  1373.           supporting TSR programs that you may write. Since the package is
  1374.           fully re-entrant, your only concern need be with those aspects of
  1375.           TSR programs are of normal concern, e.g. the non-reentrant nature
  1376.           of DOS. LiteComm-TP never uses DOS functions and may therefore be
  1377.           safely used in a TSR environment.
  1378.  
  1379.  
  1380.        5.4  USE WITH MULTITASKING ENVIRONMENTS       5.4  USE WITH MULTITASKING ENVIRONMENTS
  1381.  
  1382.  
  1383.           Some users have made attempts, with varying degrees of success, at
  1384.           using LiteComm in conjunction with multitasking environments such
  1385.           as Quarterdesk's DesqView.  Use of LiteComm in such an environment
  1386.           is certain to be affected by the way in which the multitasking
  1387.           monitor behaves with respect to interrupts.
  1388.  
  1389.           While we recognize that DesqView has achieved a certain measure of
  1390.           popularity among so-called power users, LiteComm was not explicitly
  1391.           designed for such an environment, and its performance may suffer as
  1392.           a result.
  1393.  
  1394.  
  1395.  
  1396.  
  1397.  
  1398.                                     Page 22
  1399.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1400.  
  1401.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1402.  
  1403.  
  1404.  
  1405.        5.5  NOTES ON RING DETECTION       5.5  NOTES ON RING DETECTION
  1406.  
  1407.  
  1408.           Several users have reported difficulty in consistently detecting a
  1409.           ringing telephone by checking the state of the RI (Ring Indicator)
  1410.           signal.  The problem seems to be highly dependent on the type of
  1411.           modem that is being used since this signal is provided by the
  1412.           modem, NOT the serial port.  If the duration of the signal is too
  1413.           short, the program may 'miss' the signal as the modem toggles it on
  1414.           and off.  One workaround that has been used successfully is to
  1415.           check the DeltaRI bit that can be obtained from the ModemStatus
  1416.           function, rather that the RI bit itself.  The DeltaRI bit will be
  1417.           set when the RI bit comes on and again when the RI bit goes off.
  1418.           This is the method we employ in the CheckForCall function.
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.  
  1455.  
  1456.  
  1457.  
  1458.  
  1459.  
  1460.  
  1461.  
  1462.                                     Page 23
  1463.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1464.  
  1465.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1466.  
  1467.  
  1468.  
  1469.  
  1470.  
  1471.  
  1472.  
  1473.  
  1474.  
  1475.  
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.  
  1521.  
  1522.  
  1523.  
  1524.  
  1525.  
  1526.                                     Page 24
  1527.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1528.  
  1529.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1530.  
  1531.  
  1532.  
  1533.  
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.                                      Chapter 6                                     Chapter 6
  1540.  
  1541.                                   PACKAGE CONTENTS                                  PACKAGE CONTENTS
  1542.  
  1543.  
  1544.           Your distribution diskette contains several files that are
  1545.           important to you. All distribution diskettes, at a minimum, include
  1546.           the following files in the diskette's root directory:
  1547.                           Table 6.1: Basic Diskette Contents                          Table 6.1
  1548.  
  1549.                       READ.ME           LATEST INFORMATION ABOUT
  1550.                                              LITECOMM-TP
  1551.  
  1552.                       LTCOMM.ARC        SHAREWARE VERSION AND
  1553.                                              DOCUMENTATION FILES
  1554.  
  1555.                       LTUNITS.ARC       FULLY FUNCTIONAL UNIT FILES
  1556.  
  1557.           If you registered for the source code modules, the diskette
  1558.           contains 2 additional source code archives.
  1559.  
  1560.  
  1561.                       LITECOMM-TP SOURCE CODE          LTSRC.ARC
  1562.  
  1563.                       XMODEM ENGINE SOURCE CODE      LTXMSRC.ARC
  1564.  
  1565.  
  1566.        6.1  INSTALLATION INSTRUCTIONS       6.1  INSTALLATION INSTRUCTIONS
  1567.  
  1568.  
  1569.           In the following discussion, we assume that your regular unit files          __ ___ _________ ___________ __ ______ ____ ____ _______ ____ _____
  1570.           are contained in a directory called \TP.          ___ _________ __ _ _________ ______ \TP_                                              ___
  1571.           To install the unit files used with LiteComm-TP, perform the
  1572.           following steps:
  1573.  
  1574.              1.  CD \TP
  1575.  
  1576.              2.  ARC E A:LTUNITS
  1577.  
  1578.           Since Turbo PASCAL permits you the flexibility of having a separate
  1579.           subdirectory for units, you should execute the above instructions
  1580.           in whatever directory you use for units.
  1581.  
  1582.           If you are installing only the units, this completes the
  1583.           installation procedure. If you have registered for the package's
  1584.           source code, we recommend that you create a separate subdirectory.
  1585.           The example below assumes that you will use a directory named COMM
  1586.  
  1587.  
  1588.  
  1589.  
  1590.                                     Page 25
  1591.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1592.  
  1593.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1594.  
  1595.  
  1596.  
  1597.           to hold the LiteComm-TP and XModem source code modules. To install
  1598.           the LiteComm-TP source code, do the following:
  1599.  
  1600.              1.  MD \COMM
  1601.  
  1602.              2.  CD \COMM
  1603.  
  1604.              3.  ARC E A:LTSRC *.*
  1605.  
  1606.              4.  ARC E A:LTXMSRC *.*
  1607.  
  1608.           We strongly urge that you use the recommended approach in handling
  1609.           the source code to avoid naming conflicts that might arise.
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.  
  1653.  
  1654.                                     Page 26
  1655.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1656.  
  1657.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663.  
  1664.  
  1665.  
  1666.  
  1667.                                      Chapter 7                                     Chapter 7
  1668.  
  1669.                           PROCEDURE AND FUNCTION REFERENCE                          PROCEDURE AND FUNCTION REFERENCE
  1670.  
  1671.  
  1672.           In the following pages, we provide the detailed information about
  1673.           each of the available LiteComm-TP ToolBox functions and procedures.
  1674.           Each definition includes, at a minimum, a summary of how the
  1675.           function or procedure is referenced, in which unit the function or
  1676.           procedure is found, a description of what the function or procedure
  1677.           does, and an indication of those values, if any, that might be
  1678.           returned.
  1679.  
  1680.           Where appropriate, we include additional documentation about the
  1681.           function.  Some definitions include examples, in the sense of code
  1682.           fragments illustrating the function's usage.  More importantly,
  1683.           some definitions include additional notes and warnings as well as
  1684.           references to other functions within the package.
  1685.  
  1686.           We have made every effort to insure that the documentation of the
  1687.           functions is complete and accurate.  The style and manner of the
  1688.           documentation assumes that the reader is thoroughly familiar with
  1689.           the elements of PASCAL syntax and common conventions.
  1690.  
  1691.  
  1692.        7.1  UNIT USAGE       7.1  UNIT USAGE
  1693.  
  1694.  
  1695.           To assist you in developing your own applications, you will need to
  1696.           know the following information.
  1697.  
  1698.                          Unit           Uses
  1699.  
  1700.                          LctKrnl        DOS
  1701.                          LctSupp        DOS, LctKrnl
  1702.                          LctHayes       DOS, LctSupp
  1703.                          LctBBs         DOS, CRT, LctKrnl, LctSupp
  1704.                          LTXMKrnl       DOS, LctSupp
  1705.                          LTXModem       DOS, LctSupp, LTXMKrnl
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.  
  1715.  
  1716.  
  1717.  
  1718.                                     Page 27
  1719.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1720.  
  1721.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.                                 PortChange function                                PortChange function
  1732.  
  1733.  
  1734.           UNIT            LctKrnl          UNIT
  1735.  
  1736.           FUNCTION        Changes one or more of the critical parameters for          FUNCTION
  1737.                           port COM3 or COM4.
  1738.  
  1739.           DECLARATION     PortChange(CPort:integer; NewBase:word; NewIrq,          DECLARATION
  1740.                           NewVector:byte)
  1741.  
  1742.           RESULT TYPE     boolean          RESULT TYPE
  1743.  
  1744.           REMARKS         This function must be used before the port is          REMARKS
  1745.                           opened to be effective. To leave any of the
  1746.                           parameters at its default value, make the
  1747.                           corresponding entry 0. Note that vector is a vector
  1748.                           number, not an address or pointer.
  1749.                            
  1750.                           The irq parameter should not be taken to be the irq
  1751.                           (interrupt request number), but rather the irq
  1752.                           mask. For example, the correct value for irq4 is
  1753.                           NOT 4, but a byte in which bit 4, using INTEL's bit
  1754.                           numbering, is set to a value of 1. Thus, to use irq
  1755.                           priority 4 as the irq for either COM3 or COM4, you
  1756.                           would specify $10 as the value of irq when calling
  1757.                           PortChange.
  1758.                            
  1759.                           If you intend to change the default irq settings,
  1760.                           you MUST also make a corresponding change to the
  1761.                           vector number. See the preceding section about
  1762.                           using COM3 and COM4 for additional details. Failure
  1763.                           to follow this rule may make the port appear to be
  1764.                           nonfunctional.
  1765.                            
  1766.                           The PortChange function does NOT check to determine
  1767.                           that you have provided both an IRQ mask AND a new
  1768.                           vector number.
  1769.                           PortChange returns a value of TRUE if the change
  1770.                           was successful, false otherwise.
  1771.  
  1772.           EXAMPLE         Var          EXAMPLE
  1773.                             Newbase : word;
  1774.                             Newirq : byte;
  1775.                             NewVector : byte;
  1776.                           Begin
  1777.                             Newbase := $03E8;
  1778.                             Newirq := $10;
  1779.  
  1780.  
  1781.  
  1782.                                     Page 28
  1783.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1784.  
  1785.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1786.  
  1787.  
  1788.  
  1789.                             NewVector := $0C;
  1790.                            
  1791.                             if PortChange(3, Newbase, Newirq, NewVector) then
  1792.                               Writeln('Port 3 Changed')
  1793.                             else
  1794.                               Writeln('Error changing Port 3');
  1795.                             end;
  1796.  
  1797.  
  1798.  
  1799.  
  1800.  
  1801.  
  1802.                                  CommOpen function                                 CommOpen function
  1803.  
  1804.  
  1805.           UNIT            LctKrnl          UNIT
  1806.  
  1807.           FUNCTION        Prepares the specified port for use by the other          FUNCTION
  1808.                           functions
  1809.  
  1810.           DECLARATION     CommOpen(CPort, Baud:integer; Parity:char;          DECLARATION
  1811.                           Databits, Stopbits, InSize, OutSize:integer;
  1812.                           RaiseMdmCtl:BOOLEAN)
  1813.  
  1814.           RESULT TYPE     boolean          RESULT TYPE
  1815.  
  1816.           REMARKS         Opens the specified port for use and attaches an          REMARKS
  1817.                           interrupt handler to DOS for the port. The function
  1818.                           allocates buffers for input and output of the
  1819.                           specified sizes, and sets the port to the
  1820.                           parameters specified. The minimum value for InSize
  1821.                           is 128; the minimum size for OutSize is 64. A port
  1822.                           opened in this manner must be closed using
  1823.                           CommClose before program termination to avoid the
  1824.                           possibility of a system crash.
  1825.                            
  1826.                           CommOpen sets aside an additional 512 bytes per
  1827.                           open port. This additional memory is used as the
  1828.                           stack for the port's interrupt handler while
  1829.                           interrupts are being processed.  This approach help
  1830.                           avoid the possibility of stack overflows that might
  1831.                           occur under some conditions.
  1832.                            
  1833.                           CommOpen installs an exit procedure to protect DOS
  1834.                           from problems that might arise if a program using
  1835.                           LiteComm fails.  However, we recommend that you
  1836.                           always close a port opened with CommOpen by calling
  1837.                           CommClose explicitly in your program to gain
  1838.                           maximum control over the port.
  1839.                            
  1840.                           The parameters passed to the function are discrete
  1841.                           values, and must be drawn from the following lists:
  1842.                            
  1843.  
  1844.  
  1845.  
  1846.                                     Page 29
  1847.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1848.  
  1849.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1850.  
  1851.  
  1852.  
  1853.                           Baud        any value that your communication                          Baud
  1854.                                       equipment, e.g. your modem, will
  1855.                                       support.
  1856.  
  1857.                           Parity      E, O, N, M, S                          Parity
  1858.                                       E - Even
  1859.                                       O - Odd
  1860.                                       N - None
  1861.                                       M - Mark
  1862.                                       S - Space
  1863.  
  1864.                           Databits    5, 6, 7, 8                          Databits
  1865.  
  1866.                           StopBits    1, 2                          StopBits
  1867.  
  1868.                            
  1869.                           If RaiseMdmCtl has a value of TRUE, CommOpen will
  1870.                           automatically raise the handshaking signals DTR and
  1871.                           RTS.  If RaiseMdmCtl has a value of FALSE, the
  1872.                           programmer must raise these signals by calling
  1873.                           SetModemSignals.  In general, use the second form
  1874.                           to gain full control over the handshaking signals
  1875.                           if needed, use the first form in those cases where
  1876.                           the control of these two signals is noncritical.
  1877.                            
  1878.                           A return of TRUE indicates the port has been
  1879.                           successfully opened and is ready for use.  A return
  1880.                           of FALSE indicates an error occurred, either as the
  1881.                           result of an invalid parameter, or insufficient
  1882.                           heap space available to allocate the buffers and
  1883.                           control structures for the port.
  1884.  
  1885.           EXAMPLE         Var          EXAMPLE
  1886.                             Baud, Databits, Stopbits : integer;
  1887.                             Parity : char;
  1888.                             Insize, Outsize : integer;
  1889.                            
  1890.                           begin
  1891.                             Baud := 2400;
  1892.                             Parity := 'E';
  1893.                             Databits := 7;
  1894.                             Stopbits := 1;
  1895.                             Insize := 256;
  1896.                             Outsize := 256;
  1897.                            
  1898.                             if CommOpen(1, Baud, Parity, Databits, Stopbits,
  1899.                           Insize, Outsize, TRUE) then
  1900.                               Writeln('COM1 available for use')
  1901.                             else
  1902.                               Writeln('Error opening COM1');
  1903.                            
  1904.                           The equivalent code to the above is shown below
  1905.                            
  1906.  
  1907.  
  1908.  
  1909.  
  1910.                                     Page 30
  1911.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1912.  
  1913.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1914.  
  1915.  
  1916.  
  1917.                             if CommOpen(1, Baud, Parity, Databits, Stopbits,
  1918.                           Insize, Outsize, FALSE) then
  1919.                               Writeln('COM1 is now open')
  1920.                             else
  1921.                               Writeln('Error opening COM1');
  1922.                             if SetModemSignals(1, (DTR OR RTS)) then
  1923.                               Writeln('Port is ready to transmit')
  1924.                             else
  1925.                               Writeln('Unable to set modem signals');
  1926.  
  1927.           SEE ALSO        SetModemSignals          SEE ALSO
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.                                 CommClose procedure                                CommClose procedure
  1935.  
  1936.  
  1937.           UNIT            LctKrnl          UNIT
  1938.  
  1939.           FUNCTION        Closes a port that has been opened by the CommOpen          FUNCTION
  1940.                           function
  1941.  
  1942.           DECLARATION     CommClose(CPort:integer; DropMdmCtl:BOOLEAN)          DECLARATION
  1943.  
  1944.           REMARKS         This function is the companion to CommOpen and, in          REMARKS
  1945.                           effect, performs the opposite action. CommClose
  1946.                           detaches the kernel interrupt handler from the
  1947.                           port, and reconnects the previous interrupt
  1948.                           handler.  CommClose also release dynamically
  1949.                           allocated memory used for buffering and control
  1950.                           structures. If DropMdmCtl has a value of TRUE, the
  1951.                           port is closed absolutely; both the DTR and RTS
  1952.                           signals are dropped.  If DropMdmCtl has a value of
  1953.                           FALSE, the port is closed conditionally and both
  1954.                           DTR and RTS are left in their current state.
  1955.                            
  1956.                           Since CommOpen installs an exit procedure, you are
  1957.                           not required to explicitly close an open port.
  1958.                           However, if you do not use an explicit close, you
  1959.                           will lose control over the handling of DTR and RTS.
  1960.                           The built-in exit procedure always uses the
  1961.                           absolute form of the close.
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.                                     Page 31
  1975.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  1976.  
  1977.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.                                  CommSetup function                                 CommSetup function
  1988.  
  1989.  
  1990.           UNIT            LctKrnl          UNIT
  1991.  
  1992.           FUNCTION        Provides the capability of changing the parameters          FUNCTION
  1993.                           for an open port, without breaking the connection
  1994.                           or closing the port.
  1995.  
  1996.           DECLARATION     CommSetup(CPort, Baud:integer; Parity:char;          DECLARATION
  1997.                           Databits, Stopbits:integer)
  1998.  
  1999.           RESULT TYPE     boolean          RESULT TYPE
  2000.  
  2001.           REMARKS         The CommSetup function is a subset of the CommOpen          REMARKS
  2002.                           function and the remarks made in the description of
  2003.                           CommOpen apply. This function is useful if you wish
  2004.                           to change the basic communication parameters of the
  2005.                           specified port that has already been opened without
  2006.                           CommClose'ing the port and breaking the connection.
  2007.  
  2008.           SEE ALSO        CommOpen          SEE ALSO
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.                                BytesInInput function                               BytesInInput function
  2016.  
  2017.  
  2018.           UNIT            LctSupp          UNIT
  2019.  
  2020.           FUNCTION        Returns the number of characters currently          FUNCTION
  2021.                           available in the input buffer (BytesInInput) or the
  2022.                           number of untransmitted characters in the output
  2023.                           buffer (ByteInOutput).
  2024.  
  2025.           DECLARATION     BytesInInput(CPort:integer)          DECLARATION
  2026.                           BytesInOutput(CPort:integer)
  2027.  
  2028.           RESULT TYPE     integer          RESULT TYPE
  2029.  
  2030.           REMARKS         May be used to determine the number of characters          REMARKS
  2031.                           currently in the input (BytesInInput) or output
  2032.                           (BytesInOutput) buffers for the port. In the event
  2033.                           of an error (bad port), a value of -1 is returned.
  2034.  
  2035.  
  2036.  
  2037.  
  2038.                                     Page 32
  2039.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2040.  
  2041.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2042.  
  2043.  
  2044.  
  2045.  
  2046.  
  2047.  
  2048.  
  2049.  
  2050.  
  2051.                                 ModemStatus function                                ModemStatus function
  2052.  
  2053.  
  2054.           UNIT            LctKrnl          UNIT
  2055.  
  2056.           FUNCTION        Returns the last know status of the modem control          FUNCTION
  2057.                           lines for the specified port.
  2058.  
  2059.           DECLARATION     ModemStatus(CPort:integer)          DECLARATION
  2060.  
  2061.           RESULT TYPE     byte          RESULT TYPE
  2062.  
  2063.           REMARKS         Use this function to determine the last known state          REMARKS
  2064.                           of the modem-supplied handshake signals. These may
  2065.                           be tested using the values included in the unit,
  2066.                           using PASCAL's bitwise AND operator.
  2067.                            
  2068.                           The byte value returned can be viewed as consisting
  2069.                           of two sub-fields, the current signal state (found
  2070.                           in bits 4-7 of the byte), and the signal
  2071.                           change(DELTA) indicators(found in the bits 0-3 of
  2072.                           the byte).  ModemStatus always returns the current
  2073.                           state of the signals in bits 4-7.  Bits 0-3 will
  2074.                           reflect which, if any, of the signals has changed.
  2075.                            
  2076.                           Whenever this function is called, both subfields
  2077.                           are returned, and represent the current state of
  2078.                           the individual signals.  The DELTA settings may be
  2079.                           all reset, if no signals have changed since the
  2080.                           last call to the function.  The signals which are
  2081.                           tracked are CTS, DSR, RI, and DCD.
  2082.                            
  2083.                           To determine which signals, if any, have changed
  2084.                           use the DeltaXXX bits returned. For example, if CTS
  2085.                           has changed, the DeltaCTS bit will be set.  The
  2086.                           actual CTS value (on or off) will be found in the
  2087.                           CTS bit of the returned byte.
  2088.                            
  2089.                           In the event of an error, a byte of $00 is
  2090.                           returned.
  2091.  
  2092.           HINT            Detecting a ringing phone (using the RI signal) can          HINT
  2093.                           be tricky and timing dependent.  One nearly
  2094.                           foolproof method that we have used is to examine
  2095.                           the DeltaRI value, not the RI value.  The DeltaRI
  2096.                           value is set and reset as the telephone starts and
  2097.                           stops ringing.  The RI value is set and cleared
  2098.                           independently, and you may miss the fact that the
  2099.  
  2100.  
  2101.  
  2102.                                     Page 33
  2103.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2104.  
  2105.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2106.  
  2107.  
  2108.  
  2109.                           phone is ringing if you don't examine the value at
  2110.                           the right time.
  2111.  
  2112.           EXAMPLE         Var          EXAMPLE
  2113.                             CStat : byte;
  2114.                             
  2115.                           begin
  2116.                             CStat := ModemStatus(1);
  2117.                             if CStat and DeltaDCD = DeltaDCD then
  2118.                               if CStat and DCD <> DCD then
  2119.                                 Writeln('Remote is off-line, carrier lost');
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.                                  BreakRecd function                                 BreakRecd function
  2127.  
  2128.  
  2129.           UNIT            LctKrnl          UNIT
  2130.  
  2131.           FUNCTION        Returns a value of true if a BREAK signal has been          FUNCTION
  2132.                           received from the serial port since that last call
  2133.                           to the function.
  2134.  
  2135.           DECLARATION     BreakRecd(CPort:integer);          DECLARATION
  2136.  
  2137.           RESULT TYPE     boolean;          RESULT TYPE
  2138.  
  2139.           REMARKS         This function returns a value of TRUE if a BREAK          REMARKS
  2140.                           character has been received since the last call to
  2141.                           the function.
  2142.  
  2143.           EXAMPLE         if BreakRecd(2) then          EXAMPLE
  2144.                             Writeln('Break Signal detected on Port 2');
  2145.  
  2146.  
  2147.  
  2148.  
  2149.  
  2150.  
  2151.                                 ErrorStatus function                                ErrorStatus function
  2152.  
  2153.  
  2154.           UNIT            LctKrnl          UNIT
  2155.  
  2156.           FUNCTION        Return the last known error status for the          FUNCTION
  2157.                           specified port.
  2158.  
  2159.           DECLARATION     ErrorStatus(CPort:integer)          DECLARATION
  2160.  
  2161.           RESULT TYPE     byte          RESULT TYPE
  2162.  
  2163.  
  2164.  
  2165.  
  2166.                                     Page 34
  2167.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2168.  
  2169.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2170.  
  2171.  
  2172.  
  2173.           REMARKS         Returns the last known state of the serial port's          REMARKS
  2174.                           error status bits, encoded in a byte. These may be
  2175.                           tested using the constants defined in the unit in
  2176.                           conjunction with PASCAL's bitwise AND operator.
  2177.                           The applicable values that may be checked are
  2178.                           OverRun, BadParity, and, BadFrame.
  2179.                            
  2180.  
  2181.                              1.  OverRun - failure to fetch a character from
  2182.                                  the port before the next character was
  2183.                                  received. Usually caused by a problem in the
  2184.                                  interrupt handler.
  2185.  
  2186.                              2.  BadParity - One or more characters were
  2187.                                  received in which the parity of the
  2188.                                  character(s) did not match the current
  2189.                                  parity setting of the port.  Can be caused
  2190.                                  by line noise (electrical interference),
  2191.                                  poor connections, or a variety of other
  2192.                                  reasons.
  2193.  
  2194.                              3.  BadFrame - A framing error has occurred.  A
  2195.                                  character was received that had too few or
  2196.                                  (more likely) too many bits.  Usually caused
  2197.                                  bye line noise.
  2198.  
  2199.                            
  2200.                           Break detection, i.e. the receipt of a BREAK
  2201.                           character, is handled by the BreakRecd
  2202.                           function(qv).  In the event of an error, a byte of
  2203.                           $00 is returned.
  2204.                            
  2205.                           Once the error status bits have been read in this
  2206.                           fashion, they are reset to $00, and will remain so
  2207.                           until the next error occurs.  Since this process
  2208.                           happens asynchronously, it is not possible for your
  2209.                           application to determine which character created
  2210.                           the error, only that the error occurred.
  2211.  
  2212.           EXAMPLE         Var          EXAMPLE
  2213.                             EStat : byte;
  2214.                            
  2215.                           begin
  2216.                             EStat := ErrorStatus(2);
  2217.                             if EStat and OverRun = OverRun then
  2218.                               Writeln('Receive Character Over Run');
  2219.  
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.                                     Page 35
  2231.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2232.  
  2233.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.                               SetModemSignals function                              SetModemSignals function
  2244.  
  2245.  
  2246.           UNIT            LctKrnl          UNIT
  2247.  
  2248.           FUNCTION        Allows the programmer to set the individual modem          FUNCTION
  2249.                           control lines for the specified port.
  2250.  
  2251.           DECLARATION     SetModemSignals(CPort:integer; NewSet:byte)          DECLARATION
  2252.  
  2253.           RESULT TYPE     boolean          RESULT TYPE
  2254.  
  2255.           REMARKS         Set one or more of the modem control signals.          REMARKS
  2256.                           Because of the need to always have OUT2 set for
  2257.                           interrupt support, the function always provides the
  2258.                           correct setting for this bit.
  2259.                            
  2260.                           The value of NewSet is bitwise OR'ed with the
  2261.                           current set of values to produce a new modem
  2262.                           control setting.  The value of NewSet DOES NOT
  2263.                           replace the current values. Use the constants
  2264.                           supplied in the unit to obtain the correct values.
  2265.                           These include DTR and RTS.
  2266.                            
  2267.                           Many applications will not require this, and its
  2268.                           companion, functions, if the permit CommOpen to
  2269.                           raise the DTR and RTS signals.  More sophisticated
  2270.                           applications may be required to control either or
  2271.                           both of the signals to provide handshaking with an
  2272.                           external device.
  2273.  
  2274.           EXAMPLE         begin          EXAMPLE
  2275.                             (* raise both DTR and RTS *)
  2276.                             if SetModemSignals(1, (DTR OR RTS)) then
  2277.                               Writeln('Port is ready to transmit')
  2278.                             else
  2279.                               Writeln('Unable to set modem signals');
  2280.  
  2281.           SEE ALSO        ClearModemSignals, FlipModemSignals          SEE ALSO
  2282.  
  2283.  
  2284.  
  2285.  
  2286.  
  2287.  
  2288.  
  2289.  
  2290.  
  2291.  
  2292.  
  2293.  
  2294.                                     Page 36
  2295.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2296.  
  2297.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2298.  
  2299.  
  2300.  
  2301.  
  2302.  
  2303.  
  2304.  
  2305.  
  2306.  
  2307.                              ClearModemSignals function                             ClearModemSignals function
  2308.  
  2309.  
  2310.           UNIT            LctKrnl          UNIT
  2311.  
  2312.           FUNCTION        Allows the programmer to clear (reset) the          FUNCTION
  2313.                           individual modem control lines for the specified
  2314.                           port.
  2315.  
  2316.           DECLARATION     ClearModemSignals(CPort:integer; NewSet:byte)          DECLARATION
  2317.  
  2318.           RESULT TYPE     boolean          RESULT TYPE
  2319.  
  2320.           REMARKS         Clears (resets) one or more of the modem control          REMARKS
  2321.                           signals. Because of the need to always have OUT2
  2322.                           set for interrupt support, the function always
  2323.                           provides the correct setting for this bit.
  2324.                            
  2325.                           The compliment of NewSet is bitwise AND'ed with the
  2326.                           current set of values to produce a new modem
  2327.                           control setting.  The value of NewSet DOES NOT
  2328.                           replace the current values. Use the constants
  2329.                           supplied in the unit to obtain the correct values.
  2330.                           These include DTR and RTS.
  2331.  
  2332.           EXAMPLE         begin          EXAMPLE
  2333.                             if ClearModemSignals(1,  RTS) then
  2334.                               Writeln('RTS for Port 1 has been dropped')
  2335.                             else
  2336.                               Writeln('Unable to clear RTS');
  2337.  
  2338.           SEE ALSO        SetModemSignals, FlipModemSignals          SEE ALSO
  2339.  
  2340.  
  2341.  
  2342.  
  2343.  
  2344.  
  2345.                              FlipModemSignals function                             FlipModemSignals function
  2346.  
  2347.  
  2348.           UNIT            LctKrnl          UNIT
  2349.  
  2350.           FUNCTION        Allows the programmer to compliment(toggle) the          FUNCTION
  2351.                           individual modem control lines for the specified
  2352.                           port.  This function only has value if you are
  2353.                           attempting to implement some form of hardware
  2354.                           handshaking with another device.  The absolute form
  2355.  
  2356.  
  2357.  
  2358.                                     Page 37
  2359.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2360.  
  2361.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2362.  
  2363.  
  2364.  
  2365.                           of CommClose will automatically lower both RTS AND
  2366.                           DTR, which is generally adequate for many
  2367.                           applications.
  2368.  
  2369.           DECLARATION     FlipModemSignals(CPort:integer; NewSet:byte)          DECLARATION
  2370.  
  2371.           RESULT TYPE     boolean          RESULT TYPE
  2372.  
  2373.           REMARKS         Complements(toggles) one or more of the modem          REMARKS
  2374.                           control signals. Because of the need to always have
  2375.                           OUT2 set for interrupt support, the function always
  2376.                           provides the correct setting for this bit.
  2377.                            
  2378.                           The value of NewSet is bitwise XOR'ed with the
  2379.                           current set of values to produce a new modem
  2380.                           control setting.  The value of NewSet DOES NOT
  2381.                           replace the current values. Use the constants
  2382.                           supplied in the unit to obtain the correct values.
  2383.                           These include DTR and RTS.
  2384.  
  2385.           EXAMPLE         begin          EXAMPLE
  2386.                             (*
  2387.                             ** change the RTS modem control signal to its
  2388.                           other
  2389.                             ** state (if raised, lower it, if lowered raise
  2390.                           it)
  2391.                             *)
  2392.                             if FlipModemSignals(1, RTS) then
  2393.                               Writeln('RTS for Port 1 has been changed')
  2394.                             else
  2395.                               Writeln('Unable to change RTS');
  2396.  
  2397.           SEE ALSO        SetModemSignals, ClearModemSignals          SEE ALSO
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.                                  EnableXon function                                 EnableXon function
  2405.  
  2406.  
  2407.           UNIT            LctKrnl          UNIT
  2408.  
  2409.           FUNCTION        Enable or disable the semiautomatic flow control          FUNCTION
  2410.                           features of LiteComm-TP
  2411.  
  2412.           DECLARATION     EnableXon(CPort:integer; XonFlag:boolean)          DECLARATION
  2413.  
  2414.           RESULT TYPE     boolean;          RESULT TYPE
  2415.  
  2416.           REMARKS         If XonFlag is TRUE, turns on semiautomatic XON-XOFF          REMARKS
  2417.                           flow control function. If XonFlag is FALSE (the
  2418.  
  2419.  
  2420.  
  2421.  
  2422.                                     Page 38
  2423.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2424.  
  2425.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2426.  
  2427.  
  2428.  
  2429.                           default setting), automatic flow control is
  2430.                           disabled.  
  2431.                           When enabled, the kernel will automatically
  2432.                           transmit an XOFF if and when the input buffer is
  2433.                           approximately 2/3 full and will automatically
  2434.                           recognize an XOFF sent by the other device. If the
  2435.                           other device transmits an XOFF, the kernel will
  2436.                           refuse to send any characters until the condition
  2437.                           is cleared, either by receipt of an XON, by calling
  2438.                           the XOffRecd function, or by disabling XON-XOFF
  2439.                           altogether.
  2440.                            
  2441.                           The XOFF recognition is implemented in the kernel.
  2442.                           As a result, the transmit buffer will continue to
  2443.                           accept input from your program until the buffer
  2444.                           fills completely, even though the information will
  2445.                           not be sent.  Once the matching XON is received,
  2446.                           the contents of the transmit buffer will be sent
  2447.                           rapidly to the other device.  It is possible that
  2448.                           the rate with which characters are sent when this
  2449.                           occurs may cause problems for the other device,
  2450.                           depending on its ability to handle the data flow.
  2451.                            
  2452.                           If the kernel has sent an XOFF, it is the
  2453.                           programmer's responsibility to transmit XON when
  2454.                           conditions warrant. Use the XoffSent function to
  2455.                           tell if an automatic XOFF has been sent by the
  2456.                           kernel.
  2457.                            
  2458.                           If you intended to implement a protocol that might
  2459.                           include the XON-XOFF characters, be sure to disable
  2460.                           the automatic flow control. Failure to do so may
  2461.                           result in a system hang.
  2462.  
  2463.           SEE ALSO        XoffRecd, XoffRecd          SEE ALSO
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.                                  XoffRecd function                                 XoffRecd function
  2471.  
  2472.  
  2473.           UNIT            LctKrnl          UNIT
  2474.  
  2475.           FUNCTION        Reports whether or not the kernel has detected an          FUNCTION
  2476.                           XOFF from the other device
  2477.  
  2478.           DECLARATION     XoffRecd(CPort:integer)          DECLARATION
  2479.  
  2480.           RESULT TYPE     boolean          RESULT TYPE
  2481.  
  2482.  
  2483.  
  2484.  
  2485.  
  2486.                                     Page 39
  2487.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2488.  
  2489.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2490.  
  2491.  
  2492.  
  2493.           REMARKS         Returns TRUE if an XOFF has been received, FALSE          REMARKS
  2494.                           otherwise. If an XOFF has been received, the port's
  2495.                           internal flag will be reset, and transmission to
  2496.                           the other device will be permitted. If an XON is
  2497.                           received from the other, the port's flag will also
  2498.                           be reset, permitting further transmissions to
  2499.                           occur.
  2500.                            
  2501.                           If you use flow control and the other device never
  2502.                           sends an XON after sending an XOFF, a system hang
  2503.                           is possible. You may wish to call XoffRecd
  2504.                           periodically to test for this condition, and to
  2505.                           cause your port to resume transmitting data.
  2506.  
  2507.           SEE ALSO        EnableXon, XoffSent          SEE ALSO
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.                                  XoffSent function                                 XoffSent function
  2515.  
  2516.  
  2517.           UNIT            LctKrnl          UNIT
  2518.  
  2519.           FUNCTION        Reports whether or not the kernel has automatically          FUNCTION
  2520.                           sent an XOFF to the other device.
  2521.  
  2522.           DECLARATION     XoffSent(CPort:integer)          DECLARATION
  2523.  
  2524.           RESULT TYPE     boolean          RESULT TYPE
  2525.  
  2526.           REMARKS         Returns TRUE if the LiteComm kernel has sent an          REMARKS
  2527.                           XOFF to the other device, FALSE otherwise. If an
  2528.                           XOFF has been sent, the port's flag will be reset.
  2529.                           You must send an XON character to the other device
  2530.                           to permit transmissions to proceed.
  2531.  
  2532.           SEE ALSO        EnableXon, XoffRecd          SEE ALSO
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.                                   LctGet function                                  LctGet function
  2540.  
  2541.  
  2542.           UNIT            LctSupp          UNIT
  2543.  
  2544.           FUNCTION        Returns an available character from the ports input          FUNCTION
  2545.                           buffer.
  2546.  
  2547.  
  2548.  
  2549.  
  2550.                                     Page 40
  2551.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2552.  
  2553.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2554.  
  2555.  
  2556.  
  2557.           DECLARATION     LctGet(CPort:integer; var Ch:byte)          DECLARATION
  2558.  
  2559.           RESULT TYPE     boolean          RESULT TYPE
  2560.  
  2561.           REMARKS         Places the next available character in the input          REMARKS
  2562.                           buffer for the port in the variable Ch. The
  2563.                           function returns a value of TRUE if there is a
  2564.                           character available, FALSE if there is no character
  2565.                           available or on an error.  The contents of Ch are
  2566.                           undefined when the return is FALSE.
  2567.                            
  2568.                           If you specified other than N (No Parity) when the
  2569.                           port was opened, you may have to reset (make zero)
  2570.                           the parity bit before you use the character.
  2571.  
  2572.           EXAMPLE         BEGIN          EXAMPLE
  2573.                             IF LctGet(CPort, Ch) THEN
  2574.                               Ch := Ch AND $7F;       (* Reset the Parity Bit
  2575.                           *)
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.                                   LctPeek function                                  LctPeek function
  2583.  
  2584.  
  2585.           UNIT            LctSupp          UNIT
  2586.  
  2587.           FUNCTION        Permits you to look at the next character in the          FUNCTION
  2588.                           ports input buffer without removing if from the
  2589.                           buffer.
  2590.  
  2591.           DECLARATION     LctPeek(CPort:integer; var Ch:byte)          DECLARATION
  2592.  
  2593.           RESULT TYPE     boolean          RESULT TYPE
  2594.  
  2595.           REMARKS         Places the next available character in the input          REMARKS
  2596.                           buffer for the specified port into the Ch variable,
  2597.                           but does not remove the character from the buffer.
  2598.                           This allows the application to look-ahead by one                                                         look-ahead                                                         __________
  2599.                           character in a nondestructive fashion. Returns
  2600.                           FALSE if the port is not active, or if there are no
  2601.                           characters in the port's buffer, TRUE otherwise.
  2602.                           The contents of Ch are undefined when the result is
  2603.                           FALSE.
  2604.                            
  2605.                           The comment made regarding parity setting and the
  2606.                           use of the LctGet function also applies to LctPeek.
  2607.  
  2608.           SEE ALSO        LctGet          SEE ALSO
  2609.  
  2610.  
  2611.  
  2612.  
  2613.  
  2614.                                     Page 41
  2615.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2616.  
  2617.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.                                   LctPut function                                  LctPut function
  2628.  
  2629.  
  2630.           UNIT            LctSupp          UNIT
  2631.  
  2632.           FUNCTION        Places a character in the port's transmit buffer to          FUNCTION
  2633.                           be sent when the port is ready.
  2634.  
  2635.           DECLARATION     LctPut(CPort:integer; Ch:byte)          DECLARATION
  2636.  
  2637.           RESULT TYPE     boolean          RESULT TYPE
  2638.  
  2639.           REMARKS         Returns TRUE if successful. Note that this does not          REMARKS
  2640.                           guarantee that the character has been sent, only
  2641.                           that no errors were detected, and there was space
  2642.                           in the transmit buffer to hold the character.
  2643.                           Returns FALSE if the port is not active, or if
  2644.                           there no room in the port's buffer.
  2645.                            
  2646.                           Characters are sent from the transmit buffer when
  2647.                           the system has the time to send them, assuming that
  2648.                           all conditions for transmission are satisfied
  2649.  
  2650.  
  2651.  
  2652.  
  2653.  
  2654.  
  2655.                                  GetStream function                                 GetStream function
  2656.  
  2657.  
  2658.           UNIT            LctSupp          UNIT
  2659.  
  2660.           FUNCTION        Gets a stream of N characters from the port's input          FUNCTION
  2661.                           buffer
  2662.  
  2663.           DECLARATION     GetStream(CPort:integer; var Buff; BCnt:integer)          DECLARATION
  2664.  
  2665.           RESULT TYPE     integer          RESULT TYPE
  2666.  
  2667.           REMARKS         Reads a stream of, at most, BCnt characters from          REMARKS
  2668.                           the serial port's input buffer into the Buff array.
  2669.                           Returns the count of characters actually
  2670.                           transferred, or -1 if an error occurs.
  2671.                            
  2672.                           NOTE that Buff is an array of characters or bytes,
  2673.                           not a string, although you may treat a string
  2674.                           variable like an array, as shown below.  The
  2675.  
  2676.  
  2677.  
  2678.                                     Page 42
  2679.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2680.  
  2681.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2682.  
  2683.  
  2684.  
  2685.                           comments made about parity in the LctGet function
  2686.                           description also apply the the GetStream function.
  2687.  
  2688.           EXAMPLE         Type          EXAMPLE
  2689.                             MaxStr = string[256];
  2690.                            
  2691.                           Var
  2692.                             StrBuff : MaxStr;
  2693.                             RecdLen : integer;
  2694.                            
  2695.                           begin
  2696.                             RecdLen := GetStream(2, StrBuff[1], 256);
  2697.                             if RecdLen <M=> 0 then     { error or no char }
  2698.                               StrBuff[0] := 0
  2699.                             else
  2700.                               StrBuff[0] := Chr(RecdLen);
  2701.                           end;
  2702.  
  2703.           SEE ALSO        LctGet          SEE ALSO
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.                                  PutStream function                                 PutStream function
  2711.  
  2712.  
  2713.           UNIT            LctSupp          UNIT
  2714.  
  2715.           FUNCTION        Places a stream of, at most, N characters in the          FUNCTION
  2716.                           port's transmit buffer.
  2717.  
  2718.           DECLARATION     PutStream(CPort:integer; var Buff; BCnt:integer)          DECLARATION
  2719.  
  2720.           RESULT TYPE     integer          RESULT TYPE
  2721.  
  2722.           REMARKS         Buff is an array of character or byte, not a          REMARKS
  2723.                           string, although it is possible to specify a string
  2724.                           variable, using the same approach as outlined for
  2725.                           the GetStream function. PutStream returns the
  2726.                           number of characters actually placed into the
  2727.                           buffer. Note that this does not guarantee that the
  2728.                           characters have been sent. A value of 0 will be
  2729.                           returned if any error occurs, or if there no room
  2730.                           in the port's buffer.
  2731.  
  2732.           EXAMPLE         VAR          EXAMPLE
  2733.                             Buff : ARRAY[1..128] OF BYTE;
  2734.                             LeftToSend : INTEGER;
  2735.                             ReallySent : INTEGER;
  2736.                             StartPos   : INTEGER;
  2737.                            
  2738.                           BEGIN
  2739.  
  2740.  
  2741.  
  2742.                                     Page 43
  2743.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2744.  
  2745.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2746.  
  2747.  
  2748.  
  2749.                             LeftToSend := 128;               (* set up for
  2750.                           Full Length *)
  2751.                           ReallySent :=  0;
  2752.                             StartPos := 1;
  2753.                             WHILE LeftToSend > 0 DO
  2754.                             BEGIN
  2755.                               ReallySent := PutStream(CPort, Buff[StartPos],
  2756.                           LeftToSend);
  2757.                               IF ReallySent > 0 THEN
  2758.                               BEGIN
  2759.                                 StartPos := StartPos + ReallySent; (* adjust
  2760.                           start byte *)
  2761.                                 LeftToSend := LeftToSend - ReallySent;
  2762.                               END;
  2763.                             END (* while *);
  2764.  
  2765.           SEE ALSO        PutStream          SEE ALSO
  2766.  
  2767.  
  2768.  
  2769.  
  2770.  
  2771.  
  2772.                              Buffer Flushing functions                             Buffer Flushing functions
  2773.  
  2774.  
  2775.           UNIT            LctSupp          UNIT
  2776.  
  2777.           FUNCTION        Provides several high level buffer management          FUNCTION
  2778.                           functions to control the contents of the port's
  2779.                           transmit and receive buffers
  2780.  
  2781.           DECLARATION     function PurgeTxBuff(CPort:integer)          DECLARATION
  2782.                            
  2783.                           function PurgeRxBuff(CPort:integer)
  2784.                            
  2785.                           procedure FlushUntilMatch(CPort:integer; Ch:byte)
  2786.                            
  2787.                           procedure FlushNBytes(CPort:integer; N:integer);
  2788.  
  2789.           RESULT TYPE     boolean for PurgeTxBuff, PurgeRxBuff          RESULT TYPE
  2790.  
  2791.           REMARKS         The PurgeRxBuff and PurgeTxBuff functions remove          REMARKS
  2792.                           all characters from the port's receive and transmit
  2793.                           buffers respectively and discard them;
  2794.                           untransmitted characters in the transmit buffer are
  2795.                           NEVER sent; unprocessed characters in the receive
  2796.                           buffer are lost. Both functions return a value of
  2797.                           TRUE if no errors were encountered, FALSE
  2798.                           otherwise.  An empty buffer is NOT considered an
  2799.                           error.
  2800.                            
  2801.                           The FlushUntilMatch procedure will continually
  2802.                           dispose of received characters until the character
  2803.  
  2804.  
  2805.  
  2806.                                     Page 44
  2807.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2808.  
  2809.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2810.  
  2811.  
  2812.  
  2813.                           Ch is received. The procedure will return when the
  2814.                           character Ch is detected, or when there are no more
  2815.                           characters in the port's input buffer.
  2816.                           The FlushNBytes procedure removes, at most, N
  2817.                           characters from the port's receive buffer.
  2818.  
  2819.  
  2820.  
  2821.  
  2822.  
  2823.  
  2824.                                  SendBreak function                                 SendBreak function
  2825.  
  2826.  
  2827.           UNIT            LctKrnl          UNIT
  2828.  
  2829.           FUNCTION        Send a true Break signal          FUNCTION
  2830.  
  2831.           DECLARATION     SendBreak(CPort:integer)          DECLARATION
  2832.  
  2833.           RESULT TYPE     boolean          RESULT TYPE
  2834.  
  2835.           REMARKS         SendBreak generates a BREAK signal using a          REMARKS
  2836.                           particular characteristic of the 8250 UART to
  2837.                           generate an accurate BREAK at any baud rate.
  2838.                           BREAKs generated in this manner are timed based
  2839.                           upon the baud rate at which the 8250 is currently
  2840.                           initialized.  This function may or may not work
  2841.                           correctly with other than the actual 8250 UART.
  2842.                            
  2843.                           Returns TRUE if successful. Returns FALSE if an
  2844.                           error is detected.
  2845.  
  2846.  
  2847.  
  2848.  
  2849.  
  2850.  
  2851.                                 CheckEvent Function                                CheckEvent Function
  2852.  
  2853.  
  2854.           UNIT            LctBBS          UNIT
  2855.  
  2856.           FUNCTION        Returns a value of TRUE is the Event Timer          FUNCTION
  2857.                           specified in the function call has not expired.
  2858.                           Returns a value of FALSE if the specified Event
  2859.                           Timer has expired.  Do not attempt to use
  2860.                           CheckEvent against a variable that was not
  2861.                           initialized bye NewEvent.  The results are
  2862.                           unpredictable, and may result in an apparent system
  2863.                           hang.
  2864.  
  2865.           DECLARATION     CheckEvent(EventVal : Event);          DECLARATION
  2866.  
  2867.  
  2868.  
  2869.  
  2870.                                     Page 45
  2871.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2872.  
  2873.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2874.  
  2875.  
  2876.  
  2877.           RESULT TYPE     boolean;          RESULT TYPE
  2878.  
  2879.           REMARKS         The event timer specified by EventVal must have          REMARKS
  2880.                           been set using the NewEvent function
  2881.  
  2882.           SEE ALSO        NewEvent          SEE ALSO
  2883.  
  2884.  
  2885.  
  2886.  
  2887.  
  2888.  
  2889.                                  NewEvent Function                                 NewEvent Function
  2890.  
  2891.  
  2892.           UNIT            LctBBS          UNIT
  2893.  
  2894.           FUNCTION        Initializes an event timer to a value suitable for          FUNCTION
  2895.                           use with CheckEvent.  The event timer created in
  2896.                           this fashion can time events up to 32767 seconds in
  2897.                           duration.
  2898.  
  2899.           DECLARATION     NewEvent(Seconds : integer);          DECLARATION
  2900.  
  2901.           RESULT TYPE     Event;          RESULT TYPE
  2902.  
  2903.           REMARKS         When used in conjunction with CheckEvent, the event          REMARKS
  2904.                           timer can be used to time events that span days,
  2905.                           months or years.  Actually, it should be termed a
  2906.                           timeout timer, since CheckEvent checks to see if
  2907.                           the period specified by Seconds has elapsed.
  2908.  
  2909.           EXAMPLE         var          EXAMPLE
  2910.                             InputEvent : Event;
  2911.                             Ch : byte;
  2912.                            
  2913.                           begin
  2914.                             InputEvent := NewEvent(15);
  2915.                             while CheckEvent(InputEvent) do
  2916.                             if LctGet(Port, Ch) then
  2917.                               exit;
  2918.                             WriteLn('No Input Received in 15 seconds');
  2919.                           end;
  2920.  
  2921.  
  2922.  
  2923.  
  2924.  
  2925.  
  2926.                                CheckForCall Function                               CheckForCall Function
  2927.  
  2928.  
  2929.           UNIT            LctBBS          UNIT
  2930.  
  2931.  
  2932.  
  2933.  
  2934.                                     Page 46
  2935.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  2936.  
  2937.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  2938.  
  2939.  
  2940.  
  2941.           FUNCTION        'Listens' to the specified port to see if the          FUNCTION
  2942.                           telephone is ringing.  If the phone is ringing,
  2943.                           waits for up to 30 seconds for a successful
  2944.                           connection to be established.
  2945.  
  2946.           DECLARATION     CheckForCall(CPort : integer);          DECLARATION
  2947.  
  2948.           RESULT TYPE     integer;          RESULT TYPE
  2949.  
  2950.           REMARKS         This function will return a value of -1 if the          REMARKS
  2951.                           phone is not ringing, or if the modem fails to
  2952.                           respond to the call within the 30 second period
  2953.                           allowed.  In all other cases the function returns
  2954.                           the result code that was returned by the modem
  2955.                           itself.  It is the programmer's responsibility to
  2956.                           correctly recognize and react to the various codes.
  2957.                           In the case of a failure of the modem to respond,
  2958.                           this function will automatically attempt to
  2959.                           disconnect and reset the modem.
  2960.                            
  2961.                           The function assumes that the modem has been set up
  2962.                           to use numeric result codes, and that the S0
  2963.                           register (number of rings before answering) has not
  2964.                           been set to zero.  The function ResetModem sets the
  2965.                           correct values to match these assumptions.  CAUTION
  2966.                           - do not attempt to use this function on ports not
  2967.                           connected to a modem.  The function examines the
  2968.                           modem control status lines and may behave in a
  2969.                           unpredictable fashion if not connected to a modem.
  2970.  
  2971.           EXAMPLE         var          EXAMPLE
  2972.                             ModemResult : integer;
  2973.                            
  2974.                           begin
  2975.                             repeat
  2976.                             ModemResult := CheckForCall(CPort);
  2977.                             if ModemResult = -1 then
  2978.                               Delay(1000);  (* settling time*)
  2979.                             until ModemResult <> -1;
  2980.                             Writeln('Modem reply to call was ',
  2981.                           ModemResult:2);
  2982.                           end;
  2983.  
  2984.           SEE ALSO        Disconnect, ResetModem          SEE ALSO
  2985.  
  2986.  
  2987.  
  2988.  
  2989.  
  2990.  
  2991.                                 Disconnect Procedure                                Disconnect Procedure
  2992.  
  2993.  
  2994.           UNIT            LctBBS          UNIT
  2995.  
  2996.  
  2997.  
  2998.                                     Page 47
  2999.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3000.  
  3001.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  3002.  
  3003.  
  3004.  
  3005.           FUNCTION        Causes the modem to disconnect from the caller.          FUNCTION
  3006.  
  3007.           DECLARATION     Disconnect(CPort : integer);          DECLARATION
  3008.  
  3009.           REMARKS         Disconnects the modem by dropping the DTR (Data          REMARKS
  3010.                           Terminal Ready) modem status signal for 1 second.
  3011.                           This action will cause most modems to drop carrier
  3012.                           and force the phone on-hook.  Please not that if
  3013.                           the modem has been optioned with DTR permanently
  3014.                           set on or ignored, this procedure will have no
  3015.                           effect.
  3016.  
  3017.  
  3018.  
  3019.  
  3020.  
  3021.  
  3022.                                 ResetModem Function                                ResetModem Function
  3023.  
  3024.  
  3025.           UNIT            LctBBS          UNIT
  3026.  
  3027.           FUNCTION        Returns the modem to a known set of parameters,          FUNCTION
  3028.                           suitable for use with the related functions in this
  3029.                           unit.  See the typed constants MODEMSET0 through
  3030.                           MODEMSET2 in the interface portion of the unit.
  3031.  
  3032.           DECLARATION     ResetModem(CPort, : integer);          DECLARATION
  3033.  
  3034.           RESULT TYPE     integer;          RESULT TYPE
  3035.  
  3036.           REMARKS         The modem is reset to a known state, including, but          REMARKS
  3037.                           not limited to 1) answer on the first ring, 2)
  3038.                           numeric result codes, 3) extended code set.  The
  3039.                           function returns the result of the reset operation
  3040.                           (a modem response code) or -1 if the modem fails to
  3041.                           respond.  This function and related functions are
  3042.                           suitable for use only with HAYES-type modems.  It
  3043.                           is the programmer's responsibility to interpret the
  3044.                           result code returned.
  3045.  
  3046.           SEE ALSO        GetModemReply          SEE ALSO
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.                                GetModemReply Function                               GetModemReply Function
  3054.  
  3055.  
  3056.           UNIT            LctBBS          UNIT
  3057.  
  3058.  
  3059.  
  3060.  
  3061.  
  3062.                                     Page 48
  3063.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3064.  
  3065.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  3066.  
  3067.  
  3068.  
  3069.           FUNCTION        Returns the modem's response to the last set of          FUNCTION
  3070.                           instructions that were issued to the modem, in
  3071.                           numeric form.
  3072.  
  3073.           DECLARATION     GetModemReply(CPort : integer);          DECLARATION
  3074.  
  3075.           RESULT TYPE     integer;          RESULT TYPE
  3076.  
  3077.           REMARKS         This function expects the modem to be returning          REMARKS
  3078.                           numeric result codes (set ResetModem) of up to 2
  3079.                           digits.  The function will react to 2 digits
  3080.                           returned or the first <CR> returned, whichever
  3081.                           occurs first within a 1 second timeout period.  In
  3082.                           the case that the modem does not respond in the
  3083.                           timeout period, the function returns a value of -1.
  3084.                           In no case does the function attempt to evaluate
  3085.                           the response...this is left to the programmer.
  3086.  
  3087.           SEE ALSO        ResetModem.          SEE ALSO
  3088.  
  3089.  
  3090.  
  3091.  
  3092.  
  3093.  
  3094.                                HAYES MODEM FUNCTIONS                               HAYES MODEM FUNCTIONS
  3095.  
  3096.  
  3097.           UNIT            LctHayes          UNIT
  3098.  
  3099.           FUNCTION        Provides support for various aspects of modems the          FUNCTION
  3100.                           support the Hayes(Tm) command set.
  3101.  
  3102.           DECLARATIONS    const          DECLARATIONS
  3103.                             NUMRES = 0     { numeric result codes}
  3104.                             WRDRES = 1     { word result codes }
  3105.                             SPKOFF = 0     { speaker off }
  3106.                             SPKON  = 1     { speaker on until CD }
  3107.                             SPKSPC = 2     { speaker always on }
  3108.                             ONHK   = 0     { go on-hook (hang up) }
  3109.                             OFFHK  = 1     { go off-hook (lift receiver) }
  3110.                             OFFHKS = 2     { go off-hook, don't close relay }
  3111.                             BASIC  = 0     { basic result set }
  3112.                             EXSET1 = 1     { extended results, set 1 }
  3113.                             EXSET3 = 2     { extended results, set 3 }
  3114.                             EXSET4 = 3     { extended results, set 4 }
  3115.                            
  3116.                           type
  3117.                             TelNumStr = string[20];
  3118.                            
  3119.                           procedure SetType(NType : byte)
  3120.                            
  3121.                           procedure SetSet(NSet : byte)
  3122.                            
  3123.  
  3124.  
  3125.  
  3126.                                     Page 49
  3127.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3128.  
  3129.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  3130.  
  3131.  
  3132.  
  3133.                           function RetType : byte
  3134.                            
  3135.                           function RetSet : byte
  3136.                            
  3137.                           function ModemCodesOn(CPort : integer):boolean
  3138.                            
  3139.                           function ModemCodesOff(CPort : integer):boolean
  3140.                            
  3141.                           function ModemWordResponse(CPort : integer):boolean
  3142.                            
  3143.                           function ModemDigitResponse(CPort :
  3144.                           integer):boolean
  3145.                            
  3146.                           function RepeatModemCommand(CPort :
  3147.                           integer):boolean
  3148.                            
  3149.                           function ModemSpeaker(CPort : integer; Mode :
  3150.                           byte):boolean
  3151.                            
  3152.                           function SetModemRegister(CPort, Reg, NValue :
  3153.                           integer) : boolean
  3154.                            
  3155.                           function GetModemRegister(CPort, Reg, NValue :
  3156.                           integer) : boolean
  3157.                            
  3158.                           function ModemHalfDuplex(CPort : integer) : boolean
  3159.                            
  3160.                           function ModemFullDuplex(CPort : integer) : boolean
  3161.                            
  3162.                           function ModemEchoCmd(CPort : integer) : boolean
  3163.                            
  3164.                           function ModemNoEchoCmd(CPort : integer) : boolean
  3165.                            
  3166.                           function ModemHookMode(CPort : integer; HMode :
  3167.                           byte) : boolean
  3168.                            
  3169.                           function ModemCarrierOn(CPort : integer) : boolean
  3170.                            
  3171.                           function ModemCarrierOff(CPort : integer) : boolean
  3172.                            
  3173.                           function ModemWordResponse(CPort : integer):boolean
  3174.                            
  3175.                           function ModemDigitResponse(CPort :
  3176.                           integer):boolean
  3177.                            
  3178.                           function RepeatModemCommand(CPort :
  3179.                           integer):boolean
  3180.                            
  3181.                           function ModemSpeaker(CPort : integer; Mode :
  3182.                           byte):boolean
  3183.                            
  3184.                           function SetModemRegister(CPort, Reg, NValue :
  3185.                           integer) : boolean
  3186.                            
  3187.  
  3188.  
  3189.  
  3190.                                     Page 50
  3191.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3192.  
  3193.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  3194.  
  3195.  
  3196.  
  3197.                           function GetModemRegister(CPort, Reg, NValue :
  3198.                           integer) : boolean
  3199.                            
  3200.                           function ModemHalfDuplex(CPort : integer) : boolean
  3201.                            
  3202.                           function ModemFullDuplex(CPort : integer) : boolean
  3203.                            
  3204.                           function ModemEchoCmd(CPort : integer) : boolean
  3205.                            
  3206.                           function ModemNoEchoCmd(CPort : integer) : boolean
  3207.                            
  3208.                           function ModemHookMode(CPort : integer; HMode :
  3209.                           byte) : boolean
  3210.                            
  3211.                           function ModemCarrierOn(CPort : integer) : boolean
  3212.                            
  3213.                           function ModemCarrierOff(CPort : integer) : boolean
  3214.                            
  3215.                           function ModemCodeSet(CPort : integer; NewSet :
  3216.                           byte) : boolean
  3217.                            
  3218.                           function ModemPulse(CPort : integer) : boolean
  3219.                            
  3220.                           function ModemTone(CPort : integer) : boolean
  3221.                            
  3222.                           function ModemDial(CPort : integer; TelNo :
  3223.                           TelNumStr) : boolean
  3224.  
  3225.           REMARKS         The ModemCodeSet function allows you to change the          REMARKS
  3226.                           set of codes that are returned by the modem when an
  3227.                           action is specified.
  3228.                            
  3229.                           ModemDial instructs the modem to dial the number
  3230.                           contained in TelNo. Do not include the dialing
  3231.                           (ATD) prefix, or the trailing <CR>. These are
  3232.                           provided by the function. You may include non-
  3233.                           numeric characters as the contents of TelNo are not
  3234.                           checked. The dialing is done in the last known,
  3235.                           pulse or tone, mode. If you use the Modempulse or
  3236.                           ModemTone functions, then dialing will be done in
  3237.                           the mode that was last correctly enabled. If you
  3238.                           have not exercised these functions, then dialing
  3239.                           occurs in the modems default or power-up mode.
  3240.                            
  3241.                           The ModemHalfDuplex and ModemFullDuplex functions
  3242.                           place the modem into local echo and remote echo
  3243.                           modes respectively.
  3244.                            
  3245.                           The GetModemRegister function requests that the
  3246.                           modem return the current value of S-register Reg.
  3247.                           Reg must be in the range 0 to 13. Use the
  3248.                           GetStream, or similar function, to retrieve the
  3249.                           modem's response. Specifying a register outside the
  3250.                           0 to 13 range will cause a return of FALSE.
  3251.  
  3252.  
  3253.  
  3254.                                     Page 51
  3255.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3256.  
  3257.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  3258.  
  3259.  
  3260.  
  3261.                            
  3262.                           SetModemRegister is the companion to
  3263.                           GetModemRegister, with the same restrictions. Sets
  3264.                           the S-register Reg to the value contained in
  3265.                           NValue. If NValue contains -1, then the register is
  3266.                           reset to its default (power-up) value. The function
  3267.                           checks the value to be certain that it is within
  3268.                           the limits specified for the particular register,
  3269.                           and returns a value of FALSE if the value is
  3270.                           outside the predefined limits.
  3271.                            
  3272.                           ModemCarrierOff enables modem carrier detect, but
  3273.                           disables the modems carrier signal. The
  3274.                           ModemCarrierOn companion enables both carrier
  3275.                           detect and the modems carrier signal. When
  3276.                           ModemCarrierOff is used the modem will receive data
  3277.                           but will be unable to send data.
  3278.                            
  3279.                           The ModemNoEchoCmd and ModemEchoCmd functions
  3280.                           determine whether commands sent to the modem are
  3281.                           echoed back to the sending program. With echo
  3282.                           turned off, the modem will continue to accept
  3283.                           commands, but will not try to redisplay the
  3284.                           command's characters.
  3285.                            
  3286.                           ModemHookMode allows you to control the current
  3287.                           status of the modem's telephone line connection.
  3288.                           See your modem's documentation and the above
  3289.                           constants for additional information.
  3290.                            
  3291.                           The ModemRepeatCommand function instructs the modem
  3292.                           to repeat the last command sequence executed.
  3293.                           Generally, this function is of greatest value in
  3294.                           redialing numbers that are busy, although its use
  3295.                           is not restricted to that.
  3296.                            
  3297.                           The way in which your modem responds to commands is
  3298.                           determined, in part, by the ModemWordResponse and
  3299.                           ModemDigitResponse functions. If you call
  3300.                           ModemWordResponse, then modem responses use the
  3301.                           English language response codes, e.g. CONNECT or
  3302.                           OK. Calling ModemDigitResponse instructs the modem
  3303.                           to respond with code numbers only from the
  3304.                           currently selected response set, see the
  3305.                           ModemCodeSet function above.
  3306.                            
  3307.                           You may use the functions ModemCodesOn and
  3308.                           ModemCodesOff to specify whether you want your
  3309.                           modem to send back response codes when it receives
  3310.                           a command string. In a sense, these act as
  3311.                           companions to the EchoCmd functions above.
  3312.                            
  3313.  
  3314.  
  3315.  
  3316.  
  3317.  
  3318.                                     Page 52
  3319.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3320.  
  3321.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  3322.  
  3323.  
  3324.  
  3325.                           Use the ModemSpeaker function to control the
  3326.                           modem's internal speaker, if it has one. See the
  3327.                           above constants for the applicable codes.
  3328.                            
  3329.                           The RetSet and RetType functions return,
  3330.                           respectively, the last known command set
  3331.                           (ModemCodeSet) and last known result type
  3332.                           (ModemWordResponse, ModemDigitResponse). The RetSet
  3333.                           and RetType  functions are only of value when used
  3334.                           in conjunction with the companion functions.
  3335.  
  3336.           GENERAL REMARKS Several considerations are in order if you intend          GENERAL REMARKS
  3337.                           to use the Hayes ToolBox functions.
  3338.  
  3339.                              1.  You are responsible for checking the return
  3340.                                  codes from the modem once you have given
  3341.                                  modem a command. To make the task easier, we
  3342.                                  suggest that you turn OFF command echo (so
  3343.                                  that you don't have to worry about
  3344.                                  separating commands from responses) and turn
  3345.                                  ON numeric responses (to make the
  3346.                                  interpretation of result codes easier and
  3347.                                  faster).
  3348.  
  3349.                              2.  Be sure that you allow  adequate time
  3350.                                  between commands for the modem to process
  3351.                                  the command and respond. Failure to observe
  3352.                                  this rule may result in commands being
  3353.                                  misinterpreted or "lost". You can monitor
  3354.                                  the number of characters in the receive
  3355.                                  buffer to help you with the timing. Or
  3356.                                  alternatively, check the response after each
  3357.                                  command. The latter approach is more in line
  3358.                                  with what we believe to be good programming
  3359.                                  practice.
  3360.  
  3361.           RETURN VALUES   All functions return a value of FALSE if a port or          RETURN VALUES
  3362.                           other error is detected, TRUE otherwise.
  3363.  
  3364.  
  3365.  
  3366.  
  3367.  
  3368.  
  3369.  
  3370.                                      Index                                     Index
  3371.  
  3372.  
  3373.               8250 7, 14                  B                                          B
  3374.               8259 19                     base port 9
  3375.                                           baud rate 10
  3376.               A                           BIOS 20              A
  3377.               ASP 1                       BIOS functions 21
  3378.                                           BREAK 13, 34, 35, 45
  3379.  
  3380.  
  3381.  
  3382.                                     Page 53
  3383.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3384.  
  3385.                    LITECOMM-TP (Tm) TOOLBOX for Turbo-PASCAL
  3386.  
  3387.  
  3388.  
  3389.               buffers 14, 29              IRQ 20
  3390.                                           irq 28
  3391.               C                           IRQ0 20              C
  3392.               character length 11         ISR 9
  3393.               CheckForCall 23
  3394.               COM3 19                     L                                          L
  3395.               COM4 19                     look-ahead 41                                          look-ahead                                          __________
  3396.               CommOpen 19
  3397.               control structures 14       M                                          M
  3398.               CTS 33                      modem control 12
  3399.                                           modem status 13
  3400.               D                           ModemStatus 23              D
  3401.               data overrun error 15
  3402.               data path 7                 O                                          O
  3403.               Data Terminal Ready         open function 14
  3404.                  See: DTR                 OUT2 12                 ____
  3405.               DCD 33
  3406.               DeltaCTS 33                 P                                          P
  3407.               DSR 33                      parallel 7
  3408.               DTR 12, 14, 31, 36, 37,     parity 11
  3409.                  38, 48                   parity error 15
  3410.                                           poll 8
  3411.               E                           PortChange 19              E
  3412.               error status bits 35
  3413.               Event Timer 45              R                                          R
  3414.               expansion cards 20          Request To Send See:                                                          ____
  3415.                                              RTS
  3416.               F                           RI 23, 33              F
  3417.               flow control 38             RTS 12, 15, 31, 36, 37,
  3418.               framing error 15               38
  3419.  
  3420.               H                           S              H                           S
  3421.               handshake 33                S-register 51
  3422.               handshaking 12, 13          serial port 7
  3423.               HAYES 48                    stream 42, 43
  3424.               heap 14, 30
  3425.                                           T                                          T
  3426.               I                           TSR 22              I
  3427.               interrupt 8
  3428.               interrupt chaining 17,      U                                          U
  3429.                  21                       UART 7
  3430.               interrupt enable flag
  3431.                  15                       V                                          V
  3432.               Interrupt Service           vector numbers 20
  3433.                  Routine 9
  3434.               interrupt vector 20         X                                          X
  3435.               interrupt vectors 19        XOFF 39
  3436.                                           XON 39
  3437.  
  3438.  
  3439.  
  3440.  
  3441.  
  3442.  
  3443.  
  3444.  
  3445.  
  3446.                                     Page 54
  3447.             Copyright (c) 1987, 88, 89 Information Technology, Ltd.
  3448.  
  3449.  
  3450.  
  3451.  
  3452.  
  3453.  
  3454.  
  3455.  
  3456.  
  3457.  
  3458.  
  3459.                                  Contents                                 Contents
  3460.  
  3461.  
  3462.  
  3463.             Chapter 1  OVERVIEW                                   1
  3464.                1.1  FEATURES . . . . . . . . . . . . . . . . . .  1
  3465.                1.2  THE SHAREWARE CONCEPT  . . . . . . . . . . .  1
  3466.  
  3467.             Chapter 2  LICENSE, WARRANTY AND REGISTRATION         3
  3468.                2.1  LICENSE  . . . . . . . . . . . . . . . . . .  3
  3469.                2.2  WARRANTY . . . . . . . . . . . . . . . . . .  4
  3470.                2.3  REGISTERING YOUR COPY  . . . . . . . . . . .  4
  3471.                2.4  NOTE . . . . . . . . . . . . . . . . . . . .  5
  3472.  
  3473.             Chapter 3  Serial Port Fundamentals                   7
  3474.                3.1  The 8250 UART family . . . . . . . . . . . .  7
  3475.                3.2  Purpose of the port  . . . . . . . . . . . .  7
  3476.                3.3  Internal Details . . . . . . . . . . . . . .  8
  3477.                   3.3.1  The Interrupt Connection  . . . . . . .  8
  3478.                   3.3.2  The Programmable Port Registers . . . .  9
  3479.                      3.3.2.1  register 0 - transmit/receive  . . 10
  3480.                      3.3.2.2  register 0 - baud rate selection . 10
  3481.                      3.3.2.3  register 1 - interrupt enable  . . 10
  3482.                      3.3.2.4  register 1 - baud rate selection . 11
  3483.                      3.3.2.5  register 2 - interrupt
  3484.                               identification . . . . . . . . . . 11
  3485.                      3.3.2.6  register 3 - line control  . . . . 11
  3486.                      3.3.2.7  register 4 - modem control . . . . 12
  3487.                      3.3.2.8  register 5 - line status . . . . . 12
  3488.                      3.3.2.9  register 6 - modem status  . . . . 13
  3489.                3.4  The LiteComm Connection  . . . . . . . . . . 13
  3490.                3.5  TOOLBOX NOTES AND WARNINGS . . . . . . . . . 14
  3491.  
  3492.             Chapter 4  LITECOMM-TP HISTORY                       17
  3493.                4.1  VERSION 3.0  . . . . . . . . . . . . . . . . 17
  3494.                4.2  NEW IN VERSION 5 . . . . . . . . . . . . . . 17
  3495.  
  3496.             Chapter 5  BEYOND COM2                               19
  3497.                5.1  THE TOOLBOX METHODOLOGY  . . . . . . . . . . 19
  3498.                5.2  CAUTIONS . . . . . . . . . . . . . . . . . . 20
  3499.                5.3  OTHER GENERAL NOTES AND WARNINGS . . . . . . 22
  3500.                5.4  USE WITH MULTITASKING ENVIRONMENTS . . . . . 22
  3501.                5.5  NOTES ON RING DETECTION  . . . . . . . . . . 23
  3502.  
  3503.             Chapter 6  PACKAGE CONTENTS                          25
  3504.                6.1  INSTALLATION INSTRUCTIONS  . . . . . . . . . 25
  3505.  
  3506.  
  3507.  
  3508.  
  3509.  
  3510.                                        i
  3511.  
  3512.  
  3513.  
  3514.  
  3515.  
  3516.  
  3517.             Chapter 7  PROCEDURE AND FUNCTION REFERENCE          27
  3518.                7.1  UNIT USAGE . . . . . . . . . . . . . . . . . 27
  3519.  
  3520.             PortChange function                                  28
  3521.  
  3522.             CommOpen function                                    29
  3523.  
  3524.             CommClose procedure                                  31
  3525.  
  3526.             CommSetup function                                   32
  3527.  
  3528.             BytesInInput function                                32
  3529.  
  3530.             ModemStatus function                                 33
  3531.  
  3532.             BreakRecd function                                   34
  3533.  
  3534.             ErrorStatus function                                 34
  3535.  
  3536.             SetModemSignals function                             36
  3537.  
  3538.             ClearModemSignals function                           37
  3539.  
  3540.             FlipModemSignals function                            37
  3541.  
  3542.             EnableXon function                                   38
  3543.  
  3544.             XoffRecd function                                    39
  3545.  
  3546.             XoffSent function                                    40
  3547.  
  3548.             LctGet function                                      40
  3549.  
  3550.             LctPeek function                                     41
  3551.  
  3552.             LctPut function                                      42
  3553.  
  3554.             GetStream function                                   42
  3555.  
  3556.             PutStream function                                   43
  3557.  
  3558.             Buffer Flushing functions                            44
  3559.  
  3560.             SendBreak function                                   45
  3561.  
  3562.             CheckEvent Function                                  45
  3563.  
  3564.             NewEvent Function                                    46
  3565.  
  3566.             CheckForCall Function                                46
  3567.  
  3568.             Disconnect Procedure                                 47
  3569.  
  3570.             ResetModem Function                                  48
  3571.  
  3572.  
  3573.  
  3574.                                       ii
  3575.  
  3576.  
  3577.  
  3578.  
  3579.  
  3580.  
  3581.             GetModemReply Function                               48
  3582.  
  3583.             HAYES MODEM FUNCTIONS                                49
  3584.  
  3585.             Index                                                54
  3586.  
  3587.  
  3588.  
  3589.  
  3590.  
  3591.  
  3592.  
  3593.  
  3594.  
  3595.  
  3596.  
  3597.  
  3598.  
  3599.  
  3600.  
  3601.  
  3602.  
  3603.  
  3604.  
  3605.  
  3606.  
  3607.  
  3608.  
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621.  
  3622.  
  3623.  
  3624.  
  3625.  
  3626.  
  3627.  
  3628.  
  3629.  
  3630.  
  3631.  
  3632.  
  3633.  
  3634.  
  3635.  
  3636.  
  3637.  
  3638.                                       iii
  3639.  
  3640.  
  3641.  
  3642.  
  3643.  
  3644.  
  3645.  
  3646.  
  3647.  
  3648.  
  3649.  
  3650.  
  3651.  
  3652.  
  3653.  
  3654.  
  3655.  
  3656.  
  3657.  
  3658.  
  3659.  
  3660.  
  3661.  
  3662.  
  3663.  
  3664.  
  3665.  
  3666.  
  3667.  
  3668.  
  3669.  
  3670.  
  3671.  
  3672.  
  3673.  
  3674.  
  3675.  
  3676.  
  3677.  
  3678.  
  3679.  
  3680.  
  3681.  
  3682.  
  3683.  
  3684.  
  3685.  
  3686.  
  3687.  
  3688.  
  3689.  
  3690.  
  3691.  
  3692.  
  3693.  
  3694.  
  3695.  
  3696.  
  3697.  
  3698.  
  3699.  
  3700.  
  3701.  
  3702.                                       iv
  3703.  
  3704.  
  3705.  
  3706.  
  3707.  
  3708.  
  3709.  
  3710.  
  3711.  
  3712.  
  3713.  
  3714.  
  3715.                                  Figures                                 Figures
  3716.  
  3717.  
  3718.             Figure 3.1: Register 1 Bit Definitions . . . . . . . 10
  3719.             Figure 3.2: Register 2 Bit Definitions . . . . . . . 11
  3720.             Figure 3.3: Register 3 Bit Definitions . . . . . . . 12
  3721.             Figure 3.4: Register 4 Bit Definitions . . . . . . . 12
  3722.             Figure 3.5: Register 5 Bit Definitions . . . . . . . 13
  3723.             Figure 3.6: Register 6 Bit Definitions . . . . . . . 13
  3724.  
  3725.  
  3726.  
  3727.  
  3728.  
  3729.  
  3730.  
  3731.  
  3732.  
  3733.  
  3734.  
  3735.  
  3736.  
  3737.  
  3738.  
  3739.  
  3740.  
  3741.  
  3742.  
  3743.  
  3744.  
  3745.  
  3746.  
  3747.  
  3748.  
  3749.  
  3750.  
  3751.  
  3752.  
  3753.  
  3754.  
  3755.  
  3756.  
  3757.  
  3758.  
  3759.  
  3760.  
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.                                        v
  3767.  
  3768.  
  3769.  
  3770.  
  3771.  
  3772.  
  3773.  
  3774.  
  3775.  
  3776.  
  3777.  
  3778.  
  3779.  
  3780.  
  3781.  
  3782.  
  3783.  
  3784.  
  3785.  
  3786.  
  3787.  
  3788.  
  3789.  
  3790.  
  3791.  
  3792.  
  3793.  
  3794.  
  3795.  
  3796.  
  3797.  
  3798.  
  3799.  
  3800.  
  3801.  
  3802.  
  3803.  
  3804.  
  3805.  
  3806.  
  3807.  
  3808.  
  3809.  
  3810.  
  3811.  
  3812.  
  3813.  
  3814.  
  3815.  
  3816.  
  3817.  
  3818.  
  3819.  
  3820.  
  3821.  
  3822.  
  3823.  
  3824.  
  3825.  
  3826.  
  3827.  
  3828.  
  3829.  
  3830.                                       vi
  3831.  
  3832.  
  3833.  
  3834.  
  3835.  
  3836.  
  3837.  
  3838.  
  3839.  
  3840.  
  3841.  
  3842.  
  3843.                                   Tables                                  Tables
  3844.  
  3845.  
  3846.             Table 3.1: Possible Error Conditions . . . . . . . . 15
  3847.             Table 5.1: COM3 and COM4 Default Settings  . . . . . 19
  3848.             Table 6.1: Basic Diskette Contents . . . . . . . . . 25
  3849.  
  3850.  
  3851.  
  3852.  
  3853.  
  3854.  
  3855.  
  3856.  
  3857.  
  3858.  
  3859.  
  3860.  
  3861.  
  3862.  
  3863.  
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.  
  3876.  
  3877.  
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.  
  3884.  
  3885.  
  3886.  
  3887.  
  3888.  
  3889.  
  3890.  
  3891.  
  3892.  
  3893.  
  3894.                                       vii
  3895.