home *** CD-ROM | disk | FTP | other *** search
/ Shareware 1 2 the Maxx / sw_1.zip / sw_1 / PROGRAM / PCL4C30.ZIP / PCL4C.USR < prev    next >
Text File  |  1992-01-27  |  56KB  |  1,651 lines

  1.  
  2.                       Personal Communications Library
  3.  
  4.                            For the C Language
  5.  
  6.  
  7.                                ( PCL4C )
  8.  
  9.  
  10.  
  11.  
  12.                       USERS MANUAL
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.                               Version 3.0
  20.  
  21.                               Jan 15, 1992
  22.  
  23.  
  24.  
  25.                     This software is provided as-is.
  26.               There are no warranties, expressed or implied.
  27.  
  28.  
  29.  
  30.  
  31.                             Copyright (C) 1992
  32.                             All rights reserved
  33.  
  34.  
  35.  
  36.  
  37.                            MarshallSoft Computing, Inc.
  38.                            Post Office Box 4543
  39.                            Huntsville AL 35815
  40.  
  41.                            Phone (205) 881-4630
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.       PCL4C Users Manual                                      Page 1
  63.  
  64.  
  65.  
  66.  
  67.                              Table of Contents
  68.  
  69.  
  70.  
  71.  
  72.  
  73.        Chapter                                           Page
  74.  
  75.        Introduction.........................................3
  76.        Registration.........................................4
  77.        Library Overview.....................................5
  78.           Initialization & Termination......................5
  79.           Configuration.....................................5
  80.           Modem Control & Status............................6
  81.           Serial I/O........................................6
  82.           Error Detection...................................7
  83.           General Support...................................7
  84.        Library Memory Models................................8
  85.        Compilers Supported..................................9
  86.        Installation........................................10
  87.        Using the Library...................................11
  88.        Compiling & Linking.................................12
  89.        Talking to your Modem...............................13
  90.        Problems............................................14
  91.        Function Summary....................................15
  92.        Serial Communications...............................16
  93.        IBM Communications Ports............................17
  94.        RS232 Signals.......................................18
  95.        National INS8250 UART...............................19
  96.        Register Summary....................................20
  97.        Example Code........................................22
  98.           SIMPLE...........................................22
  99.           INTERCOM.........................................22
  100.           MODEM............................................22
  101.           NORESET..........................................22
  102.           TERM.............................................23
  103.           XFER.............................................23
  104.           LOOPBACK.........................................23
  105.           BBS..............................................23
  106.        Revision History....................................24
  107.        License.............................................25
  108.        Warranty............................................25
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.       PCL4C Users Manual                                      Page 2
  129.  
  130.  
  131.  
  132.  
  133.                              Introduction
  134.  
  135.  
  136.  
  137.        The  Personal  Communications Library for the C Language ( PCL4C )
  138.        is an asynchronous communications library designed for experienced
  139.        software  developers  programming  in  C.   Four   compilers   are
  140.        supported:  Microsoft  Optimizing  C,  Microsoft  Quick C, Borland
  141.        Turbo C, and MIX Power  C.   An  IBM  PC/XT/AT  or  compatible  is
  142.        required.  The PCL features:
  143.  
  144.           o  SMALL, COMPACT, MEDIUM & LARGE memory models.
  145.           o  29 communications and support functions.
  146.           o  Interrupt driven receiver.
  147.           o  Supports 300 baud to 115,200 baud.
  148.           o  Supports COM1, COM2, COM3, and COM4.
  149.           o  Adjustable receive queues from 8 bytes to 16 KB.
  150.           o  Control-BREAK error exit.
  151.           o  17 communications error conditions trapped.
  152.           o  Allows 2 ports to run concurrently.
  153.           o  Complete modem control & status.
  154.           o  Written in assembly language for small size & high speed.
  155.  
  156.        A  typical  application  program  using  PCL4C might look like the
  157.        following code outline:
  158.  
  159.  
  160.           +-------------------------------------------------------+
  161.           | #include "pcl4c.h"                                    |
  162.           |                                                       |
  163.           | char Buffer[1024];                                    |
  164.           | main()                                                |
  165.           | {/* initialize serial comm system */                  |
  166.           |  SioRxBuf(Port,Buffer,Size1024);                      |
  167.           |  SioParms(Port,NoParity,OneStopBit,WordLength8);      |
  168.           |  SioReset(Port,Baud2400);                             |
  169.           |                                                       |
  170.           |  ...application code...                               |
  171.           |                                                       |
  172.           |  /* terminate serial comm system */                   |
  173.           |  SioDone(Port);                                       |
  174.           | }                                                     |
  175.           +-------------------------------------------------------+
  176.  
  177.  
  178.        In the above example, SioRxBuf is called to set up the a 1024 byte
  179.        receive  buffer; SioParms is called to set up the parity, stop bit
  180.        count, and word length; SioReset is called to set the baud rate to
  181.        2400 and  reset  the  UART  (  Univeral  Asynchronous  Receiver  /
  182.        Transmitter ).
  183.  
  184.        Before  leaving your application, SioDone is called to restore the
  185.        prior state of the serial communications system.
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.       PCL4C Users Manual                                      Page 3
  195.  
  196.  
  197.  
  198.  
  199.                              Registration
  200.  
  201.  
  202.  
  203.        The  shareware  version  of  PCL4C.LIB is provided so that you may
  204.        personally determine the usefulness of the product  for  yourself.
  205.        If  you  can use the Personal Communications Library for C, please
  206.        register your use with us. Send $45 plus $3 S&H (  $6  outside  of
  207.        the USA, Canada, and Mexico ) to:
  208.  
  209.                 MarshallSoft Computing, Inc.
  210.                 Post Office Box  4543
  211.                 Huntsville AL 35815
  212.  
  213.        Please pay by check in US dollars drawn on a US bank. Payment must
  214.        accompany  purchase orders. Print the file PCL4C.INV if an invoice
  215.        is needed. The registered package is mailed first  class  US  Mail
  216.        and includes:
  217.  
  218.           o  Small, Compact, Medium & Large memory model libraries without
  219.              the shareware screens.
  220.           o  Assembler source code for the library.
  221.           o  Printed Users Manual.
  222.           o  Printed Reference Manual.
  223.           o  Telephone support for one year.
  224.           o  All updates ( with printed manuals ) are $15  plus  $3  S&H
  225.              ( $6 outside of USA, Canada, & Mexico ).
  226.  
  227.        PCL4C.ASM is the source code for the library. The source  code  is
  228.        copyrighted  by MarshallSoft Computing, Inc. The user is granted a
  229.        license to use the PCL4C object code in his own application  only.
  230.        PCL4C.ASM  is  not  shareware and may not be sold or given away to
  231.        anyone.
  232.  
  233.        The  registered  user  will receive the latest version of PCL4C by
  234.        return mail.  A 5.25" diskette is provided unless a 3.5"  diskette
  235.        is requested.
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.       PCL4C Users Manual                                      Page 4
  261.  
  262.  
  263.  
  264.  
  265.                              Library Overview
  266.  
  267.  
  268.  
  269.        The  PCL4C  library is organized into six categories of functions.
  270.        Refer to the PCL Reference Manual ( PCL4C.REF  )  for  details  on
  271.        individual functions.
  272.  
  273.  
  274.                         1. Initialization & Termination
  275.  
  276.  
  277.        There are five functions in  the  initialization  and  termination
  278.        category.   Together,  SioParms, SioRxBuf, and SioReset initialize
  279.        your serial communications system.   Your  application  must  call
  280.        SioParms  and  SioRxBuf before calling SioReset, and SioReset must
  281.        be called before any serial I/O processing can be done.
  282.  
  283.        After initialization, SioParms and SioBaud can be called again  to
  284.        change  the communications parameters without resetting the serial
  285.        port.
  286.  
  287.        Before  exiting  from  your  application,  SioDone must be called.
  288.        Failure to call SioDone can crash your system later.
  289.  
  290.        SioRxBuf   -- Sets up receive buffer.
  291.        SioParms   -- Sets parity, stop bits, and word length.
  292.        SioReset   -- Initialize a serial port for processing.
  293.        SioDone    -- Terminates further serial processing.
  294.        SioBaud    -- Sets the baud rate of the selected port.
  295.  
  296.  
  297.                         2.  Configuration
  298.  
  299.  
  300.        SioUART  is the only function in the configuration category. It is
  301.        used to change the UART base address for a communications port  at
  302.        a  non-standard  address Note however, that IRQ4 is still used for
  303.        ports COM1 and COM3, while IRQ3 is still used for ports  COM2  and
  304.        COM4.  ( See the chapter IBM Communications Ports for more details
  305.        on standard UART addresses and IRQ lines ).
  306.  
  307.        SioUART  can also be used to set the UART base address to zero for
  308.        non-existant ports. For example, if you don't have COM4  installed
  309.        in your computer ( SioLoopBack will return an error ), use SioUART
  310.        to zero the UART address for COM4:
  311.  
  312.        SioUart(COM4,0)
  313.  
  314.        Then,  any subsequent attempt to reset COM4 will result in a "UART
  315.        undefined" message - reminding you that you don't have COM4.
  316.  
  317.  
  318.        SioUART -- Sets the UART base address.
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.       PCL4C Users Manual                                      Page 5
  327.  
  328.  
  329.  
  330.  
  331.                         3. Modem Control & Status
  332.  
  333.  
  334.        There  are  seven  functions  in  the  modem  control  and  status
  335.        category which provide your application with complete control over
  336.        the status and control bits of your modem.
  337.  
  338.        There are two modem control bits, "Data Terminal Ready"  (  DTR  )
  339.        and  "Request  To  Send"  ( RTS ). These bits can be read, set, or
  340.        cleared by SioDTR and SioRTS.
  341.  
  342.        There are four modem status bits, "Data Set Ready" ( DSR ), "Clear
  343.        To Send" ( CTS ), "Ring Indicator"  (  RI  ),  and  "Data  Carrier
  344.        Detect"  (  DCD ). SioModem can read any of the modem status bits.
  345.        SioDSR, SioCTS, SioRI, and SioDCD can only read  their  respective
  346.        modem status bit.
  347.  
  348.        Refer to the chapter entitled "RS232 Signals" for a discussion  of
  349.        each of the control and status bits.
  350.  
  351.        SioDTR    -- Set, clear, or read the Data Terminal Ready (DTR) bit.
  352.        SioRTS    -- Sets, clears, or reads the Request to Send (RTS) line.
  353.        SioModem  -- Reads the modem status register.
  354.        SioDSR    -- Reads the Data Set Ready (DSR) modem status bit.
  355.        SioCTS    -- Reads the Clear to Send (CTS) modem status bit
  356.        SioDCD    -- Reads the Data Carrier Detect (DCD) modem status bit.
  357.        SioRI     -- Reads the Ring Indicator (RI) modem status bit.
  358.  
  359.  
  360.                         4. Serial I/O
  361.  
  362.  
  363.        There are six  library  functions  in  the  serial  I/O  category.
  364.        Together,  these  functions  give  the programmer complete control
  365.        over serial I/O.  Higher level functions  such  as  protocols  and
  366.        smart  modem communications can be completely implemented in terms
  367.        of these functions. Refer to the example code.
  368.  
  369.        SioGetc  and SioPutc perform all the actual serial I/O.  SioUnGetc
  370.        and SioRxFlush modify the receive queue. SioLine can  be  used  to
  371.        test for UART errors.
  372.  
  373.        SioGetc    -- Reads the next character from the serial line.
  374.        SioPutc    -- Transmit a character over a serial line.
  375.        SioUnGetc  -- "Un-gets" (puts back) a specified character.
  376.        SioRxFlush -- Flush ( clears) the receive buffer.
  377.        SioRxQue   -- Returns the number of characters in the receive queue.
  378.        SioLine    -- Reads the line status register.
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.       PCL4C Users Manual                                      Page 6
  393.  
  394.  
  395.  
  396.  
  397.                         5.  Error Detection
  398.  
  399.  
  400.  
  401.        There are four functions in the error detection category. They are
  402.        concerned with detecting or reporting communications errors.   Use
  403.        of  these  functions  can make your application significantly more
  404.        robust.
  405.  
  406.        SioBrkKey  can  be  used  as  an  "emergency"   exit   from   your
  407.        application. SioBrkSig can read or modify the UART break bit. This
  408.        is  useful for signalling the remote system that a fatal condition
  409.        has occurred. SioLoopBack can be used to  test  the  integrity  of
  410.        your  UART.  SioError displays a error message corresponding to an
  411.        error  code  returned from a PCL4C function ( every PCL4C function
  412.        returns a code ).
  413.  
  414.        SioBrkKey -- Returns non-zero if the Control-BREAK key was pressed
  415.        SioBrkSig -- Asserts, cancels, or detects  BREAK  signal.
  416.        SioError  -- Displays  error  in  text.
  417.        SioLoopBack -- Performs a UART loopback test.
  418.  
  419.  
  420.                         6.  General Support
  421.  
  422.  
  423.        There are six functions in the general support category.  Strictly
  424.        speaking, they are not communications functions but  are  provided
  425.        in  the  PCL4C  library  because  they  are not always available (
  426.        especially in some older compiler run-time libraries  ).   At  any
  427.        rate,  they  take  up  a  very  small amount of additional memory.
  428.        Registered users can also remove these functions from the  library
  429.        if needed.
  430.  
  431.        SioCrtWrite -- Write character to the screen.
  432.        SioDelay    -- Delays one or more tics.
  433.        SioKeyPress -- Detects if keyboard has been pressed.
  434.        SioKeyRead  -- Reads the keyboard.
  435.        SioTimer    -- Returns the number of system clock tics.
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.       PCL4C Users Manual                                      Page 7
  459.  
  460.  
  461.  
  462.  
  463.                              Library Memory Models
  464.  
  465.  
  466.  
  467.        Because of the segmented architecture of the INTEL CPU, there  are
  468.        four  memory  organizations possible for computer programs.  These
  469.        are named the SMALL, COMPACT, MEDIUM,  and  LARGE  memory  models,
  470.        which  correspond  to  the  four  combinations of "near" and "far"
  471.        addresses for code and data.
  472.  
  473.        Each  executable  is  composed of one or more segments, where each
  474.        segment can occupy from one byte to 64  KB  of  memory.  A  "near"
  475.        address  is  a 16 bit offset in a segment, whereas a "far" address
  476.        consists of both a 16 bit segment value and a 16 bit offset.
  477.  
  478.        In  the small memory model, code and data each occupy one segment.
  479.        Thus, near addresses are allocated for both code and data.
  480.  
  481.        In  the compact memory model, code occupies one segment while data
  482.        may occupy multiple segments. Near  addresses  are  allocated  for
  483.        code but far addresses are allocated for data.
  484.  
  485.        In  the  medium memory model, data occupies one segment while code
  486.        may occupy multiple segments. Near  addresses  are  allocated  for
  487.        data but far addresses are allocated for code.
  488.  
  489.        In the large memory model, data  and  code  each  occupy  multiple
  490.        segments.  Far  addesses  are  allocated  for  both code and data.
  491.        Thus, both code and data can use as many segments as required.
  492.  
  493.        Refer to your compiler manual  for  a  discussion  of  the  memory
  494.        models supported by your compiler.
  495.  
  496.        PCL4C is organized  as  four  separate  libraries  (  PCL4C_S.LIB,
  497.        PCL4C_C.LIB,  PCL4C_M.LIB  and  PCL4C_L.LIB ) corresponding to the
  498.        four standard memory models.  For the MIX Power  C  compiler,  the
  499.        small,  medium,  and  large  models  are  provided  ( PCL4C_S.MIX,
  500.        PCL4C_M.MIX and PCL4C_L.MIX ).  MIX doesn't  support  the  compact
  501.        memory model.
  502.  
  503.  
  504.        MODEL      CODE      DATA     Library
  505.        Small      Near      Near     PCL4C_S.LIB & PCL4C_S.MIX
  506.        Compact    Near      Far      PCL4C_C.LIB
  507.        Medium     Far       Near     PCL4C_M.LIB & PCL4C_M.MIX
  508.        Large      Far       Far      PCL4C_L.LIB & PCL4C_L.MIX
  509.  
  510.  
  511.        However,  one  can  always  use  the  large  memory  model library
  512.        PCL4C_L.LIB with any memory model application code  by  explicitly
  513.        declaring  the  PCL4C  procedures  to  be FAR ( by prefixing "far"
  514.        before the name of  each  function  in  the  PCL4C.H  file  )  and
  515.        declaring  your receive buffer to be FAR. This was the method used
  516.        in early versions of PCL4C.
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.       PCL4C Users Manual                                      Page 8
  525.  
  526.  
  527.  
  528.  
  529.                              Compilers Supported
  530.  
  531.  
  532.  
  533.        At  this  time,  four  compilers  are  supported by PCL4C.
  534.  
  535.        (1)  Microsoft Optimizing C Compiler
  536.  
  537.        (2)  Microsoft Quick C Compiler
  538.  
  539.        (3)  Borland Turbo C Compiler
  540.  
  541.        (4)  MIX Power C Compiler
  542.  
  543.        The  Microsoft  Optimizing  C Compiler supports all memory models.
  544.        Just be careful to link with the PCL4C library that corresponds to
  545.        the memory model used. Recall that the small memory model  is  the
  546.        default.   Examine  the  (  small  model ) makefiles *._M_ for the
  547.        Microsoft compiler.
  548.  
  549.        The Microsoft Quick C Compiler supports all memory models, but  be
  550.        careful  to  link with the PCL4C library that corresponds with the
  551.        memory model used.  Recall that the  small  memory  model  is  the
  552.        default  for  the  command  line compiler ( QCL ) while the medium
  553.        memory  model  is  the  default  for  the   interactive   compiler
  554.        environment.   Examine the ( small model ) makefiles *._Q_ for the
  555.        Microsoft Quick C compiler.
  556.  
  557.        The  Borland Turbo C Compiler also supports all memory models.  Be
  558.        sure to link with the correct PCL4C library corresponding  to  the
  559.        memory  model  used.  Examine the ( small model ) makefiles *._T_
  560.        for the Turbo C compiler.
  561.  
  562.        The MIX Power C Compiler supports the  small,  medium,  and  large
  563.        memory models. However, older versions of Power C only support the
  564.        small  model.   Examine  the  (  small model ) project batch files
  565.        X_*.BAT for the Power C Compiler.
  566.  
  567.        Other compilers may also work  with  one  or  more  of  the  PCL4C
  568.        libraries  but  have  not been tested. Since registered users have
  569.        the source code to the library, it  should  not  be  difficult  to
  570.        modify PCL4C for use with any MSDOS C compiler.
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.       PCL4C Users Manual                                      Page 9
  591.  
  592.  
  593.  
  594.  
  595.                              Installation
  596.  
  597.  
  598.  
  599.        (1) Before installation of PCL4C , your C compiler should  already
  600.        be  installed  on  your system and tested. If you are not familiar
  601.        with makefiles, refer to your compiler manual. If  you  are  using
  602.        the  interactive  environment  for  Quick C or Turbo C, be sure to
  603.        compile with the memory model corresponding to the  PCL4C  library
  604.        used.  Examine  the  file  "FILES.LST"  for  a  list  of  all  the
  605.        distribution files.
  606.  
  607.        (2) Make a backup  copy  of  your  distribution  disk.   Put  your
  608.        original distribution disk in a safe place.
  609.  
  610.        (3)  Create  a  work  directory  on your work disk ( normally your
  611.        harddisk ). For example, to create a work directory  named  PCL4C,
  612.        we first log onto the work disk and then type:
  613.  
  614.                              MKDIR PCL4C
  615.  
  616.        (4)  Copy  all the files from your backup copy of the distribution
  617.        disk to your work directory.  For example, to  copy  from  the  A:
  618.        drive to your work directory, we type:
  619.  
  620.                             CD PCL4C
  621.                             COPY A:*.*
  622.  
  623.        (5) [OPTIONAL] Delete the  makefiles  that  you  won't  need.  For
  624.        example,  if  you  use  the Microsoft C compiler, then you want to
  625.        keep all makefiles ending *._M_ but can delete those for Turbo C (
  626.        *._T_ ), Quick C ( *._Q_ ), and MIX Power C ( X_*.BAT ).  You  may
  627.        also delete any libraries that you won't need.
  628.  
  629.        (6) Compile SIMPLE.C and link with the appropriate PCL4C library (
  630.        PCL4C_SM.LIB for all but Power C  which  must  use  PCL4C_S.MIX  ).
  631.        Makefiles  (  or  project  files  )  are  provided for each of the
  632.        supported compilers.
  633.  
  634.            a) Microsoft C: Type  MAKE SIMPLE._M_
  635.  
  636.            b) Microsoft Quick C: Type  MAKE SIMPLE._Q_
  637.  
  638.            c) Borland Turbo C: Type  MAKE -FSIMPLE._T_
  639.  
  640.            d) MIX Power C: Type X_SIMPLE
  641.  
  642.        SIMPLE.C  should  compile without any problems as all example code
  643.        has been tested with each of the supported compilers.
  644.  
  645.        (7) The recommended way to  test  SIMPLE  is  to  run  it  on  two
  646.        computers  connected  by a null modem cable.  Whatever is typed on
  647.        one computer should be displayed on the other.
  648.  
  649.        (8) Compile and run each of the remaining example programs.
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.       PCL4C Users Manual                                      Page 10
  657.  
  658.  
  659.  
  660.  
  661.                              Using the Library
  662.  
  663.  
  664.  
  665.        The  PCL4C  has been tested on a TANDY 1000 ( 4.77 MHZ 8088 IBM PC
  666.        clone ), a TANDY 3000 ( 80286 IBM AT clone ), a TANDY 1400LT ( IBM
  667.        XT clone ), and a Gateway 2000 Cache ( 25 MHZ  80386-DX  ).  PCL4C
  668.        has been tested under MSDOS 2.11, 3.2, 3.3, 4.01, and 5.0.
  669.  
  670.        Please examine the PCL4C.H file. Note that COM1 is defined as port
  671.        zero,  not  port  one.  The user must assume the responsibilty for
  672.        passing the correct  information  when  calling  PCL4C  functions.
  673.        Note  that  function  prototypes are provided in PCL4C.  But since
  674.        some  earlier  C  compilers  don't  support  function  prototypes,
  675.        PCL4C.H can be modified for no prototypes by changing the line
  676.  
  677.             #define PROTOTYPES 1
  678.  
  679.        to
  680.  
  681.             #define PROTOTYPES 0
  682.  
  683.        For an example of PCL4C use, examine the terminal emulator program
  684.        SIMPLE.C.  The user should compile and link SIMPLE.C as a test  of
  685.        the library.
  686.  
  687.        If you have two computers, then you can connect them together with
  688.        a  null  modem  cable  and  run  SIMPLE  or TERM on both machines.
  689.        Whatever is typed on one machine should appear on the  other,  and
  690.        vice versa.
  691.  
  692.        If you have a modem, use TERM to call up any bulletin board system
  693.        ( BBS ). Be sure to set the Hayes constant
  694.  
  695.           #define HAYES 1
  696.  
  697.        in  the source code so that TERM sends an initialization string to
  698.        your modem.
  699.  
  700.        There are many free BBSs around the country. Look in any issue  of
  701.        "Computer  Shopper" ( available in bookstores, computer shops, and
  702.        many grocery stores ) for a list of current systems.
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.       PCL4C Users Manual                                      Page 11
  723.  
  724.  
  725.  
  726.  
  727.                              Compiling and Linking
  728.  
  729.  
  730.  
  731.        Registered  users  may  wish  to  assemble PCL4C.ASM.  Use the /MX
  732.        switch in order to disable automatic conversion from lower case to
  733.        upper case.  If the  /MX  switch  is  not  used,  then  all  PCL4C
  734.        function  references  in C code must be in upper case. To assemble
  735.        using the Microsoft assembler:
  736.  
  737.        Model    Command
  738.  
  739.        Small    MASM PCL4C /DSMALL_MODEL /MX;
  740.        Compact  MASM PCL4C /DCOMPACT_MODEL /MX;
  741.        Medium   MASM PCL4C /DMEDIUM_MODEL /MX;
  742.        Large    MASM PCL4C /DLARGE_MODEL /MX;
  743.  
  744.        To make the (small) model PCL4C.OBJ into a library file:
  745.  
  746.              DEL PCL4C_S.LIB
  747.              LIB PCL4C_S.LIB+PCL4C,PCL4C.MAP;
  748.  
  749.        If  you  are using the MIX Power C Compiler, create the MIX object
  750.        file ( you will need version 1.3 of MIX which has the /_ switch ):
  751.  
  752.              MIX /_ PCL4C_S
  753.  
  754.        Similarly with the other memory  model  libaries.  See  the  batch
  755.        files MAKE_S.BAT, MAKE_C.BAT, MAKE_M.BAT, and MAKE_L.BAT.
  756.  
  757.        To compile and link (small model) using Microsoft C:
  758.  
  759.              cl /AS simple.c /link pcl4c_s.lib
  760.  
  761.        To compile and link (small model) using Microsoft Quick C:
  762.  
  763.              qcl /AS simple.c /link pcl4c_s.lib
  764.  
  765.        To compile and link (small model) using Turbo C:
  766.  
  767.              tcc -ms simple.c pcl4c_s.lib
  768.  
  769.        To compile and link (small model) using Power C:
  770.  
  771.              pc /ms simple.c
  772.              pcl simple pcl4c_s.mix
  773.  
  774.        Makefiles or project files are  provided  for  all  example  code.
  775.        Turbo  C  makefiles  end  with  the  extension '._T_', Microsoft C
  776.        makefiles end with '._M_', Microsoft Quick C makefiles  files  end
  777.        with  '._Q_',  and Power C project batch files start with 'X_' and
  778.        end with '.BAT'.
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.       PCL4C Users Manual                                      Page 12
  789.  
  790.  
  791.  
  792.  
  793.                              Talking To Your Modem
  794.  
  795.  
  796.  
  797.        If your application uses a Modem ( as  opposed  to  using  a  null
  798.        modem  cable  ),  then  you  should  always send an initialization
  799.        string to your modem if it is a programmable modem such  as  those
  800.        made  by  Hayes.  Communication programs such as PROCOMM and TELIX
  801.        always send such a string automatically as soon as they start up.
  802.  
  803.        The particular initialization string depends on the make  of  your
  804.        modem.   For  Hayes  and  Hayes  compatible  modems, the following
  805.        string ( followed by a carriage return ) should work:
  806.  
  807.             AT E1 S7=60 S11=60 V1 X1 Q0 S0=0
  808.  
  809.        Refer to your Hayes User's Guide for a full  discussion  of  these
  810.        commands. A brief description is as follows:
  811.  
  812.        AT     Modem attention command.
  813.        E1     Modem will echo what you send to it.
  814.        S7=60  Wait 60 seconds for carrier and/or dial tone.
  815.        S11=60 Use 60 milliseconds for tone dialing duration & spacing.
  816.        V1     Display result code as words ( not numbers ).
  817.        X1     Use the extended result message ( CONNECT XXXX ) set.
  818.        Q0     Modem returns result codes.
  819.        S0=0   Do not answer RING.
  820.  
  821.        If your application will answer incoming calls, then  set  the  S0
  822.        register to the ring on which to automatically answer.
  823.  
  824.        If  you  send  the  above  codes  by using SioPutc ( as opposed to
  825.        typing them from the keyboard ), then follow these guidelines:
  826.  
  827.        (1) Send an initial  carriage  return  before  the  initialization
  828.        string.
  829.  
  830.        (2) Pause at least two tics ( 18 tics to the second )  after  each
  831.        character  sent  as  your  modem needs the time to perform its own
  832.        internal processing.  Pause a little longer if your modem  is  not
  833.        accepting your initialization string.
  834.  
  835.        (3) Pause one and a half seconds after sending any  initialization
  836.        command  such  as ATZ or AT&F since your modem must do quite a bit
  837.        of processing.
  838.  
  839.        If you experience any problems in initializing your  Hayes  modem,
  840.        you should first reset it to factory settings by sending:
  841.  
  842.             AT&F
  843.  
  844.        Refer  to  the  TERM program ( functions SendTo and WaitFor in the
  845.        file MODEM_IO.C ) for an  example  of  sending  an  initialization
  846.        string to a Hayes compatible modem.
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.       PCL4C Users Manual                                      Page 13
  855.  
  856.  
  857.  
  858.  
  859.                              Problems
  860.  
  861.  
  862.  
  863.        If  you cannot get your application to run properly, first compile
  864.        and run the  terminal  emulator  program  TERM  provided  on  your
  865.        distribution  disk.   If  you  are  using  a null modem cable or a
  866.        non-programmable modem, be sure to set the HAYES constant to 0  in
  867.        the  source  code  (  #define HAYES 0 ).  If you are using a Hayes
  868.        compatible modem, set the HAYES constant to 1. If you are using  a
  869.        programmable  modem  which  is not Hayes compatible, then you must
  870.        modify the initialization string for your particular modem.
  871.  
  872.        If your application does not run but TERM runs correctly, then you
  873.        have  most  likely made a programming mistake in your application.
  874.        MarshallSoft Computing cannot debug your  application,  especially
  875.        over  the telephone!  However, consider each of the following when
  876.        searching for an error in your application.
  877.  
  878.        1.  Have you included the file PCL4C.H in your application ?
  879.  
  880.        2.  Did you link with the correct PCL4C library  ?   This  is  the
  881.            most probable cause if your application 'hangs' as soon as  it
  882.            starts and you must reboot. The  function  SioModel()  returns
  883.            the   model   ID   under  which  the  library  was  assembled.
  884.            SioModel()  return  0  for small, 1 for compact, 2 for small,
  885.            and 3 for large.
  886.  
  887.        3.  Is your receive buffer large enough ? If you are using 1K data
  888.            blocks in YMODEM, then your receive buffer should be at  least
  889.            1K ( 2K if baud rates above 38400 are to be used ).
  890.  
  891.        4.  Have you selected too high a baud rate ( if you  are  using  a
  892.            slow PC ) ?  If only one COM port is being run, you should  be
  893.            able to run at 38400 baud on 8088 machines and 115200 on  most
  894.            286 and all 386 and 486 machines.
  895.  
  896.        5.  Are  you  attempting  to  run  another  application   in   the
  897.            background ?  Try running  without any other programs  running
  898.            in the background ( unload all TSR programs ).
  899.  
  900.        6.  If you are running two COM ports simultaneously, are you using
  901.            separate receive buffers ? ( you should ).
  902.  
  903.        7.  Did SioReset return a zero value ?  If not, then you must call
  904.            SioReset again. See TERM.C for an example.
  905.  
  906.        8.  Did you send the proper initialization string to your modem ?
  907.  
  908.        9.  Do you have more than one COM1 port, etc.  For example, if you
  909.            have a COM1 port on your motherboard,  you cannot add  another
  910.            COM1  port  or  modem  board  that  uses  COM1  without  first
  911.            disabling the COM1 on the motherboard.
  912.  
  913.        If TERM does not run, then either there is a  physical  connection
  914.        problem  or  your computer isn't as compatible as you thought !
  915.  
  916.        Registered  users  can call (205) 881 - 4630 from 5 PM to 8 PM CST
  917.        Monday through Friday for help.
  918.  
  919.  
  920.       PCL4C Users Manual                                      Page 14
  921.  
  922.  
  923.  
  924.  
  925.                              Function Summary
  926.  
  927.  
  928.  
  929.        Refer to the PCL4C Reference Manual (  PCL4C.REF  )  for  detailed
  930.        information  on  the  communications  and support functions. A one
  931.        line summary of each function follows:
  932.  
  933.  
  934.        SioBaud     Sets the baud rate of the selected port.
  935.        SioBrkKey   Returns non-zero if the Control-BREAK key was pressed.
  936.        SioBrkSig   Asserts, cancels, or detects BREAK signal.
  937.        SioCrtWrite Write character to the screen.
  938.        SioCTS      Reads the Clear to Send (CTS) modem status bit.
  939.        SioDCD      Reads the Data Carrier Detect (DCD) modem status bit.
  940.        SioDelay    Delays one or more tics ( 18 tics per second ).
  941.        SioDone     Terminates further serial processing.
  942.        SioDSR      Reads the Data Set Ready (DSR) modem status bit.
  943.        SioDTR      Set, clear, or read the Data Terminal Ready (DTR) bit.
  944.        SioError    Displays error in text.
  945.        SioGetc     Reads the next character from the serial line.
  946.        SioKeyPress Detects if keyboard has been pressed.
  947.        SioKeyRead  Reads the keyboard.
  948.        SioLine     Reads the line status register.
  949.        SioLoopBack Performs a UART loopback test.
  950.        SioModel    Returns a code corresponding to the memory model used.
  951.        SioModem    Reads the modem status register.
  952.        SioParms    Sets parity, stop bits, and word length.
  953.        SioPutc     Transmit a character over a serial line.
  954.        SioReset    Initialize a serial port for processing.
  955.        SioRI       Reads the Ring Indicator (RI) modem status bit.
  956.        SioRTS      Sets, clears, or reads the Request to Send (RTS) line.
  957.        SioRxBuf    Sets up receive buffer.
  958.        SioRxFlush  Flushes ( clears ) the receive buffer.
  959.        SioRxQue    Returns the number of characters in the receive queue.
  960.        SioTimer    Returns the number of system clock tics.
  961.        SioUART     Sets the UART base address.
  962.        SioUnGetc   "Un-gets" ( puts back ) a specified character.
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.       PCL4C Users Manual                                      Page 15
  987.  
  988.  
  989.  
  990.  
  991.                              Serial Communications
  992.  
  993.  
  994.  
  995.        The heart  of  serial  communications  is  the  UART  (  Universal
  996.        Asynchronous   Receiver  Transmitter  ).   The  IBM  PC/XT/AT  and
  997.        compatibles use the INS8250 UART or an  UART  that  is  compatible
  998.        with the INS8250.  The purpose of the UART is:
  999.  
  1000.        (1)  To  convert  bytes  from the CPU ( Central Processing Unit ),
  1001.        into a serial format by adding  the  necessary  start,  stop,  and
  1002.        parity bits to each byte before transmission, and to then transmit
  1003.        each bit at the correct baud rate.
  1004.  
  1005.        (2) To convert the incoming stream ( at a specified baud rate ) of
  1006.        serial  bits  into  bytes  by removing the start, stop, and parity
  1007.        bits before being made available to the CPU.
  1008.  
  1009.        The  UART  is  part of the serial interface circuitry which allows
  1010.        the CPU to send and receive signals over the RS232 lines. This can
  1011.        be diagrammed as follows:
  1012.  
  1013.                              Serial Interface
  1014.                           +-------------------+
  1015.        +-----+  Data Bus  |     +------+      |    RS232 Signals
  1016.        | CPU |============|     | UART |      |<------------------>
  1017.        +-----+            |     +------+      |
  1018.                           +-------------------+
  1019.  
  1020.        The  INS  8250  UART  is capable of operating in one of two modes,
  1021.        "polled"  and  "interrupt  driven".   The  serial   communications
  1022.        functions  in  the BIOS uses the polled method.  In this approach,
  1023.        the CPU is typically in a loop asking the UART over and over again
  1024.        if it has a byte ready. If its does, the polling code returns  the
  1025.        byte.  But,  if  the next byte comes in before the polling code is
  1026.        executing again, then that byte is lost.
  1027.  
  1028.        In the interrupt driven approach ( used by PCL4C for incoming data
  1029.        ), when a byte is received by  the  UART,  an  "Interrupt  Service
  1030.        Routine"  (  ISR ) is executed immediately, suspending temporarily
  1031.        whatever else is executing.  The ISR then  moves  the  byte  to  a
  1032.        buffer  so  that your application program can later read it. Refer
  1033.        to the sections entitled "RS232  Signals"  and  "National  INS8250
  1034.        UART" for further information on these topics.
  1035.  
  1036.        The best way to learn about serial communications  is  to  read  a
  1037.        good  book  on the subject. Several good texts are available.  Two
  1038.        that I like are:
  1039.  
  1040.        (1) C Programmers's Guide to Serial Communications by Joe Campbell
  1041.        (SAMS)
  1042.  
  1043.        (2) Mastering Serial Communications by Peter Gofton (SYBEX).
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.       PCL4C Users Manual                                      Page 16
  1053.  
  1054.  
  1055.  
  1056.  
  1057.                              IBM Communications Ports
  1058.  
  1059.  
  1060.  
  1061.        There  are  a  few  things to know about how serial communications
  1062.        ports are used by  IBM  PC/XT/AT  and  compatible  computers.  The
  1063.        standard IBM PC/XT/AT configuration values are as follows:
  1064.  
  1065.        Port     Reg Base   IRQ Line   Vector
  1066.        COM1        3F8H        4        12
  1067.        COM2        2F8H        3        11
  1068.        COM3        3E8H        4        12
  1069.        COM4        2E8H        3        11
  1070.  
  1071.        PCL4C assumes the  above  values.  If  necessary,  the  UART  base
  1072.        address   can  be changed by SioUART. However, the IRQ and Service
  1073.        vector values can not be changed ( unless you  modify  the  source
  1074.        code ).
  1075.  
  1076.        When installing new communications cards, the following guidelines
  1077.        are recommended:
  1078.  
  1079.        (1) Be sure to read the documentaion  for  the  hardware  you  are
  1080.        installing.   Pay special attention to UART base addresses and IRQ
  1081.        lines.
  1082.  
  1083.        (2) If you have a choice in base addresses and IRQ  lines,  always
  1084.        choose standard values as defined above.
  1085.  
  1086.        (3) The first port should be COM1, the second COM2, etc.
  1087.  
  1088.        (4)  Use  SioUART  to  zero  all  unused ports ( for example, call
  1089.        SioUART(COM4,0) if there is no COM4 port installed ).
  1090.  
  1091.        (5)  Be  carefull not to configure two ports for the same address.
  1092.        This is easier to do than you may believe.
  1093.  
  1094.        (6) Choose an external modem over an internal  one.   It  is  much
  1095.        easier  to  debug problems with an external modem than an internal
  1096.        one.
  1097.  
  1098.        (7) Always test your port as soon as it is installed.
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.       PCL4C Users Manual                                      Page 17
  1119.  
  1120.  
  1121.  
  1122.  
  1123.                              RS232 Signals
  1124.  
  1125.  
  1126.  
  1127.        RS-232  is  the name of the serial data interface standard used to
  1128.        connect computers to modems.  Most IBM  compatible  computers  are
  1129.        built  with  at least one serial port and use either DB9 ( 9 pin )
  1130.        or DB25 ( 25 pin ) connectors.
  1131.  
  1132.        A summary of these pins and  their  function  follows.   For  more
  1133.        detailed  information, refer to one of the many books dealing with
  1134.        RS-232 interfacing.
  1135.  
  1136.        Signal Ground Pin 7 (DB25), Pin 5 (DB9)
  1137.  
  1138.        The SG line is used as the common signal ground, and  must  always
  1139.        be connected.
  1140.  
  1141.        Transmit Data Pin 2 (DB25), Pin 3 (DB9)
  1142.  
  1143.        The TX line is used to carry data from the computer to the modem.
  1144.  
  1145.        Receive Data Pin 3 (DB25), Pin 2 (DB9)
  1146.  
  1147.        The RX line is used to carry data from the modem to the computer.
  1148.  
  1149.        Data Terminal Ready Pin 20 (DB25), Pin 4 (DB9)
  1150.  
  1151.        The  DTR  line is used by the computer to signal the modem that it
  1152.        is ready.
  1153.  
  1154.        Data Set Ready Pin 6 (DB25), Pin 6 (DB9)
  1155.  
  1156.        The DSR line is used by the modem to signal the computer  that  it
  1157.        is ready.
  1158.  
  1159.        Request to Send Pin 4 (DB25), Pin 7 (DB9)
  1160.  
  1161.        The  RTS  line  is  used  to "turn the line around" in half duplex
  1162.        modems, but is not necessary in full duplex modems.
  1163.  
  1164.        Clear to Send Pin 5 (DB25), Pin 8 (DB9)
  1165.  
  1166.        The  CTS  line, like the RTS line, is not necessary in full duplex
  1167.        modems.
  1168.  
  1169.        Data Carrier Detect Pin 8 (DB25), Pin 1 (DB9)
  1170.  
  1171.        The DCD line is used by the modem to signal the  computer  that  a
  1172.        data carrier signal is present.
  1173.  
  1174.        Ring Indicator Pin 22 (DB25), Pin 9 (DB9)
  1175.  
  1176.        The RI line is asserted when a 'ring' occurs.
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.       PCL4C Users Manual                                      Page 18
  1185.  
  1186.  
  1187.  
  1188.  
  1189.                              National INS8250 UART
  1190.  
  1191.  
  1192.  
  1193.        The  Personal  Communications  Library  is  based  on the standard
  1194.        National INS8250 UART and compatible UARTs.  The 8250 consists  of
  1195.        8 register ports as follows:
  1196.  
  1197.        Offset    R/W   Register
  1198.          0       R/W   Receiver ( read ) / Transmitter ( write )
  1199.          1       R/W   Interrupt Enable
  1200.          2       R     Interrupt Identification
  1201.          3       R/W   Data Format ( Line Control )
  1202.          4       R/W   RS-232 ( Modem ) Control
  1203.          5       R/W   Line Status
  1204.          6       R/W   RS-232 ( Modem ) Status
  1205.          7       R/W   Not used.
  1206.  
  1207.        The  UART  registers  are  based  at  3F8  (COM1), 2F8 (COM2), 3E8
  1208.        (COM3), and 2E8 (COM4). COM1 and COM3 share  interrupt  vector  12
  1209.        and  interrupt  request  line  IRQ4  while  COM2  and  COM4  share
  1210.        interrupt vector 11 and interrupt request line IRQ3.   This  means
  1211.        that  COM1  and  COM3  cannot  both  be  used  at  the  same time.
  1212.        Similarly, COM2 and COM4 cannot both be used at the same time.
  1213.  
  1214.  
  1215.        Port     Reg Base   IRQ Line   Vector
  1216.        COM1        3F8H        4        12
  1217.        COM2        2F8H        3        11
  1218.        COM3        3E8H        4        12
  1219.        COM4        2E8H        3        11
  1220.  
  1221.        Four sources  of  interrupts  are  possible  with  the  8250:  (1)
  1222.        receiver  error  or  BREAK,  (2) receiver data ready, (3) ready to
  1223.        transmit, and (4) RS232 input.  These four sources  of  interrupts
  1224.        are summarized as follows:
  1225.  
  1226.        Source of Interrupt        Action Required to Clear
  1227.        Receiver error or BREAK.   Read Line Status register.
  1228.        Receiver data.             Read data from data register.
  1229.        Transmitter Buffer Empty.  Write to data register or read IID reg.
  1230.        RS232 input.               Read Modem Status register.
  1231.  
  1232.        However,  PCL4C  only  enables  the receiving data interrupt. This
  1233.        means that interrupts can only be caused by incoming data.
  1234.  
  1235.        If  you  are not familiar with the INS8250, several good books are
  1236.        available.   Refer  to  the  Serial  Communications  chapter   for
  1237.        recommendations.    Although  a  knowledge  of  the  8250  is  not
  1238.        necessary to use PCL4C, a  general  knowledge  of  the  theory  of
  1239.        asynchronous serial communications is recommended.
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.       PCL4C Users Manual                                      Page 19
  1251.  
  1252.  
  1253.  
  1254.  
  1255.                              Register Summary
  1256.  
  1257.  
  1258.  
  1259.        REG 0 : Data Register
  1260.  
  1261.        Reading  from  the data register fetches the next input byte, once
  1262.        it is ready.  Writing to the  data  register  transmits  the  byte
  1263.        written to it over the serial line.
  1264.  
  1265.        REG 1 : Interrupt Enable 
  1266.  
  1267.        The  Interrupt  Enable  register  enables  each  of  four types of
  1268.        interrupts when the appropriate bit is set to a one.
  1269.  
  1270.        bit 3 : Enable interrupt on RS232 input.
  1271.        bit 2 : Enable interrupt on receiver error or break.
  1272.        bit 1 : Enable interrupt on transmitter buffer empty ( TBE ).
  1273.        bit 0 : Enable interrupt on received data ( RxRDY ).
  1274.  
  1275.        REG 2 : Interrupt Identification (IID)
  1276.  
  1277.        Reading the Interrupt Identification register  once  an  interrupt
  1278.        has occurred identifies the interrupt as follows:
  1279.  
  1280.        Bit 2  Bit 1  Bit 0  Priority  Interrupt
  1281.        =====  =====  =====  ========  =========
  1282.          0      0      1      none     none
  1283.          1      1      0       0       Serialization or break.
  1284.          1      0      0       1       Received data.
  1285.          0      1      0       2       Transmitter Buffer Empty.
  1286.          0      0      0       3       RS232 Input.
  1287.  
  1288.        where 0 = highest priority.
  1289.  
  1290.        REG 3 : Line Control
  1291.  
  1292.        RS232  line parameters are selected by writing to this register as
  1293.        follows:
  1294.  
  1295.        bit 7 : DLAB = 0
  1296.        bit 6 : BREAK on(1), off(0).
  1297.        bits 5-3: Parity None(000),ODD(001),EVEN(011),MARK(101),SPACE(111)
  1298.        bit 2 : One stop bit(0), two stop bits(1).
  1299.        bits 1-0: Data bits = 5 (00), 6(01), 7(10), 8(11).
  1300.  
  1301.        When the Divisor Latch Access Bit ( DLAB ) is 1, registers 0 and 1
  1302.        become the LS and MS bytes of the Baud Rate Divisor registers.
  1303.  
  1304.         Divisor    Baud Rate            Divisor    Baud Rate
  1305.           300      0180                     9600      000C
  1306.           600      00C0                    19200      0006
  1307.          1200      0060                    38400      0003
  1308.          2400      0030                    57600      0002
  1309.          4800      0018                   115200      0001
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.       PCL4C Users Manual                                      Page 20
  1317.  
  1318.  
  1319.  
  1320.  
  1321.        REG 4 : Modem Control
  1322.  
  1323.        RTS, DTR, loopback testing, and General Purpose Outputs #1 and  #2
  1324.        are controlled by the Modem Control register as follows:
  1325.  
  1326.        bit 4 : Enable local loopback.
  1327.        bit 3 : Enable GP02. Necessary for 8250 interrupts.
  1328.        bit 2 : Enable GP01.
  1329.        bit 1 : Set / clear RTS.
  1330.        bit 0 : Set / clear DTR.
  1331.  
  1332.        REG 5 : Line Status
  1333.  
  1334.        Reading  the  Line  Status register provides status information as
  1335.        follows ( 1 for TRUE, 0 for FALSE ) :
  1336.  
  1337.        bit 6 : Transmitter Empty.
  1338.        bit 5 : Transmitter Buffer Empty ( TBE ).
  1339.        bit 4 : BREAK detect.
  1340.        bit 3 : Framing error.
  1341.        bit 2 : Parity error.
  1342.        bit 1 : Overrun error.
  1343.        bit 0 : Data Ready.
  1344.  
  1345.        REG 6 : Modem Status
  1346.  
  1347.        Reading the Modem Status register provides  the  following  status
  1348.        information ( 1 for TRUE, 0 for FALSE ) :
  1349.  
  1350.        bit 7 : DCD status.
  1351.        bit 6 : RI status.
  1352.        bit 5 : DSR status.
  1353.        bit 4 : CTS status.
  1354.        bit 3 : Delta DCD status.
  1355.        bit 2 : Delta RI status.
  1356.        bit 1 : Delta DSR status.
  1357.        bit 0 : Delta CTS status.
  1358.  
  1359.        The  delta  bits  ( bits 0 through 3 ) are set whenever one of the
  1360.        status bits ( bits 4 through 7 ) changes ( from 0 to 1 or  from  1
  1361.        to  0  )  since  the  last time that the Modem Status register was
  1362.        read. Reading the Modem Status register clear the delta bits.
  1363.  
  1364.        REG 7 : Scratch Register
  1365.  
  1366.        There is no function associated with  register  7.   It  does  not
  1367.        exist in early versions of the 8250.
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.       PCL4C Users Manual                                      Page 21
  1383.  
  1384.  
  1385.  
  1386.  
  1387.                              Example Code
  1388.  
  1389.  
  1390.  
  1391.        The  following programs are provided as examples of the use of the
  1392.        PCL4C library.  They are not part of the PCL4C library, and may be
  1393.        used in any way the user wishes. Makefiles (  small  model  )  are
  1394.        provided for all example code.
  1395.  
  1396.        SIMPLE
  1397.  
  1398.        SIMPLE  is  an  extremely simple terminal emulator program.  It is
  1399.        provided as the smallest and  easiest  to  understand  example  of
  1400.        serial communications programming using PCL4C.
  1401.  
  1402.        To  start  SIMPLE,  just type SIMPLE. The baud rate is set at 2400
  1403.        and can be easily changed in the source code. Similiarly the  port
  1404.        is set to COM1 and is easily changed in the source code. Note that
  1405.        SIMPLE does not send an initialization string to your modem.
  1406.  
  1407.        INTERCOM
  1408.  
  1409.        INTERCOM is just slightly more complex than SIMPLE.  Hook  up  two
  1410.        computers  via  modem or a null modem cable.  INTERCOM divides the
  1411.        screen horizontally into two areas.   Whatever  is  typed  on  one
  1412.        machine  is  displayed  locally  in the top half of the screen and
  1413.        sent  over  to  the  other  computer.   Whatever  is  received  is
  1414.        displayed in the lower half of the screen.
  1415.  
  1416.        To start INTERCOM, type INTERCOM followed by the port ( 1 to 4 ).
  1417.  
  1418.        MODEM
  1419.  
  1420.        MODEM  displays the modem status lines (DSR, CTS, DCD, and RI) and
  1421.        the modem control lines (DTR and RTS). Additionally, it allows the
  1422.        user to set or clear the modem control lines. MODEM is useful when
  1423.        testing RS232 cable connections.
  1424.  
  1425.        To start MODEM, type MODEM followed by the port ( 1 to  4  ).  For
  1426.        example "MODEM 1".
  1427.  
  1428.        NORESET
  1429.  
  1430.        NORESET   is  designed  to  "take  over"  a  port  from  a  serial
  1431.        communications program which has a DOS gateway. This is useful for
  1432.        implementing external protocols or similiar uses.
  1433.  
  1434.        For   example,   if  you  start  PROCOMM  (  a  popular  shareware
  1435.        communications  program  )  and  select  the  DOS  gateway   after
  1436.        establishing  communications, you will see the DOS prompt. At this
  1437.        point type "NORESET 1" to  take  over  COM1  (  or  whatever  port
  1438.        PROCOMM is using ) without dropping the carrier.  NORESET will run
  1439.        using  the same baud rate and parameters as PROCOMM.  When you are
  1440.        finished, type ESC to leave NORESET and type  EXIT  to  return  to
  1441.        PROCOMM.
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.       PCL4C Users Manual                                      Page 22
  1449.  
  1450.  
  1451.  
  1452.  
  1453.        TERM
  1454.  
  1455.        TERM  is  a  more  capable  terminal  emulator  than  SIMPLE.   It
  1456.        functions as a dumb terminal emulator but can exchange files using
  1457.        XMODEM ( Standard XMODEM, XMODEM-CRC, and XMODEM-1K ) and YMODEM (
  1458.        batch  capability  ) communications protocols. TERM will also send
  1459.        an initialization string to your Hayes compatible modem.
  1460.  
  1461.        To start TERM, type TERM followed by the port ( 1 to 4 )  and  the
  1462.        baud rate ( 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600,
  1463.        or 115200). For example, "TERM 4 2400".
  1464.  
  1465.        XFER
  1466.  
  1467.        XFER  is  designed  to  transfer files between PCs  connected  via
  1468.        their  serial  ports  using a null modem cable. It uses a protocol
  1469.        similiar to YMODEM and accepts wildcards in the filename.
  1470.  
  1471.        Start  XFER  on  the  computer which is to receive files by typing
  1472.        "XFER port baud" as with TERM.  Then start XFER  on  the  computer
  1473.        which  is  to  send  the files by typing "XFER port baud filespec"
  1474.        where filespec is the file specification to transfer. Type ESC  to
  1475.        cancel at any time.
  1476.  
  1477.        For  example,  to  send  all the C files over COM4 at 115200 baud,
  1478.        type "XFER 4 115200 *.C" after starting XFER  on  the  destination
  1479.        computer ( which must have the same baud rate ).
  1480.  
  1481.        LOOPBACK
  1482.  
  1483.        LOOPBACK performs a loopback test of the selected port UART.  This
  1484.        is  useful  for  testing  a  serial port UART that is suspected of
  1485.        being bad. However, defective UARTS are very unusual.
  1486.  
  1487.        Start LOOPBACK by typing LOOPBACK followed by the port ( 1 to 4 ).
  1488.        For example "LOOPBACK 4".
  1489.  
  1490.        BBS
  1491.  
  1492.        BBS is a simple single caller bulletin board system featuring file
  1493.        uploading  and  downloading  via  XMODEM and YMODEM. If you have a
  1494.        Hayes compatible modem, BBS will initialize your  modem  and  wait
  1495.        for an incoming call.
  1496.  
  1497.        BBS   demonstrates   the   communications   principles   used   in
  1498.        constructing  a  single  caller  bulletin  board system as well as
  1499.        XMODEM and YMODEM protocols.
  1500.  
  1501.        To  use BBS, type BBS followed by the port ( 1 to 4 ) and the baud
  1502.        rate. For example, "BBS 1 2400".
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.       PCL4C Users Manual                                      Page 23
  1515.  
  1516.  
  1517.  
  1518.  
  1519.                              Revision History
  1520.  
  1521.  
  1522.  
  1523.        Version 1.0 -- 14 January 1991 -- original release.
  1524.  
  1525.        Version 1.1 -- 11 March 1991
  1526.  
  1527.        o  Added SioUnGetc() function to library.
  1528.        o  Added ASCII file transfer to TERM.
  1529.        o  Minor documentation changes.
  1530.  
  1531.        Version 1.2 -- 1 June 1991
  1532.  
  1533.        o  Name changed to Personal Communications Library.
  1534.        o  SioParms() bug -- could not call before SioReset.
  1535.        o  SioReset() bug -- was not saving & restoring all regs.
  1536.        o  Added SIMPLE.C and XFER.C example code.
  1537.  
  1538.        Version 1.3 -- 1 July 1991
  1539.  
  1540.        o  Added NORESET option to SioReset.
  1541.        o  Added SioDSR, SioCTS, SioDCD, and SioRI.
  1542.        o  Added SioLoopBack function to library.
  1543.        o  Added NORESET.C example program.
  1544.        o  Added LOOPBACK.C example program.
  1545.  
  1546.        Version 2.0 -- 1 Nov 1991
  1547.  
  1548.        o  All example code released in shareware package.
  1549.        o  Reorganized as four memory model libraries.
  1550.        o  Added SioModel function to library.
  1551.        o  Added support for Quick C and Power C.
  1552.  
  1553.        Version 2.1 -- 1 Dec 1991
  1554.  
  1555.        o  Fixed bug due to Microsoft Assembler (MASM 5.0,5.1) error.
  1556.        o  Added BBS & INTERCOM example code.
  1557.        o  Greatly expanded documentation.
  1558.  
  1559.        ( MarshallSoft incorporated on December 23, 1991 )
  1560.  
  1561.        Version 3.0 -- 15 Jan 1991
  1562.  
  1563.        o  Added SioUART function.
  1564.        o  Added "UART undefined" error code.
  1565.        o  Added "Bad or missing UART" error code.
  1566.        o  Added "Port already enabled" error code.
  1567.        o  Added "Cannot enable both COM1 & COM3 ..." error code.
  1568.        o  Fixed several minor bugs ( using new automated testing ).
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.       PCL4C Users Manual                                      Page 24
  1581.  
  1582.  
  1583.  
  1584.  
  1585.                              License
  1586.  
  1587.  
  1588.  
  1589.        MarshallSoft Computing, Inc. grants the registered user  of  PCL4C
  1590.        the  right  to  use  the  PCL4C  library ( in object form ) in the
  1591.        development  of  any  software  product  without  any   royalties.
  1592.        However,  the  source  code for the library may not be released in
  1593.        whole or in part.
  1594.  
  1595.  
  1596.  
  1597.                              Warranty
  1598.  
  1599.  
  1600.  
  1601.        MARSHALLSOFT COMPUTING, INC. DISCLAIMS ALL WARRANTIES RELATING  TO
  1602.        THIS  SOFTWARE,  WHETHER  EXPRESSED  OR IMPLIED, INCLUDING BUT NOT
  1603.        LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY  AND  FITNESS
  1604.        FOR  A  PARTICULAR  PURPOSE, AND ALL SUCH WARRANTIES ARE EXPRESSLY
  1605.        AND SPECIFICALLY DISCLAIMED. NEITHER MARSHALLSOFT COMPUTING,  INC.
  1606.        NOR ANYONE ELSE WHO HAS BEEN INVOLVED IN THE CREATION, PRODUCTION,
  1607.        OR  DELIVERY  OF  THIS  SOFTWARE SHALL BE LIABLE FOR ANY INDIRECT,
  1608.        CONSEQUENTIAL, OR INCIDENTAL DAMAGES ARISING OUT  OF  THE  USE  OR
  1609.        INABILITY  TO  USE  SUCH  SOFTWARE EVEN IF MARSHALLSOFT COMPUTING,
  1610.        INC.  HAS BEEN ADVISED OF  THE  POSSIBILITY  OF  SUCH  DAMAGES  OR
  1611.        CLAIMS. IN NO EVENT SHALL MARSHALLSOFT COMPUTING, INC.'S LIABILITY
  1612.        FOR ANY SUCH DAMAGES EVER EXCEED THE PRICE PAID FOR THE LICENSE TO
  1613.        USE  THE SOFTWARE, REGARDLESS OF THE FORM OF THE CLAIM. THE PERSON
  1614.        USING  THE  SOFTWARE  BEARS  ALL  RISK  AS  TO  THE  QUALITY   AND
  1615.        PERFORMANCE OF THE SOFTWARE.
  1616.  
  1617.        Some  states  do not allow the exclusion of the limit of liability
  1618.        for consequential or incidental damages, so the  above  limitation
  1619.        may not apply to you.
  1620.  
  1621.        This  agreement  shall  be  governed  by  the laws of the State of
  1622.        Alabama and shall inure to the benefit of Marshallsoft  Computing,
  1623.        Inc.   and  any successors, administrators, heirs and assigns. Any
  1624.        action or proceeding brought by either  party  against  the  other
  1625.        arising  out of or related to this agreement shall be brought only
  1626.        in a STATE or FEDERAL COURT of competent jurisdiction  located  in
  1627.        Madison County, Alabama. The parties hereby consent to in personam
  1628.        jurisdiction of said courts.
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.       PCL4C Users Manual                                      Page 25
  1647.  
  1648.  
  1649.  
  1650.  
  1651.