home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / SOFTWARE / LIBS / PCL4C43.ZIP / PCL4CUSR.DOC (.txt) < prev    next >
Text File  |  1995-03-14  |  78KB  |  2,245 lines

  1.  
  2.  
  3.                  Personal Communications Library
  4.  
  5.                        For the C Language
  6.  
  7.  
  8.                            (PCL4C)
  9.  
  10.  
  11.  
  12.                         USERS MANUAL
  13.  
  14.  
  15.  
  16.  
  17.  
  18.                          Version 4.3
  19.  
  20.                         March 15, 1995
  21.  
  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) 1995
  32.                      All rights reserved
  33.  
  34.  
  35.  
  36.                      MarshallSoft Computing, Inc.
  37.                      Post Office Box 4543
  38.                      Huntsville AL 35815
  39.  
  40.                      Voice 205-881-4630
  41.                      FAX   205|880|0925
  42.                      BBS   205-880-9748
  43.  
  44.  
  45.                                 _______
  46.                            ____|__     |                (R)
  47.                         --+       |    +-------------------
  48.                           |   ____|__  |  Association of
  49.                           |  |       |_|  Shareware
  50.                           |__|   o   |    Professionals
  51.                         --+--+   |   +---------------------
  52.                              |___|___|    MEMBER
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  PCL4C Users Manual                                                Page 1
  69.                      C O N T E N T S
  70.  
  71.  
  72.  
  73.  
  74.  
  75.   Chapter                                                   Page
  76.  
  77.   1.0 Introduction................................................3
  78.       1.1 User Support............................................4
  79.       1.2 ASP Ombudsman...........................................4
  80.       1.3 A Typical Application...................................5
  81.       1.4 Installation............................................6
  82.   2.0 Library Organization........................................7
  83.       2.1 Configuration...........................................7
  84.       2.2 Initialization & Termination............................7
  85.       2.3 Modem Control & Status..................................8
  86.       2.4 Serial I/O..............................................8
  87.       2.5 Error Detection.........................................9
  88.       2.6 General Support.........................................9
  89.   3.0 Library Overview...........................................10
  90.       3.1 Memory Models..........................................10
  91.       3.2 Compilers Supported....................................11
  92.       3.3 Using the Library......................................12
  93.       3.4 Application Notes......................................12
  94.           3.4.1 Terminal Programs................................12
  95.           3.4.2 Door Programs....................................12
  96.           3.4.3 BBS Programs.....................................12
  97.       3.5 Compiling & Linking....................................13
  98.   4.0 Talking to Your Modem......................................14
  99.       4.1 Modem Standards........................................14
  100.       4.2 Flow Control...........................................15
  101.       4.3 MODEM_IO functions.....................................15
  102.       4.4 Modem Initialization...................................16
  103.   5.0 Problems...................................................17
  104.   6.0 Serial Communications......................................18
  105.       6.1 Communications Basics..................................18
  106.       6.2 Standard Port Addresses................................19
  107.       6.3 Running 3 or 4 Ports Concurrently......................20
  108.       6.4 Using Multiport Cards..................................21
  109.           6.4.1 The DigiBoard....................................21
  110.           6.4.2 The BOCA Board...................................21
  111.       6.5 Transmitter Interrupts.................................22
  112.       6.6 RS232 Signals..........................................23
  113.       6.7 National INS8250, INS16450, and INS16550 UARTs.........24
  114.       6.8 Register Summary.......................................25
  115.   7.0 Example Programs...........................................27
  116.       7.1 MINIMAL................................................27
  117.       7.1 SIMPLE.................................................27
  118.       7.2 LOGIN..................................................27
  119.       7.3 DOOR...................................................27
  120.       7.4 SELFTEST...............................................27
  121.   8.0 Legal Issues...............................................28
  122.       8.1 Registration...........................................28
  123.       8.2 License................................................29
  124.       8.3 Warranty...............................................29
  125.   9.0 Summary....................................................30
  126.       9.1 Revision History.......................................30
  127.       9.2 Function Summary.......................................32
  128.       9.3 Further Reading........................................32
  129.  10.0 Other MarshallSoft Computing products for C................33
  130.       10.1 The Personal Protocol Library for C...................33
  131.       10.2 The LZW Data Compression Library for C................33
  132.       10.3 The EMS Expanded Memory Library for C.................33
  133.  
  134.  
  135.  
  136.  PCL4C Users Manual                                                Page 2
  137.   1.0 Introduction
  138.  
  139.  
  140.   The  Personal  Communications  Library  for  the  C  Language  (PCL4C) is an
  141.   asynchronous  communications  library  designed  for  experienced   software
  142.   developers  programming  in  C.   Five compilers are supported: Microsoft C,
  143.   Quick C, Borland C, Turbo C, and MIX Power C.  An IBM PC/XT/AT or compatible
  144.   is required.  The PCL features:
  145.  
  146.   o SMALL, COMPACT, MEDIUM, and LARGE memory models.
  147.   o 38 communications and support functions.
  148.   o Supports the high performance 16550 UART.
  149.   o Supports the PC/4 and PC/8 DigiBoard.
  150.   o Supports the BOCA BB1004, BB1008, and BB2016 boards.
  151.   o Supports hardware (RTS/CTS) flow control.
  152.   o Interrupt driven receiver & (optionally) transmitter.
  153.   o Supports 300 baud to 115,200 baud.
  154.   o Supports COM1 through COM8 (through COM16 with multiport boards)
  155.   o Adjustable receive queues from 8 bytes to 32 KB.
  156.   o Control-BREAK error exit.
  157.   o 18 communications error conditions trapped.
  158.   o Allows 4 ports to run concurrently (more with multiport boards).
  159.   o Complete modem control & status.
  160.   o Written in assembly language for small size & high speed.
  161.   o Terminal program featuring ASCII (with XON/XOFF), XMODEM,
  162.     YMODEM, & YMODEM-G.
  163.  
  164.   Why should you buy PCL4C ?  Several good reasons are:
  165.  
  166.     COMPLETE - PCL4C is complete since it provides  absolute  control  of  the
  167.                serial ports (including the high performance INS16550).
  168.  
  169.      COMPACT - PCL4C  is  very  compact at less than 8 KB.  Your application
  170.                doesn't carry a lot of excess code.
  171.  
  172.         FAST - PCL4C is fast since it will run at 38400 baud on even slow 8088
  173.                PCs (4.77 MHZ) and at 115200 baud on most everything else.
  174.  
  175.      SUPPORT - If you get stuck, you talk to the  programmer  that  wrote  the
  176.                code, not a person hired to answer the phone.
  177.  
  178.          BBS - A BBS is available (2400 to 14400 baud, N81) in order to provide
  179.                immediate support as necessary.
  180.  
  181.   NEWSLETTER - A  one  year  subscription  to  the  MSC newsletter discusses
  182.                communications problems and solutions (published quarterly).
  183.  
  184.        PRICE - You get PCL4C for a very reasonable price!
  185.  
  186.     UPGRADES - Once you buy PCL4C, you can always update to  the  most  recent
  187.                version very inexpensively ($20 plus shipping).
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  PCL4C Users Manual                                                Page 3
  205.   1.1 User Support
  206.  
  207.  
  208.   We want you to be successful in developing your applications using PCL4C! We
  209.   depend  on  our  customers to let us know what they need in a communications
  210.   library.  This means we are committed to providing the  best  communications
  211.   library  that we can. If you have any suggestions or comments, please let us
  212.   know!
  213.  
  214.   We provide customer support for registered customers by voice, FAX, BBS, and
  215.   mail.  We provide limited support for unregistered users by  voice  and  BBS
  216.   only.
  217.  
  218.   If  you  are  having  a problem using PCL4C, call us at 205-881-4630 between
  219.   1:30 PM and 9:30 PM (CST) Monday through Friday. You can also call at  other
  220.   times and leave a message, and call back later for a reply. Registered users
  221.   (ONLY) can also FAX us at 205-880-0925 at any time (24 hours).
  222.  
  223.   However,  we  can  only  answer  questions  with  respect to using the PCL4C
  224.   library.  We cannot help you program your application, but we'll be glad  to
  225.   discuss it with you.
  226.  
  227.   You  may  also  call  our User Support BBS (2400 to 14400 baud, no parity, 8
  228.   data bits, 1 stop bit) at 205-880-9748 and leave a message  (address  it  to
  229.   the SYSOP).  We will usually have a reply ready for you within 24 hours.
  230.  
  231.   The BBS is available 24 hours per day. All files are in standard ZIP format.
  232.   The  BBS  will  contain  the  latest  shareware  version of all MarshallSoft
  233.   Computing products as well as related files such as:
  234.  
  235.       BUGS.ZIP     -  Bug report.
  236.       NEWS.ZIP     |  Latest news regarding our products.
  237.       PRODUCTS.ZIP -  List of all shareware products.
  238.  
  239.   The MarshallSoft  Computing,  Inc.   newsletter  "Comm  Talk"  is  published
  240.   quarterly.  It discusses various communications problems and solutions using
  241.   PCL4C  as  well  as related information. Registered users receive a one year
  242.   complimentary subscription  when  first  registering  and  for  each  update
  243.   purchased.
  244.  
  245.  
  246.   1.2 ASP Ombudsman
  247.  
  248.  
  249.   MarshallSoft Computing, Inc.  is a member of the  Association  of  Shareware
  250.   Professionals  (ASP).   ASP  wants to make sure that the shareware principle
  251.   works for you.  If you are unable to  resolve  a  shareware-related  problem
  252.   with  an  ASP  member  by contacting the member directly, ASP may be able to
  253.   help. The ASP Ombudsman can help you resolve a dispute or  problem  with  an
  254.   ASP  member,  but  does not provide technical support for members' products.
  255.   Please write to the ASP Ombudsman at  545  Grover  Road,  Muskegon,  MI  USA
  256.   49442-9427,  Fax  616-788-2765,  or send a CompuServe message via CompuServe
  257.   Mail to ASP Ombudsman 70007,3536.
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  PCL4C Users Manual                                                Page 4
  273.   1.3 A Typical Application
  274.  
  275.  
  276.   In general, there are two classes of applications that use a  communications
  277.   library like PCL4C - those that use a modem to connect to the outside world
  278.   and  those  that  connect directly to a peripheral device. In either case, a
  279.   typical application program using PCL4C might look like the  following  code
  280.   outline:
  281.  
  282.  
  283.  
  284.   +---------------------------------------------------+
  285.   | #include  "pcl4c.h"                               |
  286.   |                                                   |
  287.   | void main(void)                                   |
  288.   | {                                                 |
  289.   |  ...                                              |
  290.   |                                                   |
  291.   |  /* initialize serial comm  system  */            |
  292.   |  SioRxBuf(Port,AllocSeg(1024),Size1024);          |
  293.   |  SioParms(Port,NoParity,OneStopBit,WordLength8);  |
  294.   |  SioReset(Port,Baud2400);                         |
  295.   |                                                   |
  296.   |  ...application code...                           |
  297.   |                                                   |
  298.   |  /* terminate serial comm system  */              |
  299.   |  SioDone(Port);                                   |
  300.   | }                                                 |
  301.   +---------------------------------------------------+
  302.  
  303.  
  304.  
  305.   In  the  above example, SioRxBuf is called to set up the a 1024 byte receive
  306.   buffer; SioParms is called to set up the parity, stop bit  count,  and  word
  307.   length;  SioReset  is called to set the baud rate to 2400 and reset the UART
  308.   (Univeral Asynchronous Receiver / Transmitter).
  309.  
  310.   The function AllocSeg() allocates a buffer of specified size on the far heap
  311.   and returns the segment SEG such that  SEG:0  points  to  the  buffer.   The
  312.   function AllocSeg() is part of the example code and can be found in the file
  313.   ALLOCSEG.C.
  314.  
  315.   Before leaving your application, SioDone is  called  to  restore  the  prior
  316.   state of the serial communications system.
  317.  
  318.   If  you  are using a modem, you also need to be concerned about initializing
  319.   your modem correctly and handling any required flow control.  Refer  to  the
  320.   "Talking to Your Modem" chapter for detailed information.
  321.  
  322.   If  you  are  using  the versions of the library with transmitter interrupts
  323.   enabled (PCL4C_S2.LIB, PCL4C_M2.LIB, PCL4C_C2.LIB, and  PCL4C_L2.LIB),  then
  324.   SioTxBuf() must  be  called  to  set  up  the  transmitter  buffer  just  as
  325.   SioRxBuf() is called to set up the receive buffer.
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  PCL4C Users Manual                                                Page 5
  341.   1.4 Installation
  342.  
  343.  
  344.   (1)  Before  installation  of  PCL4C,  your  C  compiler  should  already be
  345.   installed on your system and tested. If you are not familiar with makefiles,
  346.   refer to your compiler manual. If you are using the interactive  environment
  347.   for  Quick  C  or  Turbo  C,  be  sure  to  compile  with  the  memory model
  348.   corresponding to the PCL4C library used, and include the correct library  in
  349.   the  project  file.   Examine  the  file  "FILES.LST"  for a list of all the
  350.   distribution files.
  351.  
  352.   (2) Make a backup  copy  of  your  distribution  disk.   Put  your  original
  353.   distribution disk in a safe place.
  354.  
  355.   (3)  Create a work directory on your work disk (normally your harddisk). For
  356.   example, to create a work directory named PCL4C, we first log onto the  work
  357.   disk and then type:
  358.  
  359.                    MKDIR PCL4C
  360.  
  361.   (4)  Copy  all  the  files from your backup copy of the distribution disk to
  362.   your work directory.  For example, to copy from the A: drive  to  your  work
  363.   directory, we type:
  364.  
  365.                   CD PCL4C
  366.                   COPY A:*.*
  367.  
  368.   (5)  [OPTIONAL]  Delete  the makefiles that you won't need.  For example, if
  369.   you use the Microsoft C compiler, then you want to keep all makefiles ending
  370.   *._M_ but can delete those for Turbo C (*._T_), Quick  C  (*._Q_),  and  MIX
  371.   Power C (*.PRJ).  You may also delete any libraries that you won't need.
  372.  
  373.   (6)   Compile   SIMPLE.C   and  link  with  the  appropriate  PCL4C  library
  374.   (PCL4C_S.LIB for all but Power C which must use PCL4C_S.MIX). Makefiles  (or
  375.   project files) are provided for each of the supported compilers (Borland C &
  376.   Turbo C use the same makefiles).
  377.  
  378.        a) Microsoft C: Type MAKE SIMPLE._M_
  379.  
  380.        b) Microsoft Quick C: Type MAKE SIMPLE._Q_
  381.  
  382.        c) Borland C: Type MAKE -fSIMPLE._B_
  383.  
  384.        d) Turbo C: Type MAKE -fSIMPLE._T_
  385.  
  386.        e) MIX Power C: Type pc/e SIMPLE.PRJ
  387.  
  388.   SIMPLE.C  should  compile  without any problems as all example code has been
  389.   tested with each of the supported compilers.
  390.  
  391.   (7)  The  recommended  way  to  test  SIMPLE  is  to run it on two computers
  392.   connected by a null modem cable.  Whatever is typed on one  computer  should
  393.   be displayed on the other. SIMPLE can also be tested by connecting your port
  394.   to a modem.
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  PCL4C Users Manual                                                Page 6
  409.   2.0 Library Organization
  410.  
  411.  
  412.   The PCL4C library is organized into six categories of  functions.  Refer  to
  413.   the PCL Reference Manual (PCL4C.REF) for details on individual functions.
  414.  
  415.  
  416.   2.1 Configuration
  417.  
  418.  
  419.   There  are three functions in the configuration category.  SioPorts sets the
  420.   number of PC and DigiBoard (or BOCA board) ports. SioUART is used to  change
  421.   the  UART  base address for a communications port to a non-standard address,
  422.   while SioIRQ is used to assign a nonstandard IRQ line to a port.   (See  the
  423.   chapter IBM Communications Ports for more details on standard UART addresses
  424.   and IRQ lines).
  425.  
  426.   The  configuration  functions  SioPorts,  SioUART  and SioIRQ must be called
  427.   before calling any other library functions.  Be very careful in using  these
  428.   functions.  Remember that your serial hardware must support the UART and IRQ
  429.   that you specify.  Always test any new configuration immediately.
  430.  
  431.   SioPorts -  Sets number of PC and DigiBoard (or BOCA board) ports.
  432.   SioUART  |  Sets the UART base address.
  433.   SioIRQ   -  Assigns an IRQ line to a port.
  434.  
  435.   THE IRQ GOLDEN RULE: You may open (via  SioReset)  only  one  port  per  IRQ
  436.   (except for the DigiBoard and BOCA board).
  437.  
  438.  
  439.   2.2 Initialization & Termination
  440.  
  441.  
  442.   There are eight functions in the initialization  and  termination  category.
  443.   Together,  SioParms,  SioFIFO,  SioRxBuf,  SioTxBuf, and SioReset initialize
  444.   your serial communications system.  Your application must call SioParms  and
  445.   SioRxBuf  before  calling  SioReset,  and SioReset must be called before any
  446.   serial I/O processing can be done.
  447.  
  448.   After initialization, SioParms and SioBaud can be called again to change the
  449.   communications parameters without resetting the serial port. SioFlow can  be
  450.   called to enable hardware flow control.
  451.  
  452.   Before  exiting  from  your  application, SioDone must be called. Failure to
  453.   call SioDone can crash your system later.
  454.  
  455.   SioRxBuf   - Sets up receive buffer.
  456.   SioTxBuf   | Sets up transmitter buffer.
  457.   SioFIFO    | Sets the interrupt level for the INS16550.
  458.   SioParms   | Sets parity, stop bits, and word length.
  459.   SioReset   | Initialize a serial port for processing.
  460.   SioDone    | Terminates further serial processing.
  461.   SioBaud    | Sets the baud rate of the selected port.
  462.   SioFlow    - Enables / disables flow control.
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  PCL4C Users Manual                                                Page 7
  477.   2.3 Modem Control & Status
  478.  
  479.  
  480.   There are nine functions in the modem  control  and  status  category  which
  481.   provide  your  application with complete control over the status and control
  482.   bits of your modem.
  483.  
  484.   There are two modem control bits, "Data Terminal Ready" (DTR)  and  "Request
  485.   To  Send"  (RTS).  These  bits  can  be  read, set, or cleared by SioDTR and
  486.   SioRTS.
  487.  
  488.   There are four modem status bits, "Data Set Ready" (DSR),  "Clear  To  Send"
  489.   (CTS),  "Ring Indicator" (RI), and "Data Carrier Detect" (DCD). SioModem can
  490.   read any of the modem status bits.  SioDSR, SioCTS, SioRI,  and  SioDCD  can
  491.   only read their respective modem status bit. SioGetDiv reads the  baud  rate
  492.   divisor register so the baud rate can be determined.
  493.  
  494.   Refer  to  the  chapter entitled "RS232 Signals" for a discussion of each of
  495.   the control and status bits.
  496.  
  497.   SioDTR    - Set, clear, or read the Data Terminal Ready (DTR) bit.
  498.   SioRTS    | Sets, clears, or reads the Request to Send (RTS) line.
  499.   SioModem  | Reads the modem status register.
  500.   SioDSR    | Reads the Data Set Ready (DSR) modem status bit.
  501.   SioCTS    | Reads the Clear to Send (CTS) modem status bit
  502.   SioDCD    | Reads the Data Carrier Detect (DCD) modem status bit.
  503.   SioRI     | Reads the Ring Indicator (RI) modem status bit.
  504.   SioRead   | Reads the contents of the 7 UART registers.
  505.   SioGetDiv - Reads the baud rate divisor registers.
  506.  
  507.  
  508.   2.4 Serial I/O
  509.  
  510.  
  511.   There are eight library functions in  the  serial  I/O  category.  Together,
  512.   these functions give the programmer complete control over serial I/O. Higher
  513.   level  functions  such  as  protocols  and smart modem communications can be
  514.   completely implemented in terms of these functions.  Refer  to  the  example
  515.   code.
  516.  
  517.   SioGetc  and  SioPutc perform all the actual serial I/O.  SioUnGetc "ungets"
  518.   the last serial  byte  read.  SioRxFlush  clears  the  receive  queue  while
  519.   SioTxFlush  clears  the transmit queue. SioLine can be used to test for UART
  520.   errors.  SioRxQue returns the number of bytes in  the  receive  queue  while
  521.   SioTxQue returns the number of bytes in the transmit queue.
  522.  
  523.   SioGetc    - Reads the next character from the serial line.
  524.   SioPutc    | Transmit a character over a serial line.
  525.   SioUnGetc  | "Un-gets" (puts back) a specified character.
  526.   SioRxFlush | Flush (clears) the receive buffer.
  527.   SioRxQue   | Returns the number of characters in the RX queue.
  528.   SioTxFlush | Flush (clears) the transmit buffer.
  529.   SioTxQue   | Returns the number of characters in the TX queue.
  530.   SioLine    - Reads the line status register.
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  PCL4C Users Manual                                                Page 8
  545.   2.5  Error Detection
  546.  
  547.  
  548.   There are four functions in the error detection category. They are concerned
  549.   with detecting or reporting communications errors.  Use of  these  functions
  550.   can make your application significantly more robust.
  551.  
  552.   SioBrkKey  can  be  used  as  an  "emergency"  exit  from  your application.
  553.   SioBrkSig can read or  modify  the  UART  break  bit.  This  is  useful  for
  554.   signalling   the   remote  system  that  a  fatal  condition  has  occurred.
  555.   SioLoopBack can be used to  test  the  integrity  of  your  UART.   SioError
  556.   displays  a  error  message  corresponding  to an error code returned from a
  557.   PCL4C function (every PCL4C function returns a code).
  558.  
  559.   SioBrkKey - Returns non-zero if the Control-BREAK key was pressed
  560.   SioBrkSig | Asserts, cancels, or detects the RS232 BREAK  signal.
  561.   SioError  - Displays  error  in  text.
  562.   SioLoopBack - Performs a UART loopback test.
  563.  
  564.  
  565.   2.6 General Support
  566.  
  567.  
  568.   There are six functions in the general support category.  Strictly speaking,
  569.   they are not communications functions but are provided in the PCL4C  library
  570.   because  they  are  not  always available (especially in some older compiler
  571.   run-time libraries).  At any rate, they take  up  a  very  small  amount  of
  572.   additional memory. Registered users can also remove these functions from the
  573.   library if needed.
  574.  
  575.   SioInfo     - Returns the library version & memory model.
  576.   SioCrtWrite | Use BIOS to write character to the screen.
  577.   SioDelay    | Delays one or more tics (18.2 tics per second).
  578.   SioKeyPress | Use BIOS to detect if keyboard key has been pressed.
  579.   SioKeyRead  | Use BIOS to reads the keyboard.
  580.   SioTimer    - Returns the number of system clock tics.
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  PCL4C Users Manual                                                Page 9
  613.   3.0 Library Organization
  614.  
  615.  
  616.   3.1 Memory Models
  617.  
  618.  
  619.   Because  of  the  segmented  architecture  of  the INTEL CPU, there are four
  620.   memory organizations possible for computer programs.  These  are  named  the
  621.   SMALL,  COMPACT,  MEDIUM,  and  LARGE memory models, which correspond to the
  622.   four combinations of "near" and "far" addresses for code and data.
  623.  
  624.   Each executable is composed of one or more segments, where each segment  can
  625.   occupy  from  one  byte  to  64  KB of memory.  A "near" address is a 16 bit
  626.   offset in a segment, whereas a "far" address  consists  of  both  a  16  bit
  627.   segment value and a 16 bit offset.
  628.  
  629.   In the small memory model, code and data each occupy one segment. Thus, near
  630.   addresses are allocated for both code and data.
  631.  
  632.   In the compact memory model, code occupies one segment while data may occupy
  633.   multiple  segments.  Near addresses are allocated for code but far addresses
  634.   are allocated for data.
  635.  
  636.   In the medium memory model, data occupies one segment while code may  occupy
  637.   multiple  segments.  Near addresses are allocated for data but far addresses
  638.   are allocated for code.
  639.  
  640.   In the large memory model, data and code each occupy multiple segments.  Far
  641.   addesses are allocated for both code and data. Thus, both code and data  can
  642.   use as many segments as required.
  643.  
  644.   Refer  to  your  compiler  manual  for  a  discussion  of  the memory models
  645.   supported by your compiler.
  646.  
  647.   PCL4C is organized as four  separate  libraries  (PCL4C_S.LIB,  PCL4C_C.LIB,
  648.   PCL4C_M.LIB  and  PCL4C_L.LIB)  corresponding  to  the  four standard memory
  649.   models.  For the MIX Power C compiler, the small, medium, and  large  models
  650.   are  provided  (PCL4C_S.MIX,  PCL4C_M.MIX  and  PCL4C_L.MIX).   MIX  doesn't
  651.   support the compact memory model.
  652.  
  653.   MODEL      CODE      DATA     Library
  654.   Small      Near      Near     PCL4C_S.LIB & PCL4C_S.MIX
  655.   Compact    Near      Far      PCL4C_C.LIB
  656.   Medium     Far       Near     PCL4C_M.LIB & PCL4C_M.MIX
  657.   Large      Far       Far      PCL4C_L.LIB & PCL4C_L.MIX
  658.  
  659.   However, one can always use the large memory model library PCL4C_L.LIB  with
  660.   any  memory  model  application  code  by  explicitly  declaring  the  PCL4C
  661.   procedures to be FAR (by prefixing "far" before the name of each function in
  662.   the PCL4C.H file) and declaring your receive buffer to be FAR.  If  you  are
  663.   compiling with the HUGE memory mode, link with PCL4C_L.LIB.
  664.  
  665.   The   equivalent   libraries   with   transmitter   interrupts  enabled  are
  666.   PCL4C_S2.LIB, PCL4C_C2.LIB, PCL4C_M2.LIB, & PCL4C_L2.LIB.
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  PCL4C Users Manual                                                Page 10
  681.   3.2 Compilers Supported
  682.  
  683.  
  684.   At this time, five C compilers are supported by PCL4C.
  685.  
  686.   (1)  Microsoft (Optimizing) C Compiler.
  687.  
  688.   (2)  Quick C Compiler.
  689.  
  690.   (3)  Turbo C Compiler.
  691.  
  692.   (4)  Borland C Compiler.
  693.  
  694.   (5)  MIX Power C Compiler
  695.  
  696.   The Microsoft Optimizing C Compiler supports  all  memory  models.  Just  be
  697.   careful  to link with the PCL4C library that corresponds to the memory model
  698.   used. Recall that the small memory model is the default.  Examine the (small
  699.   model) makefiles *._M_ for the Microsoft compiler.
  700.  
  701.   The Microsoft Quick C Compiler supports all memory models, but be careful to
  702.   link with the PCL4C library that corresponds with  the  memory  model  used.
  703.   Recall  that  the  small  memory  model  is the default for the command line
  704.   compiler (QCL) while  the  medium  memory  model  is  the  default  for  the
  705.   interactive compiler environment.  Examine the (small model) makefiles *._Q_
  706.   for the Microsoft Quick C compiler.
  707.  
  708.   The Borland and Turbo C Compilers also support all memory models. Be sure to
  709.   link  with the correct PCL4C library corresponding to the memory model used.
  710.   Examine the (small model) makefiles *._T_ for the Turbo C compiler.
  711.  
  712.   The  MIX  Power  C  Compiler  supports  the  small, medium, and large memory
  713.   models. However, older versions of Power C only  support  the  small  model.
  714.   Examine  the  (small  model)  project  batch  files  *.PRJ  for  the Power C
  715.   Compiler.
  716.  
  717.   Other compilers may also work with one or more of the  PCL4C  libraries  but
  718.   have  not  been  tested.  Since registered users have the source code to the
  719.   library, it should not be difficult to modify PCL4C for use with any MSDOS C
  720.   compiler.  Give us a call if you have any difficulty.
  721.  
  722.  
  723.   3.3 Using the Library
  724.  
  725.  
  726.   The  PCL4C  has  been tested on a Tandy 1000 (4.77 MHZ 8088 IBM PC clone), a
  727.   Tandy 3000 (80286 IBM AT clone), a Tandy 1400LT (IBM XT  clone),  a  Gateway
  728.   2000  386 (25 MHZ 80386-DX), and a Gateway 2000 486 (66MHZ 80486-DX).  PCL4C
  729.   has also been tested under MSDOS 2.11, 3.2, 3.3, 4.01, 5.0, 6.0 and 6.2.
  730.  
  731.   Please examine the PCL4C.H file. Note that COM1 is defined as port zero, not
  732.   port  one.   The  user must assume the responsibilty for passing the correct
  733.   information when calling PCL4C functions.
  734.  
  735.   If there are any conflicts between PCL4C  definitions  and  those  in  other
  736.   libraries,  the PCL4C definitions can be changed in the PCL4C.H file and any
  737.   file that uses the definition. There is no change necessary for the  library
  738.   code itself.
  739.  
  740.   The  PCL4C  libraries  contain no references to any runtime libraries.  Only
  741.   BIOS and MSDOS functions are called.
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  PCL4C Users Manual                                                Page 11
  749.   3.4 Application Notes
  750.  
  751.  
  752.   3.4.1 Terminal Programs
  753.  
  754.  
  755.   The  "terminal  program" is the most common class of communications program.
  756.   It is used to call up a BBS or on-line service such as  CompuServe,  America
  757.   On-Line,  etc.   Refer  to  the  programs  SIMPLE and LOGIN in section 7 for
  758.   examples of simple terminal programs.
  759.  
  760.   A more sophisticated terminal program featuring ASCII, XMODEM,  YMODEM,  and
  761.   ZMODEM  protocol  file  transfers  can be found in our sister product -- The
  762.   Personal Protocol Libray (PPL4C). Source code is included in  the  shareware
  763.   distribution for everything except ZMODEM and the script intepreter.
  764.  
  765.  
  766.   3.4.2 Door Programs
  767.  
  768.  
  769.   In order to write a door program which "takes over" a  serial  port  without
  770.   resetting  the  port or changing the baud rate, call SioReset() with NORESET
  771.   as the second argument rather than the baud rate. Call  SioGetDiv()  to  get
  772.   the  baud  rate divisor if the baud rate must be determined. Be sure to call
  773.   SioDone()  before  returning  to  the  invoking program. Refer to the DOOR.C
  774.   example program.
  775.  
  776.  
  777.   3.4.3 BBS Programs
  778.  
  779.  
  780.   If you are designing a BBS program (also known as HOST  programs),  consider
  781.   using  16550  UARTS.   You  should  also choose a multiport card such as the
  782.   DigiBoard or BOCA board if you wish to run more than 4 ports simultaneously.
  783.  
  784.   If  you  are using an error correcting modem, then you should be sure to set
  785.   flow control and fix your baud rate at the highest possible transfer  rates.
  786.   For  14,400  modems, this means 19200 or 38400. You may need a 16550 UART in
  787.   order to run at the higher speed.
  788.  
  789.   If you are using an older multi-speed modem (say  1200,  2400,  4800,  9600)
  790.   that doesn't use flow control, you should change your baud rate to match the
  791.   CONNECT message baud rate.
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.  
  800.  
  801.  
  802.  
  803.  
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  PCL4C Users Manual                                                Page 12
  817.   3.5 Compiling and Linking
  818.  
  819.  
  820.   Registered  users  may  wish  to  assemble PCL4C.ASM.  Use the /MX switch in
  821.   order to disable automatic conversion from lower case to upper case.  If the
  822.   /MX switch is not used, then all PCL4C function references in C code must be
  823.   in upper case. To assemble using the Microsoft assembler:
  824.  
  825.   Model    Command
  826.  
  827.   Small    MASM PCL4C /DSMALL_MODEL   /DMSC_IO /MX;
  828.   Compact  MASM PCL4C /DCOMPACT_MODEL /DMSC_IO /MX;
  829.   Medium   MASM PCL4C /DMEDIUM_MODEL  /DMSC_IO /MX;
  830.   Large    MASM PCL4C /DLARGE_MODEL   /DMSC_IO /MX;
  831.  
  832.   To enable transmitter interrupts, add "/DSET_TBE" to each MASM command  line
  833.   above.
  834.  
  835.   For example, to make the (small) model PCL4C.OBJ into a library file:
  836.  
  837.         DEL PCL4C_S.LIB
  838.         LIB PCL4C_S.LIB+PCL4C,PCL4C.MAP;
  839.  
  840.   If  you  are using the MIX Power C Compiler, create the MIX object file (you
  841.   will need version 1.3 of MIX which has the /_ switch):
  842.  
  843.         MIX /_ PCL4C_S
  844.  
  845.   Similarly with the  other  memory  model  libaries.   See  the  batch  files
  846.   MAKE_S.BAT,   MAKE_C.BAT,   MAKE_M.BAT,   and   MAKE_L.BAT.  Similiarly  for
  847.   MAKE_ST.BAT, MAKE_CT.BAT, MAKE_MT.BAT, and MAKE_LT.BAT.
  848.  
  849.   To compile and link (small model) using Microsoft C:
  850.  
  851.         CL /AS SIMPLE.C /LINK PCL4C_S.LIB
  852.  
  853.   To compile and link (small model) using Microsoft Quick C:
  854.  
  855.         QCL /AS SIMPLE.C /LINK PCL4C_S.LIB
  856.  
  857.   To compile and link (small model) using Borland C:
  858.  
  859.         BCC -ms SIMPLE.C PCL4C_S.LIB
  860.  
  861.   To compile and link (small model) using Turbo C:
  862.  
  863.         TCC -ms SIMPLE.C PCL4C_S.LIB
  864.  
  865.   To compile and link (small model) using Power C:
  866.  
  867.         PC /ms SIMPLE.C
  868.         PCL SIMPLE PCL4C_S.MIX
  869.  
  870.   Makefiles or project files are  provided  for  all  example  code.   Borland
  871.   makefiles  end  with  the  extension  '._B_', Turbo C makefiles with '._T_',
  872.   Microsoft C makefiles end with '._M_', Microsoft Quick C makefiles files end
  873.   with '._Q_', and Power C project batch files end with '.PRJ'.
  874.  
  875.   The  PCL4C  libraries  may  also  be  used   with   integrated   development
  876.   environments.  Place all required files along with the library corresponding
  877.   to the memory model being used into the project file.
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  PCL4C Users Manual                                                Page 13
  885.   4.0 Talking to Your Modem
  886.  
  887.  
  888.   A  modem  is  used  to  extend  the distance over which you may communicate.
  889.   Without a modem, your RS232 cable is limited to a maximum  of  approximately
  890.   50 feet.  But with a modem, you can communicate literally around the world.
  891.  
  892.   Also refer to Section 4.3 for details on MODEM_IO functions. These functions
  893.   faciliate communications with modems.
  894.  
  895.  
  896.   4.1 Modem Standards
  897.  
  898.  
  899.   Two modems can communicate over a telephone line only if they are both using
  900.   the  same  signaling frequencies and modulation, which are determined by the
  901.   the modem standards used.  Modem standards can be divided into  three  sets:
  902.   (1) speed, (2) data compression used, and (3) error control.
  903.  
  904.   The  Bell  standards  (103  &  212A)  are  those  of  AT&T.   The CCITT (The
  905.   International Consultative Committee for Telephone and Telegraph)  standards
  906.   are designated as "V. ".
  907.  
  908.  
  909.   Speed
  910.  
  911.  
  912.   Bell 103  -   300 baud
  913.   Bell 212A |  1200 baud
  914.   V.21      |   300 baud
  915.   V.22bis   |  1200 & 2400 baud
  916.   V.32      |  4800 & 9600 baud
  917.   V.32bis   |  4800, 7200, 9600, 12000, and 14400 baud
  918.   V.34      -  through 28800 baud
  919.  
  920.   Data Compression
  921.  
  922.  
  923.   MNP 5     -  Microcom Networking Protocol (proprietary).
  924.   V.42bis   -  International data compression standard.
  925.  
  926.  
  927.   Error Control
  928.  
  929.  
  930.   MNP 2,3,4 -  Three level error correction (public domain).
  931.   V.42      -  International error correction standard.
  932.  
  933.  
  934.   Most of the newer high speed modems use  several  of  the  above  standards.
  935.   However,  not  all  combinations of modem makes communicate easily with each
  936.   other, especially at high speeds (9600 and up).
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  PCL4C Users Manual                                                Page 14
  953.   4.2 Flow Control
  954.  
  955.  
  956.   With modems using data compression, the modem to modem connection  will  run
  957.   at  various  speeds  depending  on the quality of the line.  The computer to
  958.   modem connection will be at a fixed baud rate. Therefore, a  protocol  (flow
  959.   control)  is  necessary to synchronize the data flow between a modem and the
  960.   computer to  which  it  is  connected.   Refer  to  your  modem  manual  for
  961.   information on flow control protocols supported.
  962.  
  963.   Two  flow  control  protocols  are  used  by  most modems which require flow
  964.   control.  Software flow control is called "XON/XOFF"  (other  software  flow
  965.   control  character  pairs  are defined but operate the same as XON/XOFF) and
  966.   hardware flow control is called "RTS/CTS".  Most modems which  require  flow
  967.   control enable hardware flow control by default.
  968.  
  969.   In XON/XOFF (software) flow control, the computer suspends transmitting data
  970.   if it receives a XOFF character (13  hex)  from  the  modem,  and  continues
  971.   transmitting  when  it  receives  a XON character (11 hex).  Similiarly, the
  972.   computer can signal the modem not to send any more data  by  transmitting  a
  973.   XOFF  to  it,  and  can tell the modem to continue transmission be sending a
  974.   XON.
  975.  
  976.   In RTS/CTS (hardware) flow control, the RTS line is used by the computer  to
  977.   signal  the  modem  ,  while the CTS line is used by the modem to signal the
  978.   computer.  The RTS line is set OFF by the computer  to  tell  the  modem  to
  979.   suspend  transmission,  and  set  to  ON  to  tell  the  modem  to  continue
  980.   transmission.  The CTS line is set to OFF by the modem to tell the  computer
  981.   to  stop  transmitting,  and  set  to  ON  to  tell the computer to continue
  982.   transmitting.
  983.  
  984.   Given the choice, always choose hardware flow  control  over  software  flow
  985.   control  so  that  all  data  transmission is transparent.  If hardware flow
  986.   control is not the default (which it almost always is),  you  should  modify
  987.   your modem initialization string to turn hardware flow control on.
  988.  
  989.   Both  software  and  hardware flow control is easy to implement using PCL4C.
  990.  
  991.  
  992.   4.3 MODEM_IO Functions
  993.  
  994.  
  995.   The file MODEM_IO.C contains several functions that ease communicating  with
  996.   your  modem.  Look in the LOGIN.C code for examples of their use. Registered
  997.   users can also see examples in the script interpreter SI.C.
  998.  
  999.        ModemSendTo   : Sends string (including control chars) to the modem.
  1000.        ModemWaitFor  : Waits for a particular string from the modem, passing
  1001.                        all else through.
  1002.        ModemQuiet    : Waits for continuous quiet of specified duration.
  1003.        ModemHangup   : Hangs up the modem.
  1004.        ModemCmdState : Goes into the modem's command state.
  1005.        ModemEcho     : Echos all serial incoming bytes to the display.
  1006.  
  1007.  
  1008.  
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  PCL4C Users Manual                                                Page 15
  1021.   4.4 Modem Initialization
  1022.  
  1023.  
  1024.   If your application uses a modem (as opposed to using a null  modem  cable),
  1025.   then  you should always send an initialization string to your modem if it is
  1026.   a programmable modem such as those made by  Hayes.   Communication  programs
  1027.   such as PROCOMM and TELIX always send such a string automatically as soon as
  1028.   they start up.
  1029.  
  1030.   The particular initialization string depends on the make of your modem.  For
  1031.   Hayes  and  Hayes  AT  command  set  compatible modems, the following string
  1032.   (followed by a carriage return) may work:
  1033.  
  1034.        AT E1 S7=60 S11=60 V1 X1 Q0 S0=0
  1035.  
  1036.   Refer to your Modem User's Guide for a full discussion of these commands.  A
  1037.   brief description is as follows:
  1038.  
  1039.   AT     Modem attention command.
  1040.   E1     Modem will echo what you send to it.
  1041.   S7=60  Wait 60 seconds for carrier and/or dial tone.
  1042.   S11=60 Use 60 milliseconds for tone dialing duration & spacing.
  1043.   V1     Display result code as words (not numbers).
  1044.   X1     Use the extended result message (CONNECT XXXX) set.
  1045.   Q0     Modem returns result codes.
  1046.   S0=0   Do not answer RING.
  1047.  
  1048.   If  your application will answer incoming calls, then set the S0 register to
  1049.   the ring on which to automatically answer.
  1050.  
  1051.   If you send the above codes by using SioPutc (as opposed to typing them from
  1052.   the keyboard), then follow these guidelines:
  1053.  
  1054.   (1) Send an initial carriage return before the initialization string.
  1055.  
  1056.   (2) Pause at least two tics (18 tics to the  second)  after  each  character
  1057.   sent  as  your  modem needs the time to perform its own internal processing.
  1058.   Pause a little longer if your modem is  not  accepting  your  initialization
  1059.   string.
  1060.  
  1061.   (3)  Pause  one  and a half seconds after sending any initialization command
  1062.   such as ATZ or AT&F since your modem must do quite a bit of processing.
  1063.  
  1064.   If you experience any problems in initializing your Hayes modem, you  should
  1065.   first reset it to factory settings by sending:
  1066.  
  1067.        AT&F
  1068.  
  1069.   Your modem may require more initialization than presented  above.  Refer  to
  1070.   your  modem manual for details. If you have a communications program such as
  1071.   ProComm or Telix that is known to initialize your modem correctly, then  you
  1072.   may wish to use the same initialization string.
  1073.  
  1074.   Refer to the LOGIN program (functions ModemSendTo  and  ModemWaitFor  in  the
  1075.   file  MODEM_IO.C)  for  an  example of sending an initialization string to a
  1076.   Hayes compatible modem.
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  PCL4C Users Manual                                                Page 16
  1089.   5.0 Problems
  1090.  
  1091.  
  1092.   If  you  cannot  get your application to run properly, first compile and run
  1093.   the terminal emulator program SIMPLE provided on your distribution  disk.
  1094.  
  1095.   If your application does not run but SIMPLE runs correctly,  then  you  have
  1096.   most  likely  made  a programming mistake in your application.  MarshallSoft
  1097.   Computing cannot debug your  application,  especially  over  the  telephone!
  1098.   However,  consider each of the following when searching for an error in your
  1099.   application.
  1100.  
  1101.   1.  Have you included the file PCL4C.H in your application ?
  1102.  
  1103.   2.  Did you link with the correct PCL4C library ?  This is the most probable
  1104.   cause  if your application 'hangs' as soon as it starts and you must reboot.
  1105.   The function SioInfo('M') returns the model ID under which the  library  was
  1106.   assembled.
  1107.  
  1108.   3.  Is your receive buffer large enough ? If you are using 1K data blocks in
  1109.   YMODEM,  then  your  receive  buffer should be at least 1K (2K if baud rates
  1110.   above 19200 are to be used).
  1111.  
  1112.   4.  Have you selected too high a baud rate (if you are using a slow PC) ? If
  1113.   only one COM port is being run, you should be able to run at 38400  baud  on
  1114.   8088 machines and 115200 on most 286 and all 386 and 486 machines.
  1115.  
  1116.   5.   Are  you attempting to run another application in the background ?  Try
  1117.   running without any other programs running in the background (unload all TSR
  1118.   programs).
  1119.  
  1120.   6.  If you are running two COM ports simultaneously, are you using  separate
  1121.   receive buffers ? (you should).
  1122.  
  1123.   7.   Did SioReset return a zero value ?  If not, then you must call SioReset
  1124.   again. See SIMPLE.C for an example.
  1125.  
  1126.   8.  Did you send the proper initialization string to your modem  ?  Did  you
  1127.   set DTR and RTS ? (you should).
  1128.  
  1129.   9.   Do  you  have more than one COM1 port, etc.  For example, if you have a
  1130.   COM1 port on your motherboard, you cannot add another  COM1  port  or  modem
  1131.   board that uses COM1 without first disabling the COM1 on the motherboard.
  1132.  
  1133.   10.   Your  first  comm  port should be COM1.  If you have a second port, it
  1134.   should be COM2, not COM3 or COM4.
  1135.  
  1136.   11.  Are you passing the proper segment of the receive (or transmit) buffer?
  1137.   See SIMPLE.C for an example.
  1138.  
  1139.  
  1140.  
  1141.  
  1142.  
  1143.  
  1144.  
  1145.  
  1146.  
  1147.  
  1148.  
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  PCL4C Users Manual                                                Page 17
  1157.   6.0 Serial Communications
  1158.  
  1159.  
  1160.   6.1 Communications Basics
  1161.  
  1162.  
  1163.   The heart of serial  communications  is  the  UART  (Universal  Asynchronous
  1164.   Receiver  Transmitter).   The  IBM PC/XT/AT and compatibles use the INS8250,
  1165.   INS16450, or the INS16550 UART.  The purpose of the UART is:
  1166.  
  1167.   (1) To convert bytes from the CPU (Central Processing Unit), into  a  serial
  1168.   format  by  adding  the  necessary start, stop, and parity bits to each byte
  1169.   before transmission, and to then transmit each bit at the correct baud rate.
  1170.  
  1171.   (2) To convert the incoming stream (at a specified baud rate) of serial bits
  1172.   into bytes by removing the start, stop, and parity bits  before  being  made
  1173.   available to the CPU.
  1174.  
  1175.   The  UART  is part of the serial interface circuitry which allows the CPU to
  1176.   send and receive signals over the RS232 lines. This  can  be  diagrammed  as
  1177.   follows:
  1178.  
  1179.  
  1180.                         Serial Interface
  1181.                      +-------------------+
  1182.                      |                   |
  1183.   +-----+  Data Bus  |     +------+      |    RS232 Signals
  1184.   | CPU +------------+     | UART |      +----------------*
  1185.   +-----+            |     +------+      |
  1186.                      |                   |
  1187.                      +-------------------+
  1188.  
  1189.  
  1190.   The INS8250/16450/16550 UART is capable of operating in one  of  two  modes,
  1191.   "polled" and "interrupt driven".  The serial communications functions in the
  1192.   BIOS  uses  the  polled method.  In this approach, the CPU is typically in a
  1193.   loop asking the UART over and over again if it has a byte ready. If it does,
  1194.   the polling code returns the byte.  But, if the next byte  comes  in  before
  1195.   the polling code is executing again, then that byte is lost.
  1196.  
  1197.   In  the  interrupt driven approach (used by PCL4C for incoming data), when a
  1198.   byte is received by the UART, an interrupt is generated and  the  "Interrupt
  1199.   Service  Routine"  (ISR)  is  executed  immediately,  suspending temporarily
  1200.   whatever else is executing. The ISR then moves the byte to a buffer so  that
  1201.   your  application  program  can  later  read it. Refer to section 6.6 "RS232
  1202.   Signals", and section 6.7 "National INS8250, INS16450  and  INS16550  UARTs"
  1203.   for further information on these topics.
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209.  
  1210.  
  1211.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  PCL4C Users Manual                                                Page 18
  1225.   6.2 Standard Port Addresses
  1226.  
  1227.  
  1228.   There  are  a  few  things to know about how serial communications ports are
  1229.   used by IBM PC/XT/AT and compatible computers.  The  standard  IBM  PC/XT/AT
  1230.   configuration values are as follows:
  1231.  
  1232.   Port    Reg.   IRQ  Vector
  1233.   COM1    3F8H    4     12
  1234.   COM2    2F8H    3     11
  1235.   COM3    3E8H    4     12
  1236.   COM4    2E8H    3     11
  1237.  
  1238.   (Refer to your DigiBoard manual for DigiBoard addresses, or your BOCA  board
  1239.   manual for BOCA port addresses).
  1240.  
  1241.   PCL4C  assumes the above values.  If necessary, the UART base address can be
  1242.   changed by SioUART, and IRQ lines can be re-assigned  by  SioIRQ.   Remember
  1243.   that  each  port to be used concurrently must have a unique IRQ line.  Refer
  1244.   to the PCL4C Reference Manual for specific details.
  1245.  
  1246.   When installing new  communications  cards,  the  following  guidelines  are
  1247.   recommended:
  1248.  
  1249.   (1)  Be  sure to read the documentation for the hardware you are installing.
  1250.   Pay special attention to UART base addresses and IRQ lines, particularly  if
  1251.   trying to set up a non-standard configuration.
  1252.  
  1253.   (2)  If  you  have  a  choice in base addresses and IRQ lines, always choose
  1254.   standard values as defined above.
  1255.  
  1256.   (3) The first port should be COM1, the second COM2, etc.  Do NOT  skip  over
  1257.   any port.
  1258.  
  1259.   (4)  Use SioUART to zero all unused ports (for example, call SioUART(COM4,0)
  1260.   if there is no COM4 port installed).
  1261.  
  1262.   (5) Be carefull not to configure two ports for the  same  address.  This  is
  1263.   easier to do than you may believe.
  1264.  
  1265.   (6)  Choose  an  external  modem over an internal one.  It is much easier to
  1266.   debug problems with an external modem than an internal one.
  1267.  
  1268.   (7) Select hardware flow control (RTS/CTS) if flow control is  required  and
  1269.   hardware flow control is not the default.
  1270.  
  1271.   (8)  Always  test your port as soon as it is installed. Try several programs
  1272.   that use the communications ports.
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  PCL4C Users Manual                                                Page 19
  1293.   6.3 Running 3 or 4 Ports Concurrently
  1294.  
  1295.  
  1296.   PCL4C supports up to 4 serial ports running concurrently (more if you have a
  1297.   DigiBoard or BOCA board).  One free interrupt for  each  port  is  required.
  1298.   Refer to the next section if you have a DigiBoard or BOCA board.
  1299.  
  1300.   Interrupts  IRQ4  and  IRQ3  are  dedicated to the communications ports in a
  1301.   standard IBM PC/XT/AT configuration.  IRQ4 is shared between COM1  and  COM3
  1302.   while IRQ3 is shared between COM2 and COM4.  This means that you can run two
  1303.   ports simultaneously provided that they don't share an interrupt.
  1304.  
  1305.   Suppose that you wish to run 3 ports simultaneously. To begin, you must have
  1306.   3  serial  UARTs  installed  on your computer.  Assume, for purposes of this
  1307.   discussion, that COM1 is installed on your motherboard, and  that  you  have
  1308.   purchased a new 2 port serial communications board.
  1309.  
  1310.   You  should  be able to configure the first serial board port as COM2, which
  1311.   uses IRQ3.  Refer to the manual that came with your serial board.
  1312.  
  1313.   In order to run the third serial port concurrently with the  first  two,  an
  1314.   unused  interrupt  must be found.  If your serial card can use only IRQ3 and
  1315.   IRQ4, then there is no way to run a third line since IRQ4 and IRQ3 are  used
  1316.   for COM1 and COM2.
  1317.  
  1318.   However,  many serial cards can use other IRQs, typically IRQ2 through IRQ5.
  1319.   Since IRQ5 is normally used  for  a  second  printer  port,  it  is  a  good
  1320.   candidate  for  COM3.  To use IRQ5 for the third serial port, first set your
  1321.   serial card to use IRQ5 for COM3 (refer to your serial card manual) and then
  1322.   add the following line to your applications code before calling SioReset:
  1323.  
  1324.          SioIRQ(COM3,IRQ5);
  1325.  
  1326.   Don't forget to disable any device that might use IRQ5,  such  as  a  second
  1327.   printer  port  or  a  music  card.   Unfortunately,  there is no easy way to
  1328.   determine that you have no conflicts until you actually attempt to  use  the
  1329.   IRQ.  If  there  are  conflicts, your system will probably hang and you will
  1330.   have to reboot.
  1331.  
  1332.   To run a fourth serial port, another  free  IRQ  must  be  found.   On  some
  1333.   systems, IRQ7 can be used. To use IRQ7 for the fourth serial port, first set
  1334.   your serial card to use IRQ7 for COM4 and then add:
  1335.  
  1336.          SioIRQ(COM4,IRQ7);
  1337.  
  1338.   To  summarize,  your  serial  card must be able to generate the correct IRQ,
  1339.   which is not already being used. Refer to the entry for the SioIRQ  function
  1340.   in the PCL4C Reference Manual.
  1341.  
  1342.  
  1343.  
  1344.  
  1345.  
  1346.  
  1347.  
  1348.  
  1349.  
  1350.  
  1351.  
  1352.  
  1353.  
  1354.  
  1355.  
  1356.  
  1357.  
  1358.  
  1359.  
  1360.  PCL4C Users Manual                                                Page 20
  1361.   6.4 Using Multiport Cards
  1362.  
  1363.  
  1364.   The  PCL4C  library  supports  the dumb Digiboard (PC/4 & PC/8) and the dumb
  1365.   BOCA board (BB1004, BB1008, and BB2016).
  1366.  
  1367.   6.4.1 The DigiBoard
  1368.  
  1369.   PCL4C supports the DigiBoard PC/4 and PC/8. In order to use  the  DigiBoard,
  1370.   you  must  configure  PCL4C  using  the  SioPorts(), SioUART(), and SioIRQ()
  1371.   functions.
  1372.  
  1373.   Your  PC's  ports must be partitioned into "standard" PC ports and dumb card
  1374.   ports.  Remember that standard PC ports cannot share IRQs like the DigiBoard
  1375.   (or BOCA board) can. If you are using IRQ4 and IRQ3 for  standard  PC  ports
  1376.   COM1  and  COM2, then you cannot use either for DigiBoard ports (try IRQ5 or
  1377.   IRQ7).
  1378.  
  1379.   Suppose  that  COM1 through COM2 are standard PC ports (using IRQ4 and IRQ3)
  1380.   and you have installed a PC/8 DigiBoard  that  you  wish  to  use  for  COM3
  1381.   through  COM10 using interrupt line IRQ5.  You choose to use the recommended
  1382.   DigiBoard UART addresses starting at 0x100:
  1383.  
  1384.   SioPorts(10,COM3,0x140,DIGIBOARD);  /* COM3 = 1st DigiBoard port */
  1385.   Address = 0x100;                    /* 1st DigiBoard UART address */
  1386.   for(Port=COM3;Port<=COM10;Port++)   /* look at each port */
  1387.      {SioUART(Port,Address);          /* set the UART address */
  1388.       Address  += 8;                  /*  compute next address */
  1389.       SioIRQ(Port,IRQ5);              /* set the DigiBoard IRQ */
  1390.      }
  1391.  
  1392.   The DigiBoard uses 0x140 for the status address for odd interrupts and 0x141
  1393.   for even interrupts.
  1394.  
  1395.   Digiboard  may  be  contacted  at  6400 Flying Cloud Drive, Eden Prairie, MN
  1396.   55344.  Telephone 612-943-9020 or FAX 612-943-5398.
  1397.  
  1398.   6.4.2 The BOCA Board
  1399.  
  1400.   PCL4C supports the  dumb  BOCA  board.  As  with  the  DigiBoard,  you  must
  1401.   configure PCL4C before using the BOCA board.
  1402.  
  1403.   For  example,  to  configure the BOCA BB2016 to use COM1 to COM16, with base
  1404.   addresses starting at 0x100 and IRQ5:
  1405.  
  1406.     SioPorts(16,COM1,0x107,BOCABOARD);/* COM3 = 1st BOCA board port */
  1407.     Address = 0x100;                  /* 1st BOCA UART address */
  1408.     for(Port=COM1;Port<=COM16;Port++) /* look at each port    */
  1409.       {SioUART(Port,Address);         /* set the UART address */
  1410.        Address += 8;                  /* compute next address */
  1411.        SioIRQ(Port,IRQ15);            /* set the BOCA IRQ */
  1412.       }
  1413.  
  1414.   BOCA may be contacted at BOCA Research, Inc., 6413  Congress  Avenue,  Suite
  1415.   130, Boca Raton, FL 33487.  Phone 407-241-8088, FAX 407-997-0918.
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  PCL4C Users Manual                                                Page 21
  1429.   6.5 Transmitter Interrupts
  1430.  
  1431.  
  1432.   Beginning with version 4.0 of PCL4C, transmitter interrupts are supported by
  1433.   the   library.   Separate  libraries  are  provided,  one  with  transmitter
  1434.   interrupts enabled and one without.  When  transmitter  interrupts  are  NOT
  1435.   enabled, the following logic occurs everytime you call SioPutc():
  1436.  
  1437.    1. Wait for transmit buffer to become empty. The transmit
  1438.       buffer may not be empty if the previous transmit is not
  1439.       completed (the UART breaks down the byte & sends 1 bit
  1440.       at a time).
  1441.  
  1442.    2. When the transmit buffer is empty, the byte from the
  1443.       SioPutc() call is loaded into the transmit buffer and
  1444.       control is returned to the caller.
  1445.  
  1446.   Note that you can not write to the UART any faster than the UART baud rate.
  1447.  
  1448.   When transmitter interrupts are enabled, the byte from SioPutc() is put into
  1449.   a previously prepared (by SioTxQue) transmitter queue. The interrupt service
  1450.   routine fetches bytes from this queue as soon as the previous byte has  been
  1451.   sent.
  1452.  
  1453.   While  you can now call SioPutc() faster than the baud rate, bytes are still
  1454.   transmitted at the given baud rate.
  1455.  
  1456.   The  above  sounds  like  transmitter  interrupts  are  the   way   to   go.
  1457.   Unfortunately,  this  is often NOT the case.  Most applications will perform
  1458.   better if transmitter interrupts are NOT enabled.
  1459.  
  1460.   The  reason  is that transmitter interrupts double the amount of code in the
  1461.   time critical interrupt service routines.  While the library is processing a
  1462.   transmitter interrupt (which can take a while), incoming bytes  can  not  be
  1463.   processed.  What this means is that a given machine can run at a higher baud
  1464.   rate without transmitter interrupts. This problem is compounded when running
  1465.   multiple ports simultaniously.
  1466.  
  1467.   However, there are a few application areas where transmitter interrupts  are
  1468.   preferable.   If  your  application  will  be transmitting blocks of data at
  1469.   fairly slow baud rates you might profit from enabling transmitter interrupts
  1470.   provided that there is something else for the processor to do (which is  NOT
  1471.   the case in most protocols).
  1472.  
  1473.   Recall  that  PCL4C_S2.LIB  (small),  PCL4C_C2.LIB  (compact),  PCL4C_M2.LIB
  1474.   (medium), and PCL4C_L2.LIB (large) are the four memory model libraries  with
  1475.   transmitter interrupts enabled.
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  PCL4C Users Manual                                                Page 22
  1497.   6.6 RS-232 Signals
  1498.  
  1499.  
  1500.   RS-232  is  the  name  of the serial data interface standard used to connect
  1501.   computers to modems.  Most IBM compatible computers are built with at  least
  1502.   one serial port and use either DB9 (9 pin) or DB25 (25 pin) connectors.
  1503.  
  1504.   A  summary  of  these  pins  and  their function follows.  For more detailed
  1505.   information, refer to one of the many books dealing with RS-232 interfacing.
  1506.  
  1507.   Signal Ground Pin 7 (DB25), Pin 5 (DB9)
  1508.  
  1509.   The SG line is used  as  the  common  signal  ground,  and  must  always  be
  1510.   connected.
  1511.  
  1512.   Transmit Data Pin 2 (DB25), Pin 3 (DB9)
  1513.  
  1514.   The TX line is used to carry data from the computer to the modem.
  1515.  
  1516.   Receive Data Pin 3 (DB25), Pin 2 (DB9)
  1517.  
  1518.   The RX line is used to carry data from the modem to the computer.
  1519.  
  1520.   Data Terminal Ready Pin 20 (DB25), Pin 4 (DB9)
  1521.  
  1522.   The  DTR  line is used by the computer to signal the modem that it is ready.
  1523.   DTR should be set high when talking to a modem.
  1524.  
  1525.   Data Set Ready Pin 6 (DB25), Pin 6 (DB9)
  1526.  
  1527.   The DSR line is used by the modem to signal the computer that it is ready.
  1528.  
  1529.   Request to Send Pin 4 (DB25), Pin 7 (DB9)
  1530.  
  1531.   The RTS line is used to "turn the line around" in half  duplex  modems,  and
  1532.   for hardware flow control in most modems that require flow control.
  1533.  
  1534.   Clear to Send Pin 5 (DB25), Pin 8 (DB9)
  1535.  
  1536.   The  CTS  line  is used to "turn the line around" in half duplex modems, and
  1537.   for hardware flow control in most modems that require flow control.
  1538.  
  1539.   Data Carrier Detect Pin 8 (DB25), Pin 1 (DB9)
  1540.  
  1541.   The DCD line is used by the modem to signal the computer that a data carrier
  1542.   signal is present.
  1543.  
  1544.   Ring Indicator Pin 22 (DB25), Pin 9 (DB9)
  1545.  
  1546.   The RI line is asserted when a 'ring' occurs.
  1547.  
  1548.  
  1549.  
  1550.  
  1551.  
  1552.  
  1553.  
  1554.  
  1555.  
  1556.  
  1557.  
  1558.  
  1559.  
  1560.  
  1561.  
  1562.  
  1563.  
  1564.  PCL4C Users Manual                                                Page 23
  1565.   6.7 National INS8250, INS16450, and INS16550 UARTs
  1566.  
  1567.  
  1568.   The Personal Communications  Library  is  based  on  the  standard  National
  1569.   INS8250,  INS16450,  and INS16550 UARTs. The 8250 was the original UART used
  1570.   in the IBM PC, whereas the 16450 is a faster version found on most 286 &  up
  1571.   machines. The 16550 contains a 16 byte FIFO to further reduce communications
  1572.   overhead. These UARTs consists of 8 register ports as follows:
  1573.  
  1574.   Offset    R/W   Register
  1575.     0       R/W   Receiver (read) / Transmitter (write)
  1576.     1       R/W   Interrupt Enable (read)
  1577.     2       R     Interrupt Identification
  1578.     2       W     FIFO control (INS16550 only)
  1579.     3       R/W   Data Format (Line Control)
  1580.     4       R/W   RS-232 (Modem) Control
  1581.     5       R/W   Line Status
  1582.     6       R/W   RS-232 (Modem) Status
  1583.     7       R/W   Not used.
  1584.  
  1585.   For  the standard PC ports (not DigiBoard or BOCA ports), the UART registers
  1586.   are based at 3F8h (COM1), 2F8h (COM2), 3E8h (COM3), and 2E8h  (COM4).   COM1
  1587.   and COM3 share interrupt request line IRQ4 while COM2 and COM4 share request
  1588.   line  IRQ3.   This  means  that  COM1  and  COM3 can't be used concurrently.
  1589.   Similarly for COM2 and COM4.
  1590.  
  1591.   If you have a DigiBoard (or BOCA board) installed, you will have 4  or  more
  1592.   additional  ports  using  INS16450 or INS16550 UARTS.  The default DigiBoard
  1593.   and BOCA board ports are located at 100h, 108h, 110h,  etc.  Refer  to  your
  1594.   DigiBoard (or BOCA board) manual.
  1595.  
  1596.   Four  sources  of  interrupts  are  possible  with  the  8250 and 16550: (1)
  1597.   receiver error or BREAK, (2) receiver data ready, (3) ready to transmit, and
  1598.   (4) RS232 input.   These  four  sources  of  interrupts  are  summarized  as
  1599.   follows:
  1600.  
  1601.   Source of Interrupt        Action Required to Clear
  1602.   Receiver error or BREAK.   Read Line Status register.
  1603.   Receiver data.             Read data from data register.
  1604.   Transmitter Buffer Empty.  Write to data register or read IID reg.
  1605.   RS232 input.               Read Modem Status register.
  1606.  
  1607.   However,  PCL4C  only  enables the receiving data interrupt. This means that
  1608.   interrupts can only be caused by incoming data.
  1609.  
  1610.   If you are not familiar with the INS8250, several good books are  available.
  1611.   Refer  to the Serial Communications chapter for recommendations.  Although a
  1612.   knowledge of the 8250 is not necessary to use PCL4C, a general knowledge  of
  1613.   the theory of asynchronous serial communications is recommended.
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  PCL4C Users Manual                                                Page 24
  1633.   6.8 Register Summary
  1634.  
  1635.  
  1636.   REG 0 : Data Register
  1637.  
  1638.   Reading  from  the  data  register  fetches  the next input byte, once it is
  1639.   ready.  Writing to the data register transmits the byte written to  it  over
  1640.   the serial line.
  1641.  
  1642.   REG 1 : Interrupt Enable 
  1643.  
  1644.   The  Interrupt Enable register enables each of four types of interrupts when
  1645.   the appropriate bit is set to a one.
  1646.  
  1647.   bit 3 : Enable interrupt on RS232 input.
  1648.   bit 2 : Enable interrupt on receiver error or break.
  1649.   bit 1 : Enable interrupt on transmitter buffer empty (TBE).
  1650.   bit 0 : Enable interrupt on received data (RxRDY).
  1651.  
  1652.   REG 2 : Interrupt Identification (IID)
  1653.  
  1654.   Reading  the Interrupt Identification (read only) register once an interrupt
  1655.   has occurred identifies the interrupt as follows:
  1656.  
  1657.   Bit 2  Bit 1  Bit 0  Priority    Interrupt
  1658.     0      0      1      none      none
  1659.     1      1      0      0 (high)  Serialization or break.
  1660.     1      0      0      1         Received data.
  1661.     0      1      0      2         Transmitter Buffer Empty.
  1662.     0      0      0      3 (low)   RS232 Input.
  1663.  
  1664.   In the INS16650, REG 2 (write only)  is  also  the  FIFO  control  register.
  1665.   Writing bits 6 & 7 will set the FIFO trigger level (number of bytes received
  1666.   before an interrupt is generated).
  1667.  
  1668.   Bit 7  Bit 6   Trigger             Bit 7  Bit 6   Trigger
  1669.    0      0      1 byte               1      0      8 bytes
  1670.    0      1      4 bytes              1      1      14 bytes
  1671.  
  1672.   REG 3 : Line Control
  1673.  
  1674.   RS232 line parameters are selected by writing to this register.
  1675.  
  1676.   bit 7   : DLAB = 0
  1677.   bit 6   : BREAK on(1), off(0).
  1678.   bits 5-3: Parity None(000),ODD(001),EVEN(011),MARK(101),SPACE(111)
  1679.   bit 2   : One stop bit(0), two stop bits(1).
  1680.   bits 1-0: Data bits = 5 (00), 6(01), 7(10), 8(11).
  1681.  
  1682.   When  the Divisor Latch Access Bit (DLAB) is 1, registers 0 and 1 become the
  1683.   LS and MS bytes of the Baud Rate Divisor registers.
  1684.  
  1685.   Baud   Divisor      Baud  Divisor      Baud  Divisor
  1686.    300    0180        4800   0018       38400   0003
  1687.   1200    0060        9600   000C       57600   0002
  1688.   2400    0030       19200   0006      115200   0001
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  PCL4C Users Manual                                                Page 25
  1701.   REG 4 : Modem Control
  1702.  
  1703.   RTS, DTR, loopback testing, and  General  Purpose  Outputs  #1  and  #2  are
  1704.   controlled by the Modem Control register as follows:
  1705.  
  1706.   bit 4 : Enable local loopback.
  1707.   bit 3 : Enable GP02. Necessary for 8250 interrupts.
  1708.   bit 2 : Enable GP01.
  1709.   bit 1 : Set / clear RTS.
  1710.   bit 0 : Set / clear DTR.
  1711.  
  1712.   REG 5 : Line Status
  1713.  
  1714.   Reading  the  Line Status register provides status information as follows (1
  1715.   for TRUE, 0 for FALSE) :
  1716.  
  1717.   bit 6 : Transmitter Empty.
  1718.   bit 5 : Transmitter Buffer Empty (TBE).
  1719.   bit 4 : BREAK detect.
  1720.   bit 3 : Framing error.
  1721.   bit 2 : Parity error.
  1722.   bit 1 : Overrun error.
  1723.   bit 0 : Data Ready.
  1724.  
  1725.   REG 6 : Modem Status
  1726.  
  1727.   Reading the Modem Status register provides the following status  information
  1728.   (1 for TRUE, 0 for FALSE) :
  1729.  
  1730.   bit 7 : DCD status.
  1731.   bit 6 : RI status.
  1732.   bit 5 : DSR status.
  1733.   bit 4 : CTS status.
  1734.   bit 3 : Delta DCD status.
  1735.   bit 2 : Delta RI status.
  1736.   bit 1 : Delta DSR status.
  1737.   bit 0 : Delta CTS status.
  1738.  
  1739.   The  delta  bits  (bits 0 through 3) are set whenever one of the status bits
  1740.   (bits 4 through 7) changes (from 0 to 1 or from 1 to 0) since the last  time
  1741.   that  the  Modem Status register was read. Reading the Modem Status register
  1742.   clear the delta bits.
  1743.  
  1744.   REG 7 : Scratch Register
  1745.  
  1746.   There is no function associated with register 7.  It does not exist in early
  1747.   versions of the 8250.
  1748.  
  1749.  
  1750.  
  1751.  
  1752.  
  1753.  
  1754.  
  1755.  
  1756.  
  1757.  
  1758.  
  1759.  
  1760.  
  1761.  
  1762.  
  1763.  
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  PCL4C Users Manual                                                Page 26
  1769.   7.0 Example Programs
  1770.  
  1771.   Four  example  programs  are  include with PCL4C.  In addition, the Personal
  1772.   Protocol Library for C (PPL4C) includes  the  terminal  program  TERM  which
  1773.   features  ASCII,  XMODEM,  YMODEM,  and ZMODEM protocol transfers.  Complete
  1774.   source code is included in the shareware product for all  of  the  protocols
  1775.   above  except  ZMODEM.   In  order  to  get  ZMODEM  source,  PPL4C  must be
  1776.   registered.
  1777.  
  1778.   7.1 MINIMAL
  1779.  
  1780.   MINIMAL is the simpliest possible communications program. It reads from  the
  1781.   serial port & displays on the screen and reads from the keyboard & sends out
  1782.   over the serial line. COM1 and 9600 baud are hard coded for simplicity.
  1783.  
  1784.   7.2 SIMPLE
  1785.  
  1786.   SIMPLE  is  a simple terminal program. It operates like MINIMAL, except that
  1787.   you specify both a port and a baud rate. For example.
  1788.  
  1789.       SIMPLE 1 9600
  1790.  
  1791.   7.3 LOGIN
  1792.  
  1793.   LOGIN is programmed to dial our support BBS (205-880-9748)  and  log  on  as
  1794.   GUEST.  Start LOGIN like SIMPLE by providing a COM port and a baud rate. For
  1795.   example,
  1796.  
  1797.      LOGIN 1 38400
  1798.  
  1799.   7.4 DOOR
  1800.  
  1801.   The  DOOR program is a simple communications program which can "take over" a
  1802.   serial port.  For example, say you  are  running  PROCOMM,  PCPLUS,  or  any
  1803.   communications  program  with  a  DOS  gateway.  Select the DOS gateway from
  1804.   PROCOMM (or whatever) and then type
  1805.  
  1806.      DOOR 1
  1807.  
  1808.   at the DOS prompt to take over port COM1.
  1809.  
  1810.   7.5 SELFTEST
  1811.  
  1812.   The SELFTEST.C program is designed to test your serial ports  provided  that
  1813.   you  have two ports which can be connected together with a null modem cable.
  1814.   SELFTEST can also be used to test your multiport board.
  1815.  
  1816.   For example, to test PC port COM1 against COM2, type:
  1817.  
  1818.      SELFTEST PC 1 2
  1819.  
  1820.   SELFTEST  may  need  to  be  configured  for  non-standard  PC ports or your
  1821.   multiport board. Refer to the SELFTEST source code for more information.
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  PCL4C Users Manual                                                Page 27
  1837.   8.0 Legal Issues
  1838.  
  1839.   8.1 Registration
  1840.  
  1841.  
  1842.   If  you  wish to register the PCL4C library, please send $65 plus $3 S&H ($6
  1843.   outside of North America) to:
  1844.  
  1845.            MarshallSoft Computing, Inc.
  1846.            Post Office Box  4543
  1847.            Huntsville AL 35815
  1848.  
  1849.   Multiple copies are available: $50 for 3 to 9, $35 for 10 to 19, and $25 for
  1850.   20 or more. A site license is also available for $495 (includes  5  sets  of
  1851.   printed documentation). We pay shipping.
  1852.  
  1853.   We accept American Express (account number, expiration date, exact  name  on
  1854.   your card, and complete AmEx billing address required), checks in US dollars
  1855.   drawn  on  a  US  bank, purchase orders (POs) from recognized US schools and
  1856.   companies listed in Dun & Bradstreet, and  COD  (street  address  and  phone
  1857.   number required) within the USA (plus a $3 COD charge).
  1858.  
  1859.   You  can  also  order PCL4C from The Public Software Library (PSL) with your
  1860.   MC, Visa, AmEx, or Discover card by  calling  800-242-4PSL  (from  overseas:
  1861.   713-524-6394)  or  by  FAX  at 713-524-6398 or by CompuServe at [71355,470].
  1862.   THESE  NUMBERS ARE FOR ORDERING ONLY. The product number for PCL4C is 10908.
  1863.   Please have your credit card billing address ready.
  1864.  
  1865.   If you wish to update from an older version of PCL4C, send $20 plus  $3  S&H
  1866.   ($6  outside  of  North  America).   Updates  must  be ordered directly from
  1867.   MarshallSoft Computing.
  1868.  
  1869.   The registered package includes:
  1870.  
  1871.  
  1872.   o  Small,Compact,Medium, & Large libs w/o shareware screens.
  1873.   o  Assembler source code for the library.
  1874.   o  Laser printed Users and Reference Manuals.
  1875.   o  Telephone, FAX, and BBS support for one year.
  1876.   o  Utility program (EXAMPORT) which displays  a  detailed  formatted  report
  1877.      for any serial port.
  1878.  
  1879.  
  1880.   Print the file INVOICE.DOC if an invoice is needed. The registered user will
  1881.   receive the latest version of PCL4C shipped by two day priority mail (packet
  1882.   airmail overseas).  A 3.5" diskette is provided unless a 5.25"  diskette  is
  1883.   requested.
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  PCL4C Users Manual                                                Page 28
  1905.   8.2 License
  1906.  
  1907.  
  1908.   MarshallSoft  Computing,  Inc. grants the registered user of PCL4C the right
  1909.   to use one copy of the PCL4C library (in object form) on a  single  computer
  1910.   in  the  development  of  any software product (other than libraries such as
  1911.   PCL4C).  The user may not use the library on more than one computer  at  the
  1912.   same  time.   The  source code for the library (PCL4C.ASM) is copyrighted by
  1913.   MarshallSoft Computing and may not be released in whole or in part.
  1914.  
  1915.   Products  developed  using  PCL4C can include the object form of the library
  1916.   and may be distributed without any royalty.
  1917.  
  1918.  
  1919.   8.3 Warranty
  1920.  
  1921.  
  1922.   MARSHALLSOFT COMPUTING, INC.  DISCLAIMS  ALL  WARRANTIES  RELATING  TO  THIS
  1923.   SOFTWARE,  WHETHER  EXPRESSED  OR  IMPLIED, INCLUDING BUT NOT LIMITED TO ANY
  1924.   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR  PURPOSE,
  1925.   AND  ALL  SUCH WARRANTIES ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. NEITHER
  1926.   MARSHALLSOFT COMPUTING, INC. NOR ANYONE ELSE WHO HAS BEEN  INVOLVED  IN  THE
  1927.   CREATION,  PRODUCTION,  OR DELIVERY OF THIS SOFTWARE SHALL BE LIABLE FOR ANY
  1928.   INDIRECT, CONSEQUENTIAL, OR INCIDENTAL DAMAGES ARISING OUT  OF  THE  USE  OR
  1929.   INABILITY  TO  USE  SUCH  SOFTWARE EVEN IF MARSHALLSOFT COMPUTING, INC.  HAS
  1930.   BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES OR CLAIMS. IN NO EVENT SHALL
  1931.   MARSHALLSOFT COMPUTING, INC.'S LIABILITY FOR ANY SUCH  DAMAGES  EVER  EXCEED
  1932.   THE  PRICE  PAID FOR THE LICENSE TO USE THE SOFTWARE, REGARDLESS OF THE FORM
  1933.   OF THE CLAIM. THE PERSON USING THE SOFTWARE BEARS ALL RISK AS TO THE QUALITY
  1934.   AND PERFORMANCE OF THE SOFTWARE.
  1935.  
  1936.   Some states do not allow  the  exclusion  of  the  limit  of  liability  for
  1937.   consequential  or  incidental damages, so the above limitation may not apply
  1938.   to you.
  1939.  
  1940.   This agreement shall be governed by the laws of the  State  of  Alabama  and
  1941.   shall  inure  to  the  benefit  of  Marshallsoft  Computing,  Inc.   and any
  1942.   successors, administrators, heirs and  assigns.  Any  action  or  proceeding
  1943.   brought  by either party against the other arising out of or related to this
  1944.   agreement shall be brought only in a STATE or  FEDERAL  COURT  of  competent
  1945.   jurisdiction  located in Madison County, Alabama. The parties hereby consent
  1946.   to in personam jurisdiction of said courts.
  1947.  
  1948.  
  1949.  
  1950.  
  1951.  
  1952.  
  1953.  
  1954.  
  1955.  
  1956.  
  1957.  
  1958.  
  1959.  
  1960.  
  1961.  
  1962.  
  1963.  
  1964.  
  1965.  
  1966.  
  1967.  
  1968.  
  1969.  
  1970.  
  1971.  
  1972.  PCL4C Users Manual                                                Page 29
  1973.   9.0 Summary
  1974.  
  1975.  
  1976.   9.1 Revision History
  1977.  
  1978.  
  1979.   Version 1.0 - 14 January 1991 - original release.
  1980.  
  1981.   Version 1.1 - 11 March 1991
  1982.  
  1983.   o  Added SioUnGetc() function to library.
  1984.  
  1985.   Version 1.2 - 1 June 1991
  1986.  
  1987.   o  SioParms() bug - could not call before SioReset.
  1988.   o  SioReset() bug - was not saving & restoring all regs.
  1989.  
  1990.   Version 1.3 - 1 July 1991
  1991.  
  1992.   o  Added NORESET option to SioReset.
  1993.   o  Added SioDSR, SioCTS, SioDCD, SioLoopBack, and SioRI.
  1994.  
  1995.   Version 2.0 - 1 Nov 1991
  1996.  
  1997.   o  Reorganized as four memory model libraries.
  1998.   o  Added SioModel function to library.
  1999.   o  Added support for Quick C and Power C.
  2000.  
  2001.   Version 2.1 - 1 Dec 1991
  2002.  
  2003.   o  Fixed bug due to Microsoft Assembler (MASM 5.0,5.1) error.
  2004.  
  2005.   NOTE:  MarshallSoft incorporated as "MarshallSoft Computing, Inc."
  2006.   on December 23rd, 1991.
  2007.  
  2008.   Version 3.0 - 15 Jan 1992
  2009.  
  2010.   o  Added SioUART function.
  2011.   o  Added "UART undefined" error code.
  2012.   o  Added "Bad or missing UART" error code.
  2013.   o  Added "Port already enabled" error code.
  2014.   o  Added "Cannot enable both COM1 & COM3 ..." error code.
  2015.   o  Fixed several minor bugs (using new automated testing).
  2016.  
  2017.   Version 3.1 - 1 March 1992
  2018.  
  2019.   o  Added SioFIFO (INS16550 support).
  2020.   o  Added SioIRQ function.
  2021.   o  Increased maximum receive buffer size to 32K bytes.
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  PCL4C Users Manual                                                Page 30
  2041.   9.1 Revision History (continued)
  2042.  
  2043.  
  2044.   Version 3.2 - 1 May 1992
  2045.  
  2046.  
  2047.   o  Modified SioReset so that it no longer clears DTR & RTS.
  2048.   o  Modified SioModel & renamed to SioInfo.
  2049.   o  Fixed bug in SioDone when using 2 ports simultaneously.
  2050.   o  Added SioFlow to library.
  2051.   o  Added YMODEM-G protocol to TERM program.
  2052.  
  2053.   Version 3.3 - 3 August 1992
  2054.  
  2055.   o  Fixed bug in SioUnGet when using 2 ports simultaneously.
  2056.   o  Add SioRead function.
  2057.  
  2058.   Version 3.4 - 4 Jan 1993
  2059.  
  2060.   o  Library modified to use up to four ports simultaneously.
  2061.   o  SioIRQ was modified to include a third argument.
  2062.   o  EXAMPORT utility distributed to registered users.
  2063.  
  2064.   Version 3.5 - 15 May 1993
  2065.  
  2066.   o  Supports dumb DigiBoards ( PC/4 and PC/8).
  2067.   o  Two new error traps added ("No such IRQ" & "No such ISR").
  2068.   o  ASCII file transfer protocol added to TERM (with XON/XOFF).
  2069.  
  2070.   Version 4.0 - 18 Oct 1993
  2071.  
  2072.   o  The library supports transmitter interrupts.
  2073.   o  Corrects bug in Ver 3.5 requiring calling SioIRQ for COM3/4.
  2074.   o  All example code compiles with supported C++ compilers.
  2075.   o  The SioIRQ() function has been simplified.
  2076.  
  2077.   Version 4.1 - 1 May 1994
  2078.  
  2079.   o  Transmitter FIFO enabled.
  2080.   o  Minor internal modifications.
  2081.   o  Supports dumb BOCA boards (BB1004, BB1008, & BB2016).
  2082.   o  Port definition extented to COM16.
  2083.  
  2084.   Version 4.2 - 1 Sept 1994
  2085.  
  2086.   o  A flow control bug was fixed.
  2087.   o  SioGetDiv function added.
  2088.   o  SioRxBuf & SioTxBuf function modified.
  2089.  
  2090.   Version 4.3 - 15 March 1995
  2091.  
  2092.   o  BREAK detection bug fixed,
  2093.   o  Port definitions extended to COM20.
  2094.   o  Support for IRQ8 through IRQ15.
  2095.   o  Line status bits preserved.
  2096.  
  2097.   (The TERM program moved to PPL4C)
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.  PCL4C Users Manual                                                Page 31
  2109.   9.2 Function Summary
  2110.  
  2111.  
  2112.   Refer to the PCL4C Reference Manual (PCL4C.REF) for detailed information  on
  2113.   the  communications  and  support  functions.  A  one  line  summary of each
  2114.   function follows:
  2115.  
  2116.  
  2117.   SioBaud     Sets the baud rate of the selected port.
  2118.   SioBrkKey   Returns non-zero if the Control-BREAK key was pressed.
  2119.   SioBrkSig   Asserts, cancels, or detects BREAK signal.
  2120.   SioCrtWrite Write character to the screen.
  2121.   SioCTS      Reads the Clear to Send (CTS) modem status bit.
  2122.   SioDCD      Reads the Data Carrier Detect (DCD) modem status bit.
  2123.   SioDelay    Delays one or more tics (18 tics per second).
  2124.   SioDone     Terminates further serial processing.
  2125.   SioDSR      Reads the Data Set Ready (DSR) modem status bit.
  2126.   SioDTR      Set, clear, or read the Data Terminal Ready (DTR) bit.
  2127.   SioError    Displays error in text.
  2128.   SioFIFO     Sets the interrupt level for the INS16550.
  2129.   SioFlow     Enables / disables hardware flow control.
  2130.   SioGetc     Reads the next character from the serial line.
  2131.   SioGetDiv   Reads the baud rate divisor registers.
  2132.   SioKeyPress Detects if keyboard has been pressed.
  2133.   SioKeyRead  Reads the keyboard.
  2134.   SioInfo     Returns library version number & memory model.
  2135.   SioIRQ      Assigns an IRQ line to a port.
  2136.   SioLine     Reads the line status register.
  2137.   SioLoopBack Performs a UART loopback test.
  2138.   SioModem    Reads the modem status register.
  2139.   SioParms    Sets parity, stop bits, and word length.
  2140.   SioPorts    Sets # ports, 1st DigiBoard / BOCA port & status reg.
  2141.   SioPutc     Transmit a character over a serial line.
  2142.   SioRead     Reads any of 7 UART ports.
  2143.   SioReset    Initialize a serial port for processing.
  2144.   SioRI       Reads the Ring Indicator (RI) modem status bit.
  2145.   SioRTS      Sets, clears, or reads the Request to Send (RTS) line.
  2146.   SioRxBuf    Sets up receive buffer.
  2147.   SioRxFlush  Flushes (clears) the receive buffer.
  2148.   SioRxQue    Returns the number of characters in the receive queue.
  2149.   SioTimer    Returns the number of system clock tics.
  2150.   SioTxBuf    Sets up transmit buffer.
  2151.   SioTxFlush  Flushes (clears) the transmit buffer.
  2152.   SioTxQue    Returns the number of characters in the transmit queue.
  2153.   SioUART     Sets the UART base address.
  2154.   SioUnGetc   "Un-gets" (puts back) a specified character.
  2155.  
  2156.  
  2157.   9.3 Further Reading
  2158.  
  2159.  
  2160.   The best way to learn about serial communications is to read a good book  on
  2161.   the subject. Several good texts are available.  Two that I like are:
  2162.  
  2163.   (1) C  Programmers's  Guide to Serial Communications by Joe Campbell (SAMS)
  2164.   (2) Mastering Serial Communications by Peter Gofton (SYBEX).
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.  
  2175.  
  2176.  PCL4C Users Manual                                                Page 32
  2177.   10.0 Other MarshallSoft Computing Products
  2178.  
  2179.  
  2180.   10.1 The Personal Protocol Library for C/C++
  2181.  
  2182.  
  2183.   The  Personal  Protocol  Library  for C (PPL4C) consists of a C/C++ language
  2184.   library which implements XMODEM, XMODEM-CRC,  XMODEM-1K,  XMODEM-G,  YMODEM,
  2185.   YMODEM-G,  and  ZMODEM  file  transfer  protocols.   A  script  compiler and
  2186.   interpreter is also included which is capable of such tasks as automatically
  2187.   logging onto a BBS and downloading a file or retrieving mail. Three  example
  2188.   script programs are included.
  2189.  
  2190.   The protocol library (PPL4C) requires the  Personal  Communications  Library
  2191.   for C (PCL4C).
  2192.  
  2193.   The Personal Protocol Library for C is available for $40 plus $3 S&H ($6 S&H
  2194.   overseas).
  2195.  
  2196.  
  2197.   10.2 The LZW Data Compression Library for C
  2198.  
  2199.  
  2200.   LZW4C  is  an  implementation  of  the  LZW (Lempel-Ziv-Welch) algorithm for
  2201.   compressing and decompressing data.  LZW  does  particularly  well  on  text
  2202.   files, achieving better than a 50 % compression ratio for many files.
  2203.  
  2204.   The  LZW  algorithm  is  considered  to  be  one of the best general purpose
  2205.   algorithms  available  today.   The  new  high  speed  modems  that   employ
  2206.   on-the-fly  data  compression  (such as MNP 5.0 & the V.42 bis international
  2207.   standard) use the LZW algorithm, as well as such well known utility programs
  2208.   such as PKZIP.
  2209.  
  2210.   The LZW Data Compression Library for C is available for $45 plus $3 S&H  ($6
  2211.   S&H overseas).
  2212.  
  2213.  
  2214.   10.3 The EMS Expanded Memory Library
  2215.  
  2216.  
  2217.   The  EMS4C library implements version 3.2 of the LIM (Lotus-Intel-Microsoft)
  2218.   specification for expanded memory. It will run with either  version  3.2  or
  2219.   4.0 of the LIM specification.
  2220.  
  2221.   The  EMM4C  library  (included with the EMS4C library) is an expanded memory
  2222.   manager which allows C programmers  to  allocate  and  free  EMS  (expanded)
  2223.   memory  similiar  to  malloc() and free() in the standard C runtime library.
  2224.   Both EMM4C and EMS4C require that your system be  configured  with  expanded
  2225.   (EMS)  memory.  But,  386  &  up systems can use extended memory as expanded
  2226.   memory.
  2227.  
  2228.   The EMS Expanded Memory Library for C is available for $35 plus $3  S&H  ($6
  2229.   S&H overseas).
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  PCL4C Users Manual                                                Page 33
  2245.