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

  1.  
  2.  
  3.                       Personal Communications Library
  4.  
  5.                            For the C Language
  6.  
  7.  
  8.                                ( PCL4C )
  9.  
  10.  
  11.  
  12.  
  13.                       REFERENCE MANUAL
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.                               Version 3.0
  21.  
  22.                               Jan 15, 1992
  23.  
  24.  
  25.  
  26.  
  27.                     This software is provided as-is.
  28.               There are no warranties, expressed or implied
  29.  
  30.  
  31.  
  32.  
  33.                            Copyright (C) 1992
  34.                            All rights reserved
  35.  
  36.  
  37.  
  38.                            MarshallSoft Computing, Inc.
  39.                            Post Office Box 4543
  40.                            Huntsville AL 35815
  41.  
  42.                            Phone (205) 881-4630
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.       PCL4C Reference Manual                                  Page 1
  63.  
  64.  
  65.  
  66.  
  67.                              Table of Contents
  68.  
  69.  
  70.  
  71.  
  72.  
  73.        Chapter                                        Page
  74.  
  75.           Table of Contents.............................2
  76.           Introduction..................................3
  77.           SioBaud.......................................4
  78.           SioBrkKey.....................................5
  79.           SioBrkSig.....................................6
  80.           SioCrtWrite...................................7
  81.           SioCTS........................................8
  82.           SioDCD........................................9
  83.           SioDelay.....................................10
  84.           SioDone......................................11
  85.           SioDSR.......................................12
  86.           SioDTR.......................................13
  87.           SioError.....................................14
  88.           SioGetc......................................15
  89.           SioKeyPress..................................16
  90.           SioKeyRead...................................17
  91.           SioLine......................................18
  92.           SioLoopBack..................................19
  93.           SioModel.....................................20
  94.           SioModem.....................................21
  95.           SioParms.....................................22
  96.           SioPutc......................................23
  97.           SioReset.....................................24
  98.           SioRI........................................25
  99.           SioRTS.......................................26
  100.           SioRxBuf.....................................27
  101.           SioRxFlush...................................28
  102.           SioRxQue.....................................29
  103.           SioTimer.....................................30
  104.           SioUART......................................31
  105.           SioUnGetc....................................32
  106.        Function Summary................................33
  107.        Error Code Summary..............................34
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.       PCL4C Reference Manual                                  Page 2
  129.  
  130.  
  131.  
  132.  
  133.                              Introduction
  134.  
  135.  
  136.  
  137.        This  manual lists all of the PCL4C functions in alphabetical order.
  138.        Every library function will return a value as follows:
  139.  
  140.        1.  Negative values for error conditions. See last  page  of  this
  141.            manual for a list of error values and their meanings.
  142.  
  143.        2.  Non-negative values when returning data ( eg: SioLine ).
  144.  
  145.        3.  Zero otherwise.
  146.  
  147.        When debugging an application, be sure to test all return  values.
  148.        Use SioError to print the associated text for errors.
  149.  
  150.        Example Code Segment
  151.  
  152.  
  153.        +---------------------------------------------------------------+
  154.        | int Code;                 /* MUST be 'int', not 'char' */     |
  155.        |                                                               |
  156.        | Code = SioFunction( );    /* any PCL4C function */            |
  157.        | if(Code<0)                                                    |
  158.        |   {/* error returned */                                       |
  159.        |    SioError(Code);        /* SioError prints error text */    |
  160.        |    SioDone(Port);         /* always call SioDone last */      |
  161.        |    exit(1);                                                   |
  162.        |   }                                                           |
  163.        | /* no errors */                                               |
  164.        | ...your application code...                                   |
  165.        |                                                               |
  166.        +---------------------------------------------------------------+
  167.  
  168.  
  169.        For more examples, examine each of the example programs provided (
  170.        SIMPLE.C,  TERM.C,  INTERCOM.C,  NORESET.C,  LOOPBACK.C,  MODEM.C,
  171.        BBS.C,  and  XFER.C  ).  Also look at the examples associated with
  172.        each library function described in the following section.
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.       PCL4C Reference Manual                                  Page 3
  195.  
  196.  
  197.  
  198.  
  199.                                   SioBaud
  200.  
  201.  
  202.        Function    Sets the baud rate of the selected port.
  203.  
  204.          Syntax    int SioBaud(Port,BaudCode)
  205.                    int Port;     /* Port selected (COM1 - COM4) */
  206.                    int BaudCode; /* Baud code */
  207.  
  208.  
  209.         Remarks    The  SioBaud  function  sets  the  baud  rate  without
  210.                    resetting the port. It is used to change the baud rate
  211.                    after calling SioReset.
  212.  
  213.                    Baud Code           Baud Rate       PCL4C.H Name
  214.                         0                 300            Baud300
  215.                         1                 600            Baud600
  216.                         2                1200            Baud1200
  217.                         3                2400            Baud2400
  218.                         4                4800            Baud4800
  219.                         5                9600            Baud9600
  220.                         6               19200            Baud19200
  221.                         7               38400            Baud38400
  222.                         8               57600            Baud57600
  223.                         9              115200            Baud115200
  224.  
  225.  
  226.         Returns     -4 : Port out of range. Expecting   0  to 3.
  227.                    -11 : Bad baud rate code. See above code values.
  228.  
  229.         Example    /* do auto baud detect */
  230.                    for(Code=0;Code<10;Code++)
  231.                      {/* set baud rate & transmit 'A' */
  232.                       SioBaud(Port,Code);
  233.                       SioPutc(Port,'A');
  234.                       /* assume other side echos back */
  235.                       if(SioGetc(Port,18)=='A'))
  236.                         {puts("Baud rate detected");
  237.                          /*...do something here...*/
  238.                         }
  239.                      }
  240.  
  241.        See Also    SioReset
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.       PCL4C Reference Manual                                  Page 4
  261.  
  262.  
  263.  
  264.  
  265.                                   SioBrkKey
  266.  
  267.  
  268.        Function    Return non-zero if the Control-BREAK key was
  269.                    pressed.
  270.  
  271.          Syntax    int SioBrkKey()
  272.  
  273.         Remarks    The SioBrkKey function returns a TRUE value ( non zero
  274.                    ) if  the  Control-BREAK  key  was  pressed,  else  it
  275.                    returns a zero.  Use SioBrkKey as a safety exit from a
  276.                    polling   loop.   Don't  mix  this  function  up  with
  277.                    SioBrkSig.
  278.  
  279.         Returns    -1 : Control-BREAK was pressed.
  280.                     0 : Control-BREAK was NOT pressed.
  281.  
  282.         Example    int c;
  283.                    ...
  284.                    while(1)
  285.                      {/* exit if user pressed Control-BREAK */
  286.                       if(SioBrkKey())
  287.                         {puts("User typed Contrl-BREAK");
  288.                          SioDone(Port);
  289.                          exit(1);
  290.                         }
  291.                       /* transmit any typed character */
  292.                       if(SioKeyPress())
  293.                         {c = SioKeyRead();
  294.                          SioPutc(Port,c);
  295.                         }
  296.                       /* display any incoming character */
  297.                       c = SioGetc(Port,0);
  298.                       if(c!=-1)  SioCrtWrite(c);
  299.                      }
  300.  
  301.        See Also    SioBrkSig
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.       PCL4C Reference Manual                                  Page 5
  327.  
  328.  
  329.  
  330.  
  331.                                   SioBrkSig
  332.  
  333.  
  334.  
  335.        Function    Asserts, cancels, or detects BREAK signal.
  336.  
  337.          Syntax    int SioBrkSig(Port,Cmd)
  338.                    int Port;      /* Port selected (COM1 thru COM4) */
  339.                    char Cmd;      /* ASSERT, CANCEL, or DETECT */
  340.  
  341.         Remarks    The SioBrkSig function controls the BREAK  bit
  342.                    in the line status register. The legal commands are:
  343.  
  344.                    ASSERT ('A') to assert BREAK
  345.                    CANCEL ('C') to cancel BREAK
  346.                    DETECT ('D') to detect BREAK
  347.  
  348.                    ASSERT,  CANCEL,  and  DETECT  are defined in PCL4C.H.
  349.                    See TERM.C for an example of the use of SioBrkSig.
  350.  
  351.         Returns    -2 : Port not enabled. Call SioReset first.
  352.                    -4 : Port out of range. Expecting  0 to 3.
  353.                    -6 : Illegal command. Expected 'A', 'C', or 'D'.
  354.                    >0 : BREAK signal detected ( DETECT command only )
  355.  
  356.         Example    /* Assert BREAK for 1 second */
  357.                    SioBrkSig(Port,ASSERT);
  358.                    SioDelay(18);
  359.                    SioBrkSig(Port,CANCEL);
  360.                    /* Detect BREAK */
  361.                    if(SioBrkSig(Port,DETECT))
  362.                      {puts("BREAK signal detected");
  363.                       /* ...do some more stuff... */
  364.                      }
  365.  
  366.        See Also    SioBrkKey
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.       PCL4C Reference Manual                                  Page 6
  393.  
  394.  
  395.  
  396.  
  397.                                   SioCrtWrite
  398.  
  399.  
  400.  
  401.        Function    Write character to the screen.
  402.  
  403.          Syntax    int SioCrtWrite(ch)
  404.                    char ch;        /* character to write */
  405.  
  406.         Remarks    The  SioCrtWrite  function  uses  the  BIOS to write a
  407.                    single character to the screen at the  current  cursor
  408.                    location.
  409.  
  410.                    SioCrtWrite  calls  the  BIOS  directly  without   any
  411.                    intermediate  buffering  or processing.  It is usually
  412.                    faster than a call to the C library.
  413.  
  414.         Returns    zero
  415.  
  416.         Example    /* wait up to 1 second ( 18 tics ) for character */
  417.                    if( (c = SioGetc(COM1,18)) != -1)
  418.                      {/* echo to screen */
  419.                       SioCrtWrite(c);
  420.                      }
  421.  
  422.        See Also    SioKeyPress and SioKeyRead
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.       PCL4C Reference Manual                                  Page 7
  459.  
  460.  
  461.  
  462.  
  463.                                   SioCTS
  464.  
  465.  
  466.  
  467.        Function    Reads the Clear to Send ( CTS ) modem status bit.
  468.  
  469.          Syntax    int SioCTS(Port)
  470.                    int Port;   /* Port selected (COM1 thru COM4) */
  471.  
  472.         Remarks    The  SioCTS function is used to read the Clear to Send (
  473.                    CTS ) modem status bit.
  474.  
  475.         Returns    -2 : Port not enabled. Call SioReset first.
  476.                    -4 : Port out of range.  Expecting  0 to 3.
  477.                     0 : CTS is clear.
  478.                    >0 : CTS is set.
  479.  
  480.         Example    /* test CTS status bit */
  481.                    if(SioCTS(Port))
  482.                      puts("CTS is on");
  483.                      else puts("CTS is off");
  484.  
  485.        See Also    SioDSR, SioRI, SioDCD, and SioModem.
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.       PCL4C Reference Manual                                  Page 8
  525.  
  526.  
  527.  
  528.  
  529.                                   SioDCD
  530.  
  531.  
  532.  
  533.        Function    Reads the Data Carrier Detect ( DCD ) modem status bit.
  534.  
  535.          Syntax    int SioDCD(Port)
  536.                    int Port;      /* Port selected (COM1 thru COM4) */
  537.  
  538.         Remarks    The SioDCD function is used to read the  Data  Carrier
  539.                    Detect ( DCD ) modem status bit. Also see SioModem.
  540.  
  541.         Returns    -2 : Port not enabled. Call SioReset first.
  542.                    -4 : Port out of range.  Expecting  0 to 3.
  543.                     0 : DCD is clear.
  544.                    >0 : DCD is set.
  545.  
  546.         Example    /* test data carrier status bit */
  547.                    if(SioDCD(Port))
  548.                      puts("Carrier is on");
  549.                      else puts("Carrier is off");
  550.  
  551.        See Also    SioDSR, SioCTS, SioRI, and SioModem.
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.       PCL4C Reference Manual                                  Page 9
  591.  
  592.  
  593.  
  594.  
  595.                                   SioDelay
  596.  
  597.  
  598.  
  599.        Function    Delays one or more tics.
  600.  
  601.          Syntax    int SioDelay(tics)
  602.                    int tics;       /* # tics */
  603.  
  604.         Remarks    The  SioDelay  function  is used to delay one  or more
  605.                    timer tics, where each timer tic is  approximately  55
  606.                    milliseconds ( 18 to the second ).
  607.  
  608.         Returns    zero
  609.  
  610.         Example    /* delay 5 seconds */
  611.                    SioDelay(5*18);
  612.  
  613.        See Also    SioTimer
  614.  
  615.  
  616.  
  617.  
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.  
  655.  
  656.       PCL4C Reference Manual                                  Page 10
  657.  
  658.  
  659.  
  660.  
  661.                                   SioDone
  662.  
  663.  
  664.  
  665.        Function    Terminates further serial processing.
  666.  
  667.          Syntax    int SioDone(Port)
  668.                    int Port;     /* Port selected (COM1 thru COM4) */
  669.  
  670.         Remarks    The  SioDone  function  terminates  further  serial
  671.                    processing. SioDone MUST be called before exiting your
  672.                    application so that  interrupts  can  be  restored  to
  673.                    their original state. Failure to do this can crash the
  674.                    operating  system.   If  you  forget  to  call SioDone
  675.                    before exiting, be sure to re-boot your computer.  You
  676.                    can call SioDone even if SioReset has not been called,
  677.                    so it is good practice to always call  SioDone  before
  678.                    exiting your application.
  679.  
  680.         Returns    -2 : Port not enabled. Call SioReset first.
  681.                    -4 : Port out of range. Expecting  0 to 3.
  682.  
  683.         Example    /* terminate processing for COM3 */
  684.                    SioDone(COM3);
  685.  
  686.        See Also    SioReset.
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.       PCL4C Reference Manual                                  Page 11
  723.  
  724.  
  725.  
  726.  
  727.                                   SioDSR
  728.  
  729.  
  730.  
  731.        Function    Reads the Data Set Ready ( DSR ) modem status bit.
  732.  
  733.          Syntax    int SioDSR(Port )
  734.                    int Port;     /* Port selected (COM1 thru COM4) */
  735.  
  736.         Remarks    The SioDSR function is used  to  read  the  Data  Set
  737.                    Ready ( DSR ) modem status bit.
  738.  
  739.         Returns    -2 : Port not enabled. Call SioReset first.
  740.                    -4 : Port out of range.  Expecting  0 to 3.
  741.                     0 : DSR is clear.
  742.                    >0 : DSR is set
  743.  
  744.         Example    /* read DSR status bit */
  745.                    if(SioDSR(Port))
  746.                      puts("Modem is ready");
  747.                      else puts("Modem is not ready");
  748.  
  749.        See Also    SioCTS, SioRI, SioDCD, and SioModem
  750.  
  751.  
  752.  
  753.  
  754.  
  755.  
  756.  
  757.  
  758.  
  759.  
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.       PCL4C Reference Manual                                  Page 12
  789.  
  790.  
  791.  
  792.  
  793.                                   SioDTR
  794.  
  795.  
  796.  
  797.        Function    Set, clear, or read the Data Terminal Ready ( DTR ) bit.
  798.  
  799.          Syntax    int SioDTR(Port,Cmd)
  800.                    int Port;     /* Port selected (COM1 thru COM4) */
  801.                    char Cmd;     /* DTR command ( SET, CLEAR, or READ ) */
  802.  
  803.         Remarks    The SioDTR function controls the Data Terminal Ready (
  804.                    DTR  )  bit in the modem control register.  Commands (
  805.                    defined in PCL4C.H ) are:
  806.  
  807.                    SET ('S')  to set DTR ( ON )
  808.                    CLEAR ('C')  to clear DTR ( OFF )
  809.                    READ ('R')  to read DTR
  810.  
  811.         Returns    -2 : Port not enabled. Call SioReset first.
  812.                    -4 : Port out of range. Expecting  0 to 3.
  813.                    -5 : Not one of 'S', 'C', or 'R'.
  814.                     0 : DTR is OFF (READ Command).
  815.                    >0 : DTR is ON (READ Command).
  816.  
  817.         Example    /* turn DTR on for modem connected to COM4 */
  818.                    SioDTR(COM4,SET);
  819.  
  820.        See Also    SioRTS.
  821.  
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834.  
  835.  
  836.  
  837.  
  838.  
  839.  
  840.  
  841.  
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.       PCL4C Reference Manual                                  Page 13
  855.  
  856.  
  857.  
  858.  
  859.                                   SioError
  860.  
  861.  
  862.        Function    Displays error in text.
  863.  
  864.          Syntax    int SioError(Code)
  865.                    int Code; /* Error code returned from */
  866.                              /* a PCL4C function */
  867.  
  868.         Remarks    The SioError  function  displays  the  error  in  text
  869.                    corresponding  to  the error code.  During development
  870.                    of a communications application, it is a good idea  to
  871.                    always   test   return  codes,  and  print  out  their
  872.                    descriptions with SioError.
  873.  
  874.         Returns    zero
  875.  
  876.         Example    code = SioReset(Port,Baud4800);
  877.                    /* display error message if error occurred */
  878.                    if(code<0) SioError(code);
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.  
  919.  
  920.       PCL4C Reference Manual                                  Page 14
  921.  
  922.  
  923.  
  924.  
  925.                                   SioGetc
  926.  
  927.  
  928.  
  929.        Function    Reads the next character from the serial line.
  930.  
  931.          Syntax    int SioGetc(Port,Tics)
  932.                    int Port;     /* COM1 to COM4 */
  933.                    int Tics;     /* # timer tics */
  934.  
  935.         Remarks    The  SioGetc function reads the selected serial port.
  936.                    The function will wait for the number of  system  tics
  937.                    given  by  the 'Tics' argument before returning 'timed
  938.                    out'. There are 18 tics to the second.
  939.  
  940.                    To specify no waiting, call SioGetc with Tics = 0.
  941.  
  942.         Returns    -2 : Port not enabled. Call SioReset first.
  943.                    -4 : Port out of range. Expecting  0 to 3.
  944.                    -1 : If timed out.
  945.                    >0 : Character read.
  946.  
  947.         Example    int c; /* MUST be 'int', not 'char' !!! */
  948.                    ...
  949.                    /* wait 9 tics for incoming character & display it */
  950.                    if( (c=SioGetc(COM1,9)) != -1)
  951.                      printf("Character is '%c'\n", c);
  952.                      else puts("Timed out");
  953.  
  954.        See Also    SioUnGetc and SioPutc.
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.       PCL4C Reference Manual                                  Page 15
  987.  
  988.  
  989.  
  990.  
  991.                                   SioKeyPress
  992.  
  993.  
  994.  
  995.        Function    Detects if keyboard has been pressed.
  996.  
  997.          Syntax    int SioKeyPress()
  998.  
  999.         Remarks    The SioKeyPress function uses the  BIOS  to  test  the
  1000.                    keyboard   for   a   key   press   (including  control
  1001.                    characters).
  1002.  
  1003.                    SioKeyPress  calls  the  BIOS  directly  without   any
  1004.                    intermediate  buffering  or processing.  It is usually
  1005.                    faster than using the C library.
  1006.  
  1007.         Returns    zero
  1008.  
  1009.         Example    if( SioKeyPress() )
  1010.                      {c = SioKeyRead();
  1011.                       /* echo character c */
  1012.                       SioCrtWrite(c)
  1013.                      }
  1014.  
  1015.        See Also    SioCrtWrite and SioKeyRead.
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.       PCL4C Reference Manual                                  Page 16
  1053.  
  1054.  
  1055.  
  1056.  
  1057.                                   SioKeyRead
  1058.  
  1059.  
  1060.  
  1061.        Function    Reads the keyboard.
  1062.  
  1063.          Syntax    int SioKeyRead()
  1064.  
  1065.         Remarks    The SioKeyRead function uses  the  BIOS  to  read  the
  1066.                    keyboard.  It will wait until a character is typed.
  1067.  
  1068.                    SioKeyRead  calls  the  BIOS  directly   without   any
  1069.                    intermediate  buffering  or processing.  It is usually
  1070.                    faster than using the C library.
  1071.  
  1072.         Returns    Character typed ( including control codes ).
  1073.  
  1074.         Example    if(SioKeyPress())
  1075.                      {/* fetch the character */
  1076.                       c = SioKeyRead();
  1077.                       /* echo to screen */
  1078.                       SioCrtWrite(c);
  1079.                      }
  1080.  
  1081.        See Also    SioCrtWrite and SioKeyRead.
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.       PCL4C Reference Manual                                  Page 17
  1119.  
  1120.  
  1121.  
  1122.  
  1123.                                   SioLine
  1124.  
  1125.  
  1126.  
  1127.        Function    Reads the line status register.
  1128.  
  1129.          Syntax    int SioLine(Port)
  1130.                    int Port;     /* Port selected (COM1 thru COM4) */
  1131.  
  1132.         Remarks    The  SioLine function reads the line status register.
  1133.                    The individual bit masks are as follows:
  1134.  
  1135.                    0x20  = Transmitter Buffer Empty.
  1136.                    0x10  = Break detected.
  1137.                    0x08  = Framming error.
  1138.                    0x04  = Parity error.
  1139.                    0x02  = Overrun error.
  1140.                    0x01  = Data ready.
  1141.  
  1142.                    The above are documented in the file PCL4C.H.
  1143.  
  1144.         Returns    -2 : Port not enabled. Call SioReset first.
  1145.                    -4 : Port out of range. Expecting  0 to 3.
  1146.                    >0 : Line status ( rightmost byte of word ).
  1147.  
  1148.         Example    int rc;
  1149.                    ...
  1150.                    rc = LineStatus(Port);
  1151.                    if(rc & (FramingError|ParityError|OverrunError))
  1152.                      {if(rc & FramingError) puts("Framing Error");
  1153.                       if(rc & ParityError)  puts("Parity Error");
  1154.                       if(rc & OverrunError) puts("Overrun Error");
  1155.                      }
  1156.                    else puts("No error");
  1157.  
  1158.        See Also    SioModem.
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.  
  1183.  
  1184.       PCL4C Reference Manual                                  Page 18
  1185.  
  1186.  
  1187.  
  1188.  
  1189.                                   SioLoopBack
  1190.  
  1191.  
  1192.  
  1193.        Function    Does a UART loopback test.
  1194.  
  1195.          Syntax    int SioLoopBack(Port)
  1196.                    int Port;     /* Port selected (COM1 thru COM4) */
  1197.  
  1198.         Remarks    SioLoopBack  makes  use of the built in loopback test
  1199.                    capability of the INS8250 UART.  Normally  SioLoopBack
  1200.                    will  never  need  to  be called except if you suspect
  1201.                    that your UART is bad. See the LOOPBACK.C program.
  1202.  
  1203.  
  1204.         Returns      0 : Loopback test is successfull.
  1205.                     -2 : Port not enabled. Call SioReset first.
  1206.                     -4 : Port out of range.  Expecting   0  to 3.
  1207.                    -12 : Loopback test fails.
  1208.  
  1209.  
  1210.         Example    /* test port */
  1211.                    if(SioLoopBack(Port))
  1212.                      puts("Loopback test has failed");
  1213.                      else puts("Loopback test has succeeded");
  1214.  
  1215.  
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.       PCL4C Reference Manual                                  Page 19
  1251.  
  1252.  
  1253.  
  1254.  
  1255.                                   SioModel
  1256.  
  1257.  
  1258.  
  1259.        Function    Returns a code corresponding to the library memory model.
  1260.  
  1261.          Syntax    int SioModel()
  1262.  
  1263.         Remarks    The   SioModel  function  returns  an  integer  code
  1264.                    corresponding to the library memory model as follows.
  1265.  
  1266.                    Code    Memory Model
  1267.                      0      Small
  1268.                      1      Compact
  1269.                      2      Medium
  1270.                      3      Large
  1271.  
  1272.                    SioModel is  provided  so  that  you  can  verify  the
  1273.                    memory model that a PCL4C library was assembled under.
  1274.  
  1275.         Returns    0 to 3 as described above.
  1276.  
  1277.         Example    char *Model[] = {"Small","Compact","Medium","Large"};
  1278.                    ...
  1279.                    Code = SioModel();
  1280.                    printf("Memory Model is %s\n", Model[ Code ]);
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.       PCL4C Reference Manual                                  Page 20
  1317.  
  1318.  
  1319.  
  1320.  
  1321.                                   SioModem
  1322.  
  1323.  
  1324.  
  1325.        Function    Reads the modem status register.
  1326.  
  1327.          Syntax    int SioModem(Port, Mask)
  1328.                    int Port;    /* Port selected (COM1 thru COM4) */
  1329.                    char Mask;   /* Modem function mask */
  1330.  
  1331.         Remarks    The  SioModem function reads the modem register.  The
  1332.                    bit definitions for the function mask are as follows:
  1333.  
  1334.                     Bit    PCL4C.H Name   Function
  1335.                      7      DCD           Data Carrier Detect
  1336.                      6      RI            Ring Indicator
  1337.                      5      DSR           Data Set Ready
  1338.                      4      CTS           Clear To Send
  1339.                      3      DeltaDCD      Delta DCD   ( DCD has changed )
  1340.                      2      DeltaRI       Delta RI    ( RI has changed )
  1341.                      1      DeltaDSR      Delta DSR   ( DSR has changed )
  1342.                      0      DeltaCTS      Delta CTS   ( CTS has changed )
  1343.  
  1344.                    Bits 4 through  7  represent  the  absolute  state  of
  1345.                    their  respective  RS-232  inputs.  Bits  0  through 3
  1346.                    repesent a change in the  state  of  their  respective
  1347.                    RS-232 inputs since last read.
  1348.  
  1349.                    The  above  definitions  are  also in the PCL4C.H file
  1350.                    for use by your application program.
  1351.  
  1352.         Returns    -2 : Port not enabled. Call SioReset first.
  1353.                    -4 : Port out of range. Expecting  0 to 3.
  1354.                    >0 : Modem status ( rightmost byte of word ).
  1355.  
  1356.         Example    /* any change in DCD or CTS ? */
  1357.                    if(delta=SioModem(Port,DeltaDCD|DeltaCTS))
  1358.                      {status = SioModem(Port,DCD|CTS);
  1359.                       if(delta&DeltaDCD)
  1360.                         {if(status&DCD) c='T';
  1361.                          else c='F';
  1362.                         }
  1363.                       printf("DCD=%c\n",c);
  1364.                      }
  1365.                    if(delta&DeltaCTS)
  1366.                      {if(status&CTS)
  1367.                         {c='T'; else c='F';
  1368.                          printf("CTS=%c\n",c);
  1369.                         }
  1370.                      }
  1371.  
  1372.        See Also    SioCTS, SioDCD, SioDSR and SioRI.
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.       PCL4C Reference Manual                                  Page 21
  1383.  
  1384.  
  1385.  
  1386.  
  1387.                                   SioParms
  1388.  
  1389.  
  1390.  
  1391.        Function    Sets parity, stop bits, and word length.
  1392.  
  1393.          Syntax    int SioParms(Port,ParityCode,StopBitsCode,WordLengthCode)
  1394.                    int Port;           /* Port selected (COM1 thru COM4) */
  1395.                    int ParityCode;      /* parity code [0,1,2] */
  1396.                    int StopBitsCode;    /* stop bits code  [0,1] */
  1397.                    int WordLengthCode;  /* word length code [0,1,2,3] */
  1398.  
  1399.         Remarks    The SioParms function sets the parity, stop bits, and
  1400.                    word length.  If the default parity  (  none  ),  stop
  1401.                    bits  (  1  ), or word length ( 8 ) is not acceptable,
  1402.                    then they can be changed by calling SioParms. SioParms
  1403.                    can be called either before or after calling SioReset.
  1404.                    See file PCL4C.H.
  1405.  
  1406.                                   Value   Description    PCL4C.H Name
  1407.                    ParityCode:    *0      no parity      NoParity
  1408.                                    1      odd parity     OddParity
  1409.                                    3      even parity    EvenParity
  1410.  
  1411.                    StopBitsCode:  *0      1 stop bit     OneStopBit
  1412.                                    1      2 stop bits    TwoStopBits
  1413.  
  1414.                    WordLengthCode: 0      5 data bits    WordLength5
  1415.                                    1      6 data bits    WordLength6
  1416.                                    2      7 data bits    WordLength7
  1417.                                   *3      8 data bits    WordLength8
  1418.  
  1419.                    * = Default
  1420.  
  1421.         Returns    -4 : Port out of range. Expecting 0 to 3.
  1422.                    -7 : Bad parity code selected. Expecting  0 to 2.
  1423.                    -8 : Bad stop bits code. Expecting  0 or 1.
  1424.                    -9 : Bad word length code. Expecting  0 to 3.
  1425.  
  1426.         Example    /* set no parity, 1 stop bit, and 8 bit data for COM1 */
  1427.                    SioParms(COM1,NoParity,OneStopBit,WordLength8);
  1428.  
  1429.        See Also    SioReset.
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.  
  1447.  
  1448.       PCL4C Reference Manual                                  Page 22
  1449.  
  1450.  
  1451.  
  1452.  
  1453.                                   SioPutc
  1454.  
  1455.  
  1456.  
  1457.        Function    Transmit a character over a serial line.
  1458.  
  1459.          Syntax    int SioPutc(Port,c)
  1460.                    int Port;     /* Port selected (COM1 thru COM4) */
  1461.                    char c;       /* character to send */
  1462.  
  1463.         Remarks    The SioPutc function transmits one character over the
  1464.                    selected serial line.
  1465.  
  1466.         Returns    -2 : Port not enabled. Call SioReset first.
  1467.                    -4 : Port out of range. Expecting  0 to 3.
  1468.  
  1469.         Example    char crc;
  1470.                    char buffer[128];
  1471.                    ...
  1472.                    /* transmit 128 byte buffer + CRC */
  1473.                    crc = 0;
  1474.                    for(i=0;i<128;i++)
  1475.                      {crc = crcupdate( buffer[i], crc);
  1476.                       SioPutc(Port, buffer[i]);
  1477.                      }
  1478.                    SioPutc(crc);
  1479.  
  1480.        See Also    SioGetc.
  1481.  
  1482.  
  1483.  
  1484.  
  1485.  
  1486.  
  1487.  
  1488.  
  1489.  
  1490.  
  1491.  
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.       PCL4C Reference Manual                                  Page 23
  1515.  
  1516.  
  1517.  
  1518.  
  1519.                                   SioReset
  1520.  
  1521.  
  1522.  
  1523.        Function    Initialize a serial port for processing.
  1524.  
  1525.          Syntax    int SioReset(Port,BaudCode)
  1526.                    int Port;     /* Port selected (COM1 thru COM4) */
  1527.                    int BaudCode; /* baud code or -1 */
  1528.  
  1529.         Remarks    The SioReset function initializes the selected serial
  1530.                    port.  SioReset should be called after calling SioParm
  1531.                    and SioRxBuf but before  making  any  other  calls  to
  1532.                    PCL4C.   SioReset uses the parity, stop bits, and word
  1533.                    length value previously set  if  SioParm  was  called,
  1534.                    otherwise the default values ( see SioParm ) are used.
  1535.  
  1536.                    Recall  that  COM1  and  COM3 share the same interrupt
  1537.                    vector and therefore  cannot  operate  simultaneously.
  1538.                    Similiarly,    COM2    and    COM4    cannot   operate
  1539.                    simultaneously. Any other combination of two ports can
  1540.                    be used.
  1541.  
  1542.                    By specifing NORESET ( -1 ) for the  baud  rate  code,
  1543.                    the  port  will  NOT  be reset.  This is used to "take
  1544.                    over" a port from a host communications  program  that
  1545.                    allows  a  "DOS  gateway".   External protocols can be
  1546.                    implemented this way. See SioBaud for a  list  of  the
  1547.                    baud rate codes, or see "PCL4C.H".
  1548.  
  1549.        Returns      -3 : No buffer available. Call SioRxBuf first.
  1550.                     -4 : Port out of range. Expecting  0 to 3.
  1551.                    -11 : Bad baud rate code selected. Expecting  0 to 9.
  1552.                    -13 : UART  undefined.   SioUART(Port,0)  was  called
  1553.                          previously.
  1554.                    -14 : Bad or missing UART.  You may not have hardware
  1555.                          present.
  1556.                    -15 : Port already enabled.  SioReset has already been
  1557.                          called.
  1558.                    -16 : Cannot enable both COM1 & COM3  or  COM2 & COM4.
  1559.  
  1560.         Example    char Buffer[128];
  1561.                    int rc;
  1562.                    ...
  1563.                    SioRxBuf(COM1,Buffer,Size128);
  1564.                    rc = SioReset(Com1,Baud38400);
  1565.                    if(rc==0) puts("RESET ok");
  1566.                    else if(rc<0) SioError(rc);
  1567.                    else
  1568.                      {if(rc&OverrunError) puts("Overrun Error");
  1569.                       if(rc&ParityError) puts("Parity Error");
  1570.                       if(rc&FramingError) puts("Framing Error");
  1571.                       if(rc&BreakDetected) puts("Break Detected");
  1572.                      }
  1573.  
  1574.        See Also    SioBaud, SioParms, SioRxBuf, SioDone, and SioUART.
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.       PCL4C Reference Manual                                  Page 24
  1581.  
  1582.  
  1583.  
  1584.  
  1585.                                   SioRI
  1586.  
  1587.  
  1588.  
  1589.        Function    Reads the Ring Indicator ( RI ) modem status bit.
  1590.  
  1591.          Syntax    int SioRI(Port)
  1592.                    int Port;     /* Port selected (COM1 thru COM4) */
  1593.  
  1594.         Remarks    The SioRI function is used to read the Ring Indicator
  1595.                    ( RI ) modem status bit. Also see SioModem.
  1596.  
  1597.         Returns    -2 : Port not enabled. Call SioReset first.
  1598.                    -4 : Port out of range.  Expecting   0  to 3.
  1599.                     0 : RI is clear.
  1600.                    >0 : RI is set ( RING has occurred ).
  1601.  
  1602.         Example    /* check for Ring */
  1603.                    if(SioRI(Port))
  1604.                      {puts("RING ");
  1605.                       /* process RING */
  1606.                       ...
  1607.                      }
  1608.  
  1609.        See Also    SioDSR, SioCTS, SioDCD, and SioModem.
  1610.  
  1611.  
  1612.  
  1613.  
  1614.  
  1615.  
  1616.  
  1617.  
  1618.  
  1619.  
  1620.  
  1621.  
  1622.  
  1623.  
  1624.  
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.       PCL4C Reference Manual                                  Page 25
  1647.  
  1648.  
  1649.  
  1650.  
  1651.                                   SioRTS
  1652.  
  1653.  
  1654.  
  1655.        Function    Sets,  clears,  or  reads the Request to Send ( RTS )
  1656.                    line.
  1657.  
  1658.          Syntax    int SioRTS(Port,Cmd)
  1659.                    int Port;     /* COM1 to COM4 */
  1660.                    char Cmd;     /* RTS command ( SET, CLEAR, or READ ) */
  1661.  
  1662.         Remarks    The SioRTS function controls the  Request  to  Send  (
  1663.                    RTS  )  bit  in the modem control register. Commands (
  1664.                    defined in PCL4C.H ) are:
  1665.  
  1666.                    SET ('S')   -- set RTS ( ON )
  1667.                    CLEAR ('C') -- clear RTS ( OFF )
  1668.                    READ ('R')  -- read RTS
  1669.  
  1670.         Returns    -2 : Port not enabled. Call SioReset first.
  1671.                    -4 : Port out of range. Expecting  0 to 3.
  1672.                    -5 : Command is not one of 'S', 'C', or 'R'.
  1673.                     0 : RTS is OFF (READ Command).
  1674.                    >0 : RTS is ON  (READ Command).
  1675.  
  1676.         Example    /* turn off RTS for modem */
  1677.                    SioRTS(Port,CLEAR);
  1678.  
  1679.        See Also    SioDTR.
  1680.  
  1681.  
  1682.  
  1683.  
  1684.  
  1685.  
  1686.  
  1687.  
  1688.  
  1689.  
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.       PCL4C Reference Manual                                  Page 26
  1713.  
  1714.  
  1715.  
  1716.  
  1717.                                   SioRxBuf
  1718.  
  1719.  
  1720.  
  1721.        Function    Sets up receive buffers.
  1722.  
  1723.          Syntax    int SioRxBuf(Port,Buffer,SizeCode)
  1724.                    int Port;     /* Port selected (COM1 thru COM4) */
  1725.                    char *Buffer  /* Receive buffer */
  1726.                    int SizeCode; /* Buffer size code */
  1727.  
  1728.         Remarks    The SioRxBuf function passes the address and  size  of
  1729.                    the   receive  buffer  to  PCL4C.  Recall  that  PCL4C
  1730.                    requires  a  receive   buffer   for   each   port   in
  1731.                    simultaneous  operation  since the receive function is
  1732.                    interrupt driven. SioRxBuf passes the  receive  buffer
  1733.                    to  PCL4C  for  both  the  primary  (  COM1/COM3 ) and
  1734.                    secondary ( COM2/COM4 )  ports.   It  must  be  called
  1735.                    before   any  incoming  characters  can  be  received.
  1736.                    SioRxBuf must be called before SioReset.  Buffer  size
  1737.                    codes are listed in "PCL4C.H".
  1738.  
  1739.                    Size Code       Buffer Size    PCL4C.H Name
  1740.                       0              8 bytes        Size8
  1741.                       1             16 bytes        Size16
  1742.                       2             32 bytes        Size32
  1743.                       3             64 bytes        Size64
  1744.                       4            128 bytes        Size128
  1745.                       5            256 bytes        Size256
  1746.                       6            512 bytes        Size512
  1747.                       7           1024 bytes        Size1024
  1748.                       8           2048 bytes        Size2048
  1749.                       9           4096 bytes        Size4096
  1750.                      10           8192 bytes        Size8192
  1751.                      11          16384 bytes        Size16384
  1752.  
  1753.         Returns    -4 : Port out of range. Expecting 0 to 3.
  1754.                   -10 : Bad buffer size code. Expecting 0 to 11.
  1755.  
  1756.         Example    char RxBuf[1024];
  1757.                    ...
  1758.                    /* setup 1K receive buffer */
  1759.                    SioRxBuf(COM1, RxBuf, Size1024);
  1760.                    /* ready to call SioReset */
  1761.                    ...
  1762.  
  1763.        See Also    SioReset.
  1764.  
  1765.  
  1766.  
  1767.  
  1768.  
  1769.  
  1770.  
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.       PCL4C Reference Manual                                  Page 27
  1779.  
  1780.  
  1781.  
  1782.  
  1783.                                   SioRxFlush
  1784.  
  1785.  
  1786.  
  1787.        Function    To  flush  the  receive  buffer  associated  with  the
  1788.                    specified port.
  1789.  
  1790.          Syntax    int SioRxFlush(Port)
  1791.                    int Port;   /* Port selected (COM1 thru COM4) */
  1792.  
  1793.         Remarks    The SioRxFlush function will delete any characters  in
  1794.                    the  receive  buffer  for  the  specified port.  After
  1795.                    execution, the receive buffer  will  be  empty.   Call
  1796.                    SioRxBuf after resetting a port in order to delete any
  1797.                    spurious characters.
  1798.  
  1799.         Returns    -2 : Port not enabled. Call SioReset first.
  1800.                    -4 : Port out of range. Expecting 0 to 3.
  1801.  
  1802.         Example    char buffer[1024];
  1803.                    ...
  1804.                    /* setup receive buffer & reset port */
  1805.                    SioRxBuf(COM1,buffer,Size1024);
  1806.                    SioReset(COM1,Baud115200);
  1807.                    /* flush any spurious character */
  1808.                    SioRxFlush(COM1);
  1809.                    /* ready for serial processing ! */
  1810.                    ...
  1811.  
  1812.        See Also    SioRxQue.
  1813.  
  1814.  
  1815.  
  1816.  
  1817.  
  1818.  
  1819.  
  1820.  
  1821.  
  1822.  
  1823.  
  1824.  
  1825.  
  1826.  
  1827.  
  1828.  
  1829.  
  1830.  
  1831.  
  1832.  
  1833.  
  1834.  
  1835.  
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.       PCL4C Reference Manual                                  Page 28
  1845.  
  1846.  
  1847.  
  1848.  
  1849.                                   SioRxQue
  1850.  
  1851.  
  1852.  
  1853.        Function    Returns the number of characters in the receive queue.
  1854.  
  1855.          Syntax    int SioRxQue(Port)
  1856.                    int Port;     /* Port selected (COM1 thru COM4) */
  1857.  
  1858.         Remarks    The  SioRxQue  function  will  return  the  number  of
  1859.                    characters in the receive queue. It  can  be  used  to
  1860.                    implement XON/XOFF flow control.
  1861.  
  1862.         Returns    -2 : Port not enabled. Call SioReset first.
  1863.                    -4 : Port out of range. Expecting  0 to 3.
  1864.  
  1865.         Example    #define XON 0x11
  1866.                    #define XOFF 0x13
  1867.                    int count;
  1868.                    char last = XON;
  1869.                    char Buffer[128];
  1870.                    ...
  1871.                    SioRxBuf(COM1,Buffer,Size128);
  1872.                    /* implement XON / XOFF */
  1873.                    count = SioRxQue(COM1);
  1874.                    if((last==XON)&&(count>120))
  1875.                      {SioPutc(COM1,XOFF);
  1876.                       last = XOFF;
  1877.                      }
  1878.                    if((last==XOFF)&&(count<8))
  1879.                      {SioPutc(COM1,XON);
  1880.                       last = XON;
  1881.                      }
  1882.  
  1883.       See Also     SioRxFlush.
  1884.  
  1885.  
  1886.  
  1887.  
  1888.  
  1889.  
  1890.  
  1891.  
  1892.  
  1893.  
  1894.  
  1895.  
  1896.  
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.       PCL4C Reference Manual                                  Page 29
  1911.  
  1912.  
  1913.  
  1914.  
  1915.                                   SioTimer
  1916.  
  1917.  
  1918.  
  1919.        Function    Returns the number of system clock tics since midnight.
  1920.  
  1921.          Syntax    long SioTimer()
  1922.  
  1923.         Remarks    The SioTimer function will return the number of system
  1924.                    clock tics since midnight, at 18.2065 tics per second.
  1925.                    This function is usefull for timing various functions.
  1926.                    Also see SioDelay.
  1927.  
  1928.         Returns    timer tics.
  1929.  
  1930.         Example    long time;
  1931.                    ...
  1932.                    time = SioTimer();
  1933.                    ...
  1934.                    printf("Elasped time = %ld tics\n",SioTimer() - time);
  1935.  
  1936.        See Also    SioDelay.
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  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.  
  1973.  
  1974.  
  1975.  
  1976.       PCL4C Reference Manual                                  Page 30
  1977.  
  1978.  
  1979.  
  1980.  
  1981.                                   SioUART
  1982.  
  1983.  
  1984.  
  1985.        Function    Sets the UART base address.
  1986.  
  1987.          Syntax    int SioUART(Port,Address)
  1988.                    int Port;     /* COM1 to COM4 */
  1989.                    int Address;  /* UART address */
  1990.  
  1991.         Remarks    The SioUART function sets the UART  base  address  for
  1992.                    the  specified  port.   SioUART  must be called before
  1993.                    SioReset in order to have effect.  Be  extremely  sure
  1994.                    that you know what you are doing! Note that PCL4C uses
  1995.                    the   standard   PC/XT/AT  port  addresses,  interrupt
  1996.                    request  lines,   and   interrupt   service   vectors.
  1997.                    Therefore,   this   function   is   only   needed  for
  1998.                    non-standard ports.
  1999.  
  2000.         Returns    >0 : The previous base address for this port.
  2001.                    -4 : Port out of range.  Expecting 0 to 3.
  2002.  
  2003.         Example    /* Record fact that you don't have COM4 */
  2004.                    SioUART(COM4, 0);
  2005.  
  2006.        See Also    SioReset.
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.  
  2021.  
  2022.  
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.  
  2029.  
  2030.  
  2031.  
  2032.  
  2033.  
  2034.  
  2035.  
  2036.  
  2037.  
  2038.  
  2039.  
  2040.  
  2041.  
  2042.       PCL4C Reference Manual                                  Page 31
  2043.  
  2044.  
  2045.  
  2046.  
  2047.                                   SioUnGetc
  2048.  
  2049.  
  2050.  
  2051.        Function    "Un-gets" the last character read with SioGetc().
  2052.  
  2053.          Syntax    int SioUnGetc(Port,c)
  2054.                    int Port;     /* Port selected (COM1 thru COM4) */
  2055.                    char c;       /* character to unget */
  2056.  
  2057.         Remarks    The  SioUnGetc  function  returns  (  pushes  )   the
  2058.                    character  back  into  the  serial  input buffer.  The
  2059.                    character pushed will be the next  character  returned
  2060.                    by  SioGetc.  Only  one  character can be pushed back.
  2061.                    This function works just like the "ungetc" function in
  2062.                    the C language.
  2063.  
  2064.         Returns    -2 : Port not enabled. Call SioReset first.
  2065.                    -4 : Port out of range. Expecting 0 to 3.
  2066.  
  2067.         Example    /* push back c so next SioGetc will get it */
  2068.                    SioUnGetc(Port,c);
  2069.  
  2070.        See Also    SioReset.
  2071.  
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087.  
  2088.  
  2089.  
  2090.  
  2091.  
  2092.  
  2093.  
  2094.  
  2095.  
  2096.  
  2097.  
  2098.  
  2099.  
  2100.  
  2101.  
  2102.  
  2103.  
  2104.  
  2105.  
  2106.  
  2107.  
  2108.       PCL4C Reference Manual                                  Page 32
  2109.  
  2110.  
  2111.  
  2112.  
  2113.                              Function Sumary
  2114.  
  2115.  
  2116.  
  2117.        +=============+==========+==========+==========+==========+
  2118.        | Function    |   Arg1   |   Arg2   |   Arg3   |   Arg4   |
  2119.        +=============+==========+==========+==========+==========+
  2120.        | SioBaud     | Port     | BaudCode |          |          |
  2121.        | SioBrkKey   |          |          |          |          |
  2122.        | SioBrkSig   | Port     | Cmd      |          |          |
  2123.        | SioCrtWrite | Ch       |          |          |          |
  2124.        | SioCTS      | Port     |          |          |          |
  2125.        | SioDCD      | Port     |          |          |          |
  2126.        | SioDelay    | Tics     |          |          |          |
  2127.        | SioDone     | Port     |          |          |          |
  2128.        | SioDSR      | Port     |          |          |          |
  2129.        | SioDTR      | Port     | Cmd      |          |          |
  2130.        | SioError    | Code     |          |          |          |
  2131.        | SioGetc     | Port     | Tics     |          |          |
  2132.        | SioKeyPress |          |          |          |          |
  2133.        | SioKeyRead  |          |          |          |          |
  2134.        | SioLine     | Port     |          |          |          |
  2135.        | SioLoopBack | Port     |          |          |          |
  2136.        | SioModel    |          |          |          |          |
  2137.        | SioModem    | Port     | Mask     |          |          |
  2138.        | SioParms    | Port     | Parity   | StopBits |WordLength|
  2139.        | SioPutc     | Port     | Ch       |          |          |
  2140.        | SioReset    | Port     | BaudCode |          |          |
  2141.        | SioRI       | Port     |          |          |          |
  2142.        | SioRTS      | Port     | Cmd      |          |          |
  2143.        | SioRxBuf    | Port     | Buffer   | SizeCode |          |
  2144.        | SioRxFlush  | Port     |          |          |          |
  2145.        | SioRxQue    | Port     |          |          |          |
  2146.        | SioTimer    |          |          |          |          |
  2147.        | SioUART     | Port     | Address  |          |          |
  2148.        | SioUnGetc   | Port     | Ch       |          |          |
  2149.        +-------------+----------+----------+----------+----------+
  2150.  
  2151.        ( 29 functions )
  2152.  
  2153.  
  2154.  
  2155.  
  2156.  
  2157.  
  2158.  
  2159.  
  2160.  
  2161.  
  2162.  
  2163.  
  2164.  
  2165.  
  2166.  
  2167.  
  2168.  
  2169.  
  2170.  
  2171.  
  2172.  
  2173.  
  2174.       PCL4C Reference Manual                                  Page 33
  2175.  
  2176.  
  2177.  
  2178.  
  2179.                              Error Code Summary
  2180.  
  2181.  
  2182.  
  2183.        Code      Description
  2184.  
  2185.          0        No error.
  2186.  
  2187.         -1        Timeout waiting for input. (Only returned by SioGetc).
  2188.  
  2189.         -2        Port not enabled. Call SioReset first.
  2190.  
  2191.         -3        No buffer  available.   Call  SioRxBuf  before  calling
  2192.                   SioReset.
  2193.  
  2194.         -4        Port  out of range. Expecting 0 to 3. Recall that COM1
  2195.                   is port 0, COM2 is port 1, etc.
  2196.  
  2197.         -5        Expected 'S', 'C', or 'R' as second argument.
  2198.  
  2199.         -6        Expected 'A', 'C', or 'D' as second argument.
  2200.  
  2201.         -7        Bad parity code specified. Must be 0 to 7.
  2202.  
  2203.         -8        Bad stop bits code specified. Must be 0 or 1.
  2204.  
  2205.         -9        Bad wordlength code specified. Must be 0 to 3.
  2206.  
  2207.        -10        Bad buffer size code specified. Must be 0 to 11.
  2208.  
  2209.        -11        Bad baud rate code. Must be 0 to 9.
  2210.  
  2211.        -12        Loopback test fails.
  2212.  
  2213.        -13        UART undefined.
  2214.  
  2215.        -14        Missing or bad UART.
  2216.  
  2217.        -15        Port already enabled.
  2218.  
  2219.        -16        Cannot enable both COM1 and COM3 or COM2 and COM4.
  2220.  
  2221.  
  2222.  
  2223.  
  2224.  
  2225.  
  2226.  
  2227.  
  2228.  
  2229.  
  2230.  
  2231.  
  2232.  
  2233.  
  2234.  
  2235.  
  2236.  
  2237.  
  2238.  
  2239.  
  2240.       PCL4C Reference Manual                                  Page 34
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.