
API-232 Library                   Aug. 1999
Copyright (C) 1987-1998  All Rights Reserved

About this document
=====================

This document contains information on API-232 library functions. For details on
how to install, configure and use the drivers and utilities, please refer to
User's Manual of respective MOXA board.

Contents are outlined below:
    The first Chapter provides an introduction to the API-232 library.

    Chapter 2 gives complete descriptions of the API-232 functions. A quick
    reference table can be found at the beginning of the chapter to help you to
    quickly find the function you need. Following is programming notes that
    gives you more insights.

    Chapter 3 helps you troubleshoot any programming problems.


Table of Contents
=================

Chapter 1  Introduction

Chapter 2  Library Functions

   2.1  Quick Reference Table
   2.2  Complete Function Descriptions
   2.3  Programming Notes
   2.4  Function Descriptions

Chapter 3  Troubleshooting Programming Problems


Chapter 1                                                        Introduction
------------------------------------------------------------------------------

The RS-232 communications interface is commonly used for personal computers as
well as industrial and lab instrumentation. The "API-232" is a software package
which uses the standard RS-232 protocols to control devices under DOS or
Windows 3.x. Programming is simplified Ä only one program need be written to
control any RS-232 device. Troubleshooting tools are also included to ease
system development.

The API-232 software has three major parts: first is the complete software
device driver for serial I/O processing and control including interrupt
handling, UART control and memory management; next is the group of interface
libraries which allows you to use high-level programming languages for serial
communications control; last is a complete set of application programs and
utilities, such as Data Scope, which allows you to troubleshoot your serial
communication more effectively.

A wide range of popular programming languages is supported: Microsoft C, Turbo
C, Turbo PASCAL, QuickBASIC, Assembly and CLIPPER under DOS; Visual Basic,
Visual C and Borland C under Windows 3.x; C under UNIX (C360 only).

In this document, only the API-232 library functions are detailed.


Chapter 2                                                    Library Functions
------------------------------------------------------------------------------

This chapter lists all the API-232 function calls under DOS and MS Windows 3.x.
The detail function, syntax and example of each library are also given.

The API-232 3.x/4.x/5.x is compatible with the early API-232 2.x at the
application binary code level except sio_getbaud() function. That means,
executable application program developed under API-232 2.x can be directly
ported to API-232 3.x/4.x/5.x environment without any modification, compiling
or linking provided that the sio_getbaud() function is not used. For those who
upgrade from  API-232 1.x, linking again the application object with API-232
3.x/4.x/5.x library is necessary.

MOXA DOS API-232 C Library to be linked with user-developed C program is
compiled and saved in 'MOXA-Cx.OBJ' files, where x = S/M/L/C for
Small/Medium/Large/Compact mode. The Modem Control and File Transfer libraries
are in 'FILE-Cx.OBJ' files and 'MODEM-Cx.OBJ'files, respectively.

MOXA DOS API-232 Assembly Library to be linked with user-developed Assembly
program is compiled and saved in the 'MOXA-ASM.OBJ' file.

MOXA DOS API-232 Turbo Pascal Library to be linked with user-developed Pascal
program is compiled and saved in the 'MOXA-TP.OBJ' file.

MOXA DOS API-232 Quick Basic Library to be linked with user-developed Basic
program is compiled and saved in the 'MOXA-QB.OBJ' file.

MOXA DOS API-232 Clipper Library to be linked with user-developed Clipper
program is compiled and saved in the 'MOXA-CLP.OBJ' file.

MOXA UNIX API-232 C Library to be linked with user-developed C program is
compiled and saved in the 'MXAPI232.LIB' file.


2.1 Quick Reference Table

The function list is organized in such a way that the similar functions are
grouped together. There are nine catagories: Driver Manipulation, Port Control,
Input Data, Output Data, Port Status Inquiry, Interrupt Control, Miscellaneous,
Modem Control and File Transfer Functions.

Note: (M) behind a function index means function Modified;
      (N) behind a function index means New function in comparision to
          API-232 2.x, 1.x.

Driver Manipulation
-------------------

     Index     Function                            Description
     -----    ----------             ----------------------------------------
       1      sio_init()             Initialize Windows DLL driver (only for
                                     Windows 3.x)
       2      sio_end()              Release Windows DLL driver (only for
                                     Windows 3.x)
       3      sio_reset()            Reset all ports

Port Control
------------

       4      sio_open()             Start port to receive/transmit data
       5      sio_close()            Stop port receiving/transmiting data
       6      sio_ioct1()            Set port baud rate, parity, etc.
       7      sio_flowctrl()         Set port H/W and/or S/W flow control
       8      sio_flush()            Flush input and/or output buffer
       9 (N)  sio_DTR()              Set DTR state
       10(N)  sio_RTS()              Set RTS state
       11     sio_lctrl()            Set both DTR and RTS state
       12(N)  sio_baud()             Set baud rate using the actual speed value
       13     sio_disableTx()        Stop port from transmiting data
       14     sio_enableTx()         Enable port to transmit data again
       15(N)  sio_disableRx()        Stop port from receiving data
       16(N)  sio_enableRx()         Enable port to receive data again
       17     sio_overlap()          Set driver to input buffer overlap mode
                                     when buffer's overflow
       18(N)  sio_ignore_errdata()   Discard data if received error

Input Data
----------

       19     sio_getch()            Read one character at a time from driver's
                                     input buffer
       20     sio_read()             Read a block of data from driver's input
                                     buffer
       21     sio_linput()           Read a block of data that ends with a
                                     terminator character
       22     sio_linput_t()         Same as sio_linput(), add timeout
                                     limitation

Output Data
-----------

       23     sio_putch()            Write one character at a time to driver's
                                     output buffer
       24     sio_putb()             Write a block of data (either whole block
                                     or nothing written)
       25     sio_write()            Write a block of data (probably only
                                     partial block written)
       26     sio_putb_t()           Same as sio_putb(), add timeout limitation
       27(N)  sio_putb_x()           Write a block of data (especially for
                                     RS-485 communication)

Port Status Inquiry
-------------------

       28     sio_lstatus()          Get line status
       29     sio_iqueue()           Size of data accumulated in driver's input
                                     buffer
       30     sio_oqueue()           Size of data not yet sent out (still kept
                                     in driver's output buffer)
       31     sio_ifree()            Size of free space in driver's input
                                     buffer
       32     sio_ofree()            Size of free space in driver's output
                                     buffer
       33     sio_Tx_hold()          Check the reason why data could not be
                                     transmitted
       34(M)  sio_getbaud()          Get the baud rate setting
       35     sio_getmode()          Get the parity, data bits... settings
       36     sio_getflow()          Get the H/W ans S/W flow control settings
       37     sio_brk_cnt()          Get the counter value of received BREAK
                                     and then clear
       38     sio_overflow()         Check if driver's input buffer overflow
       39(N)  sio_data_status()      Check if any error happen when receiving
                                     data

Interrupt Control
-----------------

       40     sio_term_irq()         Set interrupt service routine when
                                     terminator character received
       41     sio_cnt_irq()          Set interrupt service routine when certain
                                     amount of data received
       42     sio_modem_irq()        Set interrupt service routine when line
                                     status changed
       43     sio_break_irq()        Set interrupt service routine when break
                                     signal received
       44     sio_disableIRQ()       Disable the 'interrupt-driven' operation
                                     for sio_term_irq(), sio_break_irq(),
                                     sio_modem_irq() or sio_cnt_irq().
       45     sio_enableIRQ()        To enable the 'interrupt-driven' operation
                                     disabled by sio_disableIRQ() function.

Miscellaneous Functions
-----------------------

       46     sio_getports()         Get no. of ports recognized by the driver
       47     sio_break()            Send out BREAK signal
       48     sio_bank()             Get C320 memory base address
       49     sio_timeout()          Set timeout value for sio_linput_t() and
                                     sio_putb_t()
       50     sio_loopback()         Port loopback selftest
       51     sio_view()             View received data
       52     sio_linked()           Check if CPU module is linked
       53 (N) sio_getACs()           Get Connectrators' serial numbers
       54 (N) sio_ACstate()          Get Connectrator's status
       55 (N) sio_ACdiag             Concentrator's port diagnostics

Modem Control
-------------

      100(N)  sio_McAnswer()         Answer the caller manually
      101(N)  sio_McAutoAnswer()     Set auto answer after a number of rings
      102(N)  sio_McCommandMode()    Tell the modem to go off line
      103(N)  sio_McDataMode()       Tell the modem to go on line
      104(N)  sio_McDial()           Dial a phone number and wait for carrier
      105(N)  sio_McGetSRegister()   Read the value of the modem's S register
      106(N)  sio_McHangUp()         Hang up the line
      107(N)  sio_McIsConnect()      Check if the line is connected
      108(N)  sio_McOffHook()        Tell the modem to go off hook
      109(N)  sio_McReset()          Performs a reset of the modem
      110(N)  sio_McRings()          Read how many rings has come in
      111(N)  sio_McSetSRegister()   Send a register set command to the modem
      112(N)  sio_McSetString()      Set wait connect modem echo string
      113(N)  sio_McSetTimeout()     Set timeout seconds
      114(N)  sio_McWaitConnect()    Check if the line is connected, if not,
                                     wait for timeout
      115(N)  sio_McAnswer_ex()      Answer the caller manually
      116(N)  sio_McDataMode_ex()    Tell the modem to go on line
      117(N)  sio_McIsConnect_ex()   Check if the line is connected

File Transfer
-------------

      200(N)  sio_FtASCIIRx()              Receive a file using ASCII protocol
      201(N)  sio_FtASCIITx()              Transmit a file using ASCII protocol
      202(N)  sio_FtKermitRx()             Receive files using KERMIT protocol
      203(N)  sio_FtKermitTx()             Transmit files using KERMIT protocol
      204(N)  sio_FtXmodem1KCRCRx()        Receive a file using XMODEM, 1K CRC
      205(N)  sio_FtXmodem1KCRCTx()        Transmit a file using XMODEM, 1K CRC
      206(N)  sio_FtXmodemCheckSumRx()     Receive a file using XMODEM,checksum
      207(N)  sio_FtXmodemCheckSumTx()     Transmit a file using XMODEM,
                                           checksum
      208(N)  sio_FtXmodemCRCRx()          Receive a file using XMODEM, CRC
      209(N)  sio_FtXmodemCRCTx()          Transmit a file using XMODEM, CRC
      210(N)  sio_FtYmodemRx()             Receive files using YMODEM protocol
      211(N)  sio_FtYmodemTx()             Transmit a file using YMODEM
      212(N)  sio_FtZmodemRx()             Receive files using ZMODEM protocol
      213(N)  sio_FtZmodemTx()             Transmit a file using ZMODEM

Cross Reference
---------------
                                                   DOS/Win31
                         Func.  Product            Languages           UNIX C
Function Name            Index  Specific           Supported           Specific
-------------            -----  --------------     ------------------  --------
sio_bank()                48    C218/C320          All
                                C218 Turbo Series
                                only
sio_baud()                12                       All
sio_ACdiag()              55    C360 only          All
sio_ACstate()             54    C360 only          All
sio_break()               47                       All                  UNIX
sio_break_irq()           43                       C/ASM/Win31
sio_brk_cnt()             37                       All
sio_close()                5                       All                  UNIX
sio_cnt_irq()             41                       C/ASM/Win31
sio_data_status()         39                       All
sio_disableIRQ()          44                       C/ASM/PASCAL/Win31
sio_disableRx()           15                       All
sio_disableTx()           13                       All                  UNIX
sio_DTR()                  9                       All                  UNIX
sio_enableIRQ()           45                       C/ASM/PASCAL/Win31
sio_enableRx()            16                       All
sio_enableTx()            14                       All                  UNIX
sio_end()                  2                       Win31
sio_flowctrl()             7                       All                  UNIX
sio_flush()                8                       All                  UNIX
sio_FtASCIIRx()          200                       C/Win31
sio_FtASCIITx()          201                       C/Win31
sio_FtKermitRx()         202                       C/Win31
sio_FtKermitTx()         203                       C/Win31
sio_FtXmodem1KCRCRx()    204                       C/Win31
sio_FtXmodem1KCRCTx()    205                       C/Win31
sio_FtXmodemCheckSumRx() 206                       C/Win31
sio_FtXmodemCheckSumTx() 207                       C/Win31
sio_FtXmodemCRCRx()      208                       C/Win31
sio_FtXmodemCRCTx()      209                       C/Win31
sio_FtYmodemRx()         210                       C/Win31
sio_FtYmodemTx()         211                       C/Win31
sio_FtZmodemRx()         212                       C/Win31
sio_FtZmodemTx()         213                       C/Win31
sio_getbaud()             34                       All
sio_getACs()              53    C360 only          C/PASCAL/ASM
sio_getch()               19                       All
sio_getflow()             36                       All
sio_getmode()             35                       All
sio_getports()            46                       C/PASCAL/ASM/Win31
sio_ifree()               31                       All
sio_ignore_errdata()      18                       All
sio_init()                 1                       Win31
sio_ioctl()                6                       All                  UNIX
sio_iqueue()              30                       All                  UNIX
sio_lctrl()               11                       All                  UNIX
sio_linked()              52    C320 only          All
sio_linput()              21                       All
sio_linput_t()            22                       All
sio_loopback()            50    Not for C360/C320  All
                                Turbo
sio_lstatus()             28                       All                  UNIX
sio_McAnswer()           100                       C/Win31
sio_McAnswer()_ex        115                       C
sio_McAutoAnswer()       101                       C/Win31
sio_McCommandMode()      102                       C/Win31
sio_McDataMode()         103                       C/Win31
sio_McDataMode_ex()      116                       C
sio_McDial()             104                       C/Win31
sio_McGetSRegister()     105                       C/Win31
sio_McHangUp()           106                       C/Win31
sio_McIsConnect()        107                       C/Win31
sio_McIsConnect_ex()     117                       C
sio_McOffHook()          108                       C/Win31
sio_McReset()            109                       C/Win31
sio_McRings()            110                       C/Win31
sio_McSetSRegister()     111                       C/Win31
sio_McSetString()        112                       C/Win31
sio_McSetTimeout()       113                       C/Win31
sio_McWaitConnect()      114                       C/Win31
sio_modem_irq()           42                       C/ASM/Win31
sio_ofree()               32                       All
sio_open()                 4                       All                  UNIX
sio_oqueue()              30                       All                  UNIX
sio_overflow()            38    Not for C218/C320  All
                                Turbo Series
sio_overlap()             17    Not for C360       All
                                C218/C320 Turbo
                                Series
sio_putb()                24                       All                  UNIX
sio_putb_t()              26                       All
sio_putb_x()              27    Not for C360       All
sio_putch()               23                       All
sio_read()                20                       All                  UNIX
sio_reset()                3                       All
sio_RTS()                 10                       All                  UNIX
sio_term_irq()            40                       C/ASM/Win31
sio_timeout()             49                       All
sio_Tx_hold()             33                       All
sio_view()                51                       All
sio_write()               25                       All                  UNIX


2.2 Buffer Concept

There are two kinds of buffer need to be understood in writing application
software that calls API-232 functions. One is the buffer manipulated by the
device driver, or "driver's buffer". The other is the buffer managed by user's
application, or "user's buffer".

Input
-----

     After loading the device driver, the driver starts to read the character
     queued in the UART chip if the port is properly initialized. It then puts
     the character into the "driver's input buffer" which is maintained by the
     driver itself. The data are kept in "driver's input buffer" until the
     user's application calls API-232 function (e.g. sio_read()) to read to
     the "user's input buffer".

       user's application        device driver         UART chip
       ------------------      -----------------       +------+
       |     user's     | <--  |   driver's    | <--   | FIFO | <-- RS-232 line
       |  input buffer  |      | input buffer  |       +------+
       |                |      |               |
       ------------------      -----------------

Output
------

     To output data, the user's application first prepare the data in the
     "user's output buffer". It then put the data into the "driver's output
     buffer" by calling API-232 function (e.g. sio_putb()). The driver will
     continue to send out data in the "driver's output buffer" to UART chip
     character by character.

       user's application        device driver         UART chip
       ------------------      -----------------       +------+
       |     user's     | -->  |   driver's    | -->   | FIFO | --> RS-232 line
       |  output buffer |      | output buffer |       +------+
       |                |      |               |
       ------------------      -----------------


2.3 Programming Notes

A simplest program that calls API-232 functions would have a similar structure
as follows.

    .  Calling Driver Manipulation functions

    .  Calling Port Control functions

    .  Calling Input/Output Data functions

    .  Calling Port Status functions if necessary

For example, following illustrates a piece code of a simple API-232 calls
in C language.  (Variables are not defined)

     /* i=sio_init();  */ /* If under Windows 3.x, uncomment this func. */
     i=sio_reset();       /* Driver Manipulation function */
     if (i <= 0) {
          printf ("No driver found!\n");
          exit();
     }
     i=sio_open (port);                  /* Port Control, enable the port  */
     if (i == 0) {
          printf ("port opened ok.\n");
          sio_ioctl (port, baud, mode);  /* Port Control,set baud,parity... */
          sio_putb (port, "ABCDE", 5);   /* Output Data function */
          sio_read (port, ibuf, length); /* Input Data function  */
     }

The following functions must be used after sio_open().

        sio_getch()
        sio_read()
        sio_linput()
        sio_linput_t()
        sio_putch()
        sio_write()
        sio_putb()
        sio_putb_t()
        sio_putb_x()
        sio_flush()
        sio_iqueue()
        sio_ifree()
        sio_oqueue()
        sio_ofree()
        sio_oqueue()
        sio_ofree()
        sio_break()
        sio_view()
        sio_baud()
        sio_DTR()
        sio_RTS()
        sio_ignore_errdata()
        sio_disableTx()
        sio_disableRx()
        sio_enableRx()
        sio_disableIRQ()
        sio_term_irq()
        sio_break_irq()
        sio_modem_irq()
        sio_cnt_irq()

sio_close() function do the followings:

        . Clear term/break/modem/cnt interrupt service routine address set by
          sio_term_irq(), sio_break_irq(), sio_modem_irq() and sio_cnt_irq().
        . Disable all these interrupts.
        . Flush Tx/Rx data buffer.
        . Disable Tx and Rx.

sio_open() function do the following:

        . Enable Tx and Rx.

sio_reset() function do the following:

        . Enable driver settings to those of SETUP program.
        . Set all ports to accept error data mode.

sio_tx_hold() function do not fully support C320.

        . The bit 1 (XOFF received) is not abailable.


2.4 Function Descriptions

Function 1  sio_init()

Driver initialization for MS Windows 3.x. The DLL driver is invoked, the
board's configuration file is read, and then the driver will find the
multiport board and do the port initialization.

     Language        Syntax

     DOS C           ---
     DOS PASCAL      ---
     DOS QBASIC      ---
     DOS CLIPPER     ---
     DOS Assembly    ---
     Windows C       int WINAPI sio_init()
     Windows VB      Function Declare sio_init()
     UNIX C          ---

Argument:

     None

Return:

     int n
     n =  0:  No board found
        1-4:  Number of boards found
         -1:  User not running in 386 Enhanced mode
         -2:  MX-WIN.CNF file format error or can not open
     -3, -4:  Not enough space for extended rcv buffer
         -5:  Extended rcv buffer can't be locked
         -6:  Can't open *.cod (C218dos.cod or C320dos.cod) or file formal
              error

Note: If there is an error or no board is found, further functions will not
      work.

Example:  (Windows C)

     int i;
     i = sio_init();


Function 2  sio_end()

Releases the MOXA Windows 3.x driver and frees all allocated memory.

     Language        Syntax

     DOS C           ---
     DOS PASCAL      ---
     DOS QBASIC      ---
     DOS CLIPPER     ---
     DOS Assembly    ---
     Windows C       void WINAPI sio_end()
     Windows VB      Function Declare sio_end()
     UNIX C          ---

Argument:

     None

Return:

     None


Function 3  sio_reset()

Resets all serial ports, disable all interrupt service routines, and flushes
the driver's input & output buffers.

     Language        Syntax

     DOS C           int sio_reset()
     DOS PASCAL      sio_reset:integer
     DOS QBASIC      SioReset(drvno%)
     DOS CLIPPER     sio_reset()
     DOS Assembly    __sio_reset
     Windows C       int WINAPI sio_reset()
     Windows VB      Function Declare sio_reset()
     UNIX C          ---

Argument:

     None

Return:

     int n (ax)

     n > 0:  Total number of drivers
       <=0:  No driver found

Example (C language):

     int stat;
     if((stat = sio_reset()) <=0)
         printf("No Driver Found !\n");


Function 4  sio_open()

Enables a serial port for transmit/receive.  The port must be enabled by
issuing this function before the following operations: sio_getch, sio_linput,
sio_read, sio_iqueue, sio_ifree, sio_putch, sio_putb, sio_write, sio_oqueue,
sio_ofree, sio_flush, sio_disableTx, sio_enableTx, sio_putb_t, sio_linput_t,
sio_term_irq, sio_cnt_irq, sio_modem_irq, sio_break_irq, sio_putb_x.

     Language        Syntax

     DOS C           sio_open(int port)
     DOS PASCAL      sio_open(port:integer) :integer
     DOS QBASIC      SioOpen(port%, n%)
     DOS CLIPPER     sio_open(port)
     DOS Assembly    __sio_open
     Windows C       int WINAPI sio_open(port)
     UNIX C          sio_open(int port)

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -3:  Bad function call
         -2:  Time out

Example (C language):

     int port=1;
     if(sio_open(port)==0)
         printf("Port 1 opened\n");


Function 5  sio_close()

Disables a serial port so that it cannot receive/transmit data.

     Language        Syntax

     DOS C           sio_close(int port)
     DOS PASCAL      sio_close(port:integer):integer
     DOS QBASIC      SioClose(port%, n%)
     DOS CLIPPER     sio_close(port)
     DOS Assembly    __sio_close
     Windows C       int WINAPI sio_close(port)
     UNIX C          sio_close(int port)

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n >= 0:  OK
              0 -- No data in Tx/Rx buffer when the port is closed
              1 -- Some data still in Rx buffer
              2 -- Some data still in Tx buffer
              3 -- Some data still in Tx and Rx buffer
         -1:  No such port
         -3:  Bad function call
         -2:  Time out

Example (C language):

     int port=1;
     if(sio_close(port)==0)
         printf("Port 1 closed\n");


Function 6  sio_ioctl()

Controls the setting of the serial port's I/O control register, such as baud
rate, parity, data bits and stop bits.

     Language        Syntax

     DOS C           sio_ioctl(int port, int baud, int mode)
     DOS PASCAL      sio_ioctl(port, baud, mode:integer):integer
     DOS QBASIC      SioIoctl(port%, baud%, mode%, n%)
     DOS CLIPPER     sio_ioctl(port, baud, mode)
     DOS Assembly    __sio_ioctl
     Windows C       int WINAPI sio_ioctl(port, baud, mode)
     UNIX C          sio_ioctl(int port, int baud, int mode)

Argument:

     int port (dx) = Port number
     int baud (ch) = 0=50     6=600      12=9600     18=460800
                     1=75     7=1200     13=19200    19=921600
                     2=110    8=1800     14=38400    (bits/sec)
                     3=134.5  9=2400     15=57600
                     4=150    10=4800    16=115200
                     5=300    11=7200    17=230400

     Note: Some MOXA boards may not support higher speeds.  Please refer to
           the baord's manual for information.

     int mode (cl) = bit_cnt OR stop_bit OR parity
                     bit_cnt (bit 0, 1)   = 0x00=bit_5
                                            0x01=bit_6
                                            0x02=bit_7
                                            0x03=bit_8
                     stop_bit (bit 2)     = 0x00=stop_1
                                            0x04=stop_2
                     parity (bit 3, 4, 5) = 0x00=none
                                            0x08=odd
                                            0x18=even
                                            0x28=mark
                                            0x38=space

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Can't control MOXA board
              or time out (UNIX only)
         -3:  Bad function call
         -4:  Bad baud rate (UNIX only)


Example (C language):

     #include "head-c.h"
     int port=0;   /* set up 2400 baud, none parity, 8 data bit, 1 stop bit  */
     if(sio_ioctl(port, B2400, P_NONE | BIT_8 | STOP_1)==0)
         printf("Setting port #%d:B2400,n,8,1\n", port);


Function 7  sio_flowctrl()

Sets hardware and/or software flow control.

     Language        Syntax

     DOS C           sio_flowctrl(int port, int mode)
     DOS PASCAL      sio_flowctrl(port, mode:integer):integer
     DOS QBASIC      SioFlowCtrl(port%, mode%, n%)
     DOS CLIPPER     sio_flow(port, mode)
     DOS Assembly    __sio_flowctrl
     Windows C       int WINAPI sio_flowctrl(port, mode)
     UNIX C          sio_flowctrl(int port, int mode)

Argument:

     int port (dx) = Port number
     int mode (al) = Bit 0:  CTS flow control
                     Bit 1:  RTS flow control
                     Bit 2:  Tx XON/XOFF flow control
                     Bit 3:  Rx XON/XOFF flow control
                     (0=OFF  1=ON)

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -3:  Bad function call
         -2:  Time out

Example (C language):

     int stat, port=1, mode=3;  /* set H/W flow control */
     stat = sio_flowctrl(port, mode);


Function 8  sio_flush()

Flushes the driver's input/output buffer.  The data will no longer exists.

     Language        Syntax

     DOS C           sio_flush(int port, int func)
     DOS PASCAL      sio_flush(port, func:integer):integer
     DOS QBASIC      SioFlush(port%, func%, n%)
     DOS CLIPPER     sio_flush(port, func)
     DOS Assembly    __sio_flush
     Windows C       int WINAPI sio_flush(port, func)
     UNIX C          sio_flush(int port, int func)

Argument:

     int port (dx) = Port number
     int func (ax) = Flush function (clear the assigned queue)
                     0 : Flush input buffer
                     1 : Flush output buffer
                     2 : Flush input & output buffer

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Can't control MOXA board
              or time out (UNIX only)
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int stat, port=1, func=0; /* flush input queue */
     stat = sio_flush(port, func);


Function 9 (N)  sio_DTR()

Sets the DTR state of a port.

     Language        Syntax

     DOS C           sio_DTR(int port, int mode)
     DOS PASCAL      sio_DTR(port, mode:integer):integer
     DOS QBASIC      SioDTR(port%, mode%, n%)
     DOS CLIPPER     sio_DTR(port, mode)
     DOS Assembly    __sio_DTR
     Windows C       int WINAPI sio_DTR(port, mode)
     UNIX C          sio_DTR(int port, int mode)

Argument:

     int port (dx) = Port number
     int mode (ax) = 0: Turn DTR off
                     1: Set DTR on

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -3:  Bad function call
         -2:  Time out
         -5:  Port not open

Example (C language):

     int stat, port=1, mode=1;
     stat = sio_DTR(port, mode);     /* to set DTR on */

Function 10 (N)  sio_RTS()

Sets the RTS state of a port.

     Language        Syntax

     DOS C           sio_RTS(int port, int mode)
     DOS PASCAL      sio_RTS(port, mode:integer):integer
     DOS QBASIC      SioRTS(port%, mode%, n%)
     DOS CLIPPER     sio_RTS(port, mode)
     DOS Assembly     __sio_RTS
     Windows C       int WINAPI sio_RTS(port, mode)
     UNIX C          sio_RTS(int port, int mode)

Argument:

     int port (dx) = Port number
     int mode (ax) = 0: Turn RTS off
                     1: Set RTS on

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -3:  Bad function call
         -6:  Can't control because the port is set as H/W flow control enabled
              by sio_flowctrl() or driver setup program.
         -2:  Time out
         -5:  Port not open

Example (C language):

     int stat, port=1, mode=1;
     stat = sio_RTS(port, mode);     /* to set RTS on */


Function 11  sio_lctrl()

Sets both the DTR and RTS state.

     Language        Syntax

     DOS C           sio_lctrl(int port, int mode)
     DOS PASCAL      sio_lctrl(port, mode:integer):integer
     DOS QBASIC      SioLctrl(port%, mode%, n%)
     DOS CLIPPER     sio_lctrl(port, mode)
     DOS Assembly    __sio_lctrl
     Windows C       it WINAPI sio_lctrl(port, mode)
     UNIX C          sio_lctrl(int port, int mode)

Argument:

     int port (dx) = Port number
     int mode (ax) = C_DTR (bit 0), C_RTS (bit 1)

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Can't control MOXA board
              or time out (UNIX only)
         -3:  Bad function call

Example (C language):

     #include "head-c.h"

     int stat, port=1;
     stat = sio_lctrl(port, C_DTR | C_RTS);


Function 12 (N)  sio_baud()

Set baud rate using the actual speed value.

     Language        Syntax

     DOS C           sio_baud(int port, long speed)
     DOS PASCAL      sio_baud(port:integer, speed:long):integer
     DOS QBASIC      SioBaud(port%, speed%, n%)
     DOS CLIPPER     sio_baud(port, speed)
     DOS Assembly    __sio_baud
     Windows C       int WINAPI sio_baud(port, speed)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     long speed (cx:ax) = True baud rate, e.g. 200, 1200, 9600, 19200, etc.

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Time out
         -3:  Bad function call
         -5:  Port not open
         -6:  Bad baud rate

Example (C language):

     int stat, port=1;
     stat = sio_baud(port, 200);  /* to set port speed to 200 bps */


Function 13  sio_disableTx()

Stop the port from transmiting data.

     Language        Syntax

     DOS C           sio_disableTx(int port)
     DOS PASCAL      sio_disableTx(port:integer):integer
     DOS QBASIC      SioDisableTx(port%, n%)
     DOS CLIPPER     sio_disTx(port)
     DOS Assembly    __sio_disableTx
     Windows C       int WINAPI sio_disableTx(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Can't control MOXA board
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int port=1;
     if(sio_disableTx(port)==0)
         printf("Port 1 transmit disabled\n");


Function 14  sio_enableTx()

Enable the port to transmit data again.

     Language        Syntax

     DOS C           sio_enableTx(int port)
     DOS PASCAL      sio_enableTx(port:integer):integer
     DOS QBASIC      SioEnableTx(port%, n%)
     DOS CLIPPER     sio_enTx(port)
     DOS Assembly    __sio_enableTx
     Windows C       int WINAPI sio_enableTx(port)
     UNIX C          sio_enableTx(int port)

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Can't control MOXA board
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int port=1;
     if(sio_enableTx(port)==0)
         printf("Port 1 transmit enabled\n");


Function 15 (N)  sio_disableRx()

Stop the port from receiving data.

     Language        Syntax

     DOS C           sio_disableRx(int port)
     DOS PASCAL      sio_disableRx(port:integer):integer
     DOS QBASIC      SioDisableRx(port%, n%)
     DOS CLIPPER     sio_disRx(port)
     DOS Assembly    __sio_disableRx
     Windows C       int WINAPI sio_disableRx(port)
     UNIX C          sio_disableRx(int port)

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Can't control MOXA board
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int port=1;
     if(sio_disableRx(port)==0)
         printf("Port 1 receival data disabled\n");


Function 16 (N)  sio_enableRx()

Enable the port to receive data again.

     Language        Syntax

     DOS C           sio_enableRx(int port)
     DOS PASCAL      sio_enableRx(port:integer):integer
     DOS QBASIC      SioEnableRx(port%, n%)
     DOS CLIPPER     sio_enRx(port)
     DOS Assembly    __sio_enableRx
     Windows C       int WINAPI sio_enableRx(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Can't control MOXA board
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int port=1;
     if(sio_enableRx(port)==0)
         printf("Port 1 receiving data enabled\n");


Function 17  sio_overlap()

Set the data processing method to the either data-overlap or non-data-overlap
mode when the driver's input buffer is full.

     Language        Syntax

     DOS C           sio_overlap(int port, int mode)
     DOS PASCAL      sio_overlap(port, mode:integer):integer
     DOS QBASIC      SioOverlap(port%, mode%, n%)
     DOS CLIPPER     sio_olap(port, mode)
     DOS Assembly    __sio_overlap
     Windows C       int WINAPI sio_overlap(port, mode)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     int mode (ax) = 0:  When Rx buffer is full, received data cannot overlap.
                         Last received data will be lost. For C320 Turbo and
                         C360, the only mode supported is non-data-overlap.
                     1:  When Rx buf full, newly received data will overlap the
                         previously received data. Part or all of the received
                         data in input buffer will be lost.

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -3:  Bad function

Example (C language):

     /*  enable buffer overlap function */
     int stat, port=1, mode=1
     stat = sio_overlap(port, mode);


Function 18 (N)  sio_ignore_errdata()

Discard data if received data error.

     Language        Syntax

     DOS C           sio_ignore_errdata(int port, int mode)
     DOS PASCAL      sio_ignore_errdata(port, mode:integer):integer
     DOS QBASIC      SioIgnoreErrdata(port%, mode%, n%)
     DOS CLIPPER     sio_iedata(port, mode)
     DOS Assembly    __sio_ignore_errdata
     Windows C       int WINAPI sio_ignore_errdata(port, mode)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     int mode (ax) = 0: Accept data even error
                     1: Ignore (or discard) data if error

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Time out
         -3:  Bad function call
         -5:  Port not open

Example (C language):

     int port=1;
     if(sio_ignore_errdata(port, 1)==0)
         printf("Port 1 will discard data if error");


Function 19  sio_getch()

Read one character from the driver's input buffer.

     Language        Syntax

     DOS C           sio_getch(int port)
     DOS PASCAL      sio_getch(port:integer):integer
     DOS QBASIC      SioGetch(port%, n%)
     DOS CLIPPER     sio_getch(port)
     DOS Assembly    __sio_getch
     Windows C       int WINAPI sio_getch(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:
     int n (ax)

     n = -1:  No such port
         -3:  Bad function call
         -4:  EOL, no data read
         -5:  Port is not opened
         0~255:  The character read

Example (C language):

     int stat, port;
     if((stat = sio_getch(port)) >= 0)
          printf("Character [%c] read", stat);


Function 20  sio_read()

Reads data from the driver's input buffer.  If the length of data in the
driver's input buffer is less than the user's buffer, then all data in the
driver's input buffer will be transferred to the user's buffer.  Otherwise,
only 'len' bytes will be transferred to the user's buffer.

     Language        Syntax

     DOS C           sio_read(int port, char *buf, int len)
     DOS PASCAL      sio_read(port:integer):string
     DOS QBASIC      SioRead(port%, buf$, n%)
     DOS CLIPPER     sio_read(port, buf)
     DOS Assembly    __sio_read
     Windows C       int WINAPI sio_read(port, LPSTR buf, len)
     UNIX C          sio_read(int port, char *buf, int len)

Argument:

     int port (dx) = Port number
     char *buf (es:di) = Receive buffer pointer with sufficient space
     int len (cx) = Buffer length

Return:

     int n (ax)

     n >  0:  Length of data received
       =  0:  No data received
         -1:  No such port
         -3:  Bad function call
         -5:  Port is not opened
         -2:  Time out (UNIX only)

Example (C language):

     #define LEN 80;
     int stat, port=1; char buf [LEN];
     if((stat = sio_read(port, buf, LEN)) >0)
         printf("%d characters received\n", stat);


Function 21  sio_linput()

Reads a block of data from the driver's input buffer until the terminator
character is encountered or 'len' bytes of data are read.

     Language        Syntax

     DOS C           sio_linput(int port, char *buf, int len, int term)
     DOS PASCAL      sio_linput(port, term:integer):string
     DOS QBASIC      SioLinput(port%, buf$, term%, n%)
     DOS CLIPPER     sio_linput(port, buf, term)
     DOS Assembly    __sio_linput
     Windows C       int WINAPI sio_linput(port, LPSTR buf, len, term)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     char *buf (es:di) = Receive buffer pointer
     int len (cx) = Buffer length
     int term (al) = Terminator character

Return:

     int n (ax)

     n >  0:  Length of data received
       =  0:  No data received
         -1:  No such port
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int stat;
     stat = sio_linput(0, buf, 10, 13);

     /* Read data from port 0, max length is 10 bytes, terminator is CR (ASCII
        13). If less than 10 characters accumulated in driver's input buffer
        and a CR is in the 5th byte, this function will read 5 bytes, including
        CR. If more than 10 bytes are queued in the buffer without a CR, it
        will read the first 10 bytes into the user buffer `buf'. */


Function 22  sio_linput_t()

Reads block of a data from the drivers input buffer until the termination
character is encountered or a timeout occurs. (See also the sio_linput()
function.)

     Language        Syntax

     DOS C           sio_linput_t(int port, char *buf, int len, int term)
     DOS PASCAL      sio_linput_t(port, term:integer):string
     DOS QBASIC      SioLinputT(port%, buf$, term%, len%)
     DOS CLIPPER     sio_line_t(port, buf, term)
     DOS Assembly     __sio_linput_t
     Windows C       int WINAPI sio_linput_t(port, LPSTR buf, len, term)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     char *buf (es:di) = Receive buffer pointer with required space
     int len (cx) = Buffer length
     int term (al) = Terminator character

Return:

     int n (ax)

     n >  0:  Length of data received
       =  0:  No data received
         -1:  No such port
         -2:  Time out
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int stat, port=1, len=40, term=13; char buf[80];
     stat = sio_timeout(18); /* set 1 sec timeout */
     stat = sio_linput_t(port, buf, len, term);


Function 23  sio_putch()

Writes a character into the driver's output buffer.

     Language        Syntax

     DOS C           sio_putch(int port, int code)
     DOS PASCAL      sio_putch(port, code:integer):integer
     DOS QBASIC      SioPutch(port%, code%, n%)
     DOS CLIPPER     sio_putch(port, code)
     DOS Assembly    __sio_putch
     Windows C       int WINAPI sio_putch(port, code)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     int code (al) = Character (0 - 255)

Return:

     int n (ax)

     n =  1:  OK
          0:  Buffer full
         -1:  No such port
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int stat, port=1, code=13;
     stat = sio_putch(port, code);


Function 24  sio_putb()

Puts a block of data in the driver's output buffer.  If the output buffer free
space is less than the block length, it will return zero and no data is
written.  See also sio_write() for comparison.

     Language        Syntax

     DOS C           sio_putb(int port, char *buf, int len)
     DOS PASCAL      sio_putb(port:integer; buf:string):integer
     DOS QBASIC      SioPutb(port%, buf$, len%)
     DOS CLIPPER     sio_putb(port, buf)
     DOS Assembly    __sio_putb
     Windows C       int WINAPI sio_putb(port, LPSTR buf, len)
     UNIX C          sio_putb(int port, char *buf, int len)

Argument:

     int port (dx) = Port number
     char *buf (ds:si) = Transmit string pointer
     int len (cx) = Transmit string length

Return:

     int n (ax)

     n >  0:  Length of data transmitted
       =  0:  Free buffer not enough
         -1:  No such port
         -3:  Bad function call
         -5:  Port is not opened
         -6:  Data block too large, larger than the Tx buffer of the driver
              adjust the data block size
         -2:  Time out (UNIX only)

Example (C language):

     int stat, port=1, len=14; char *buf="This is a test";
     stat = sio_putb(port, buf, len);


Function 25  sio_write()

Puts a block of data to the driver's output buffer.  The actual length of
data written depends on the amount of free space in the driver's output
buffer.  See also sio_putb() for comparison.

     Language        Syntax

     DOS C           sio_write(int port, char *buf, int len)
     DOS PASCAL      sio_write(port:integer; buf:string):integer
     DOS QBASIC      SioWrite(port%, buf$, len%)
     DOS CLIPPER     sio_write(port, buf)
     DOS Assembly    __sio_write
     Windows C       int WINAPI sio_write(port, LPSTR buf, len)
     UNIX C          sio_write(int port, char *buf, int len)

Argument:

     int port (dx) = Port number
     char *buf (ds:si) = Transmit string pointer
     int len (cx) = Transmit string length

Return:

     int n (ax)

     n >  0:  Length of data transmitted
       =  0:  Buffer full
         -1:  No such port
         -3:  Bad function call
         -5:  Port is not opened
         -2:  Time out (UNIX only)

Example (C language):

     int stat, port=0, len=14; char *buf="This is a test";
     stat = sio_write(port, buf, len);


Function 26  sio_putb_t()

Writes a block of data into the driver's output buffer with a time out
check.  See also sio_putb()

     Language        Syntax

     DOS C           sio_putb_t(int port, char *buf, int len)
     DOS PASCAL      sio_putb_t(port:integer; buf:string): integer
     DOS QBASIC      SioPutbT(port%, buf$, n%)
     DOS CLIPPER     sio_putb_t(port, buf)
     DOS Assembly    __sio_putb_t
     Windows C       int WINAPI sio_putb_t(port, LPSTR buf, len)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     char *buf (ds:si) = Transmit string pointer
     int len (cx) = Transmit string length

Return:

     int n (ax)

     n >= 0:  Data transmitted
         -1:  No such port
         -2:  Time out
         -3:  Bad function call
         -5:  Port not open
         -6:  Data block too large, than the Tx buffer of the driver.
              Please adjust the data block size

Example (C language):

     #define LEN 80
     int stat, port=1, len=40; char buf[LEN];
     stat = sio_timeout(18); /* set 1 sec timeout */
     stat = sio_putb_t(port, buf, len);


Function 27 (N)  sio_putb_x()

Set RTS state on before writing a block of data into the driver's output
buffer. After writing the data into the driver's output buffer, wait 'tick'
tick (1/18.2 s) then turn RTS off. This function is useful for RS-485 comm.

     Language        Syntax

     DOS C           sio_putb_x(int port, char *buf, int len, int tick)
     DOS PASCAL      sio_putb_x(port:integer; buf:string, tick:integer):integer
     DOS QBASIC      SioPutbX(port%, buf$, n%)
     DOS CLIPPER     sio_putb_x(port, buf)
     DOS Assembly    __sio_putb_x
     Windows C       int WINAPI sio_putb_x(port, LPSTR buf, len, tick)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     char *buf (ds:si) = Transmit string pointer
     int len (cx) = Transmit string length
     int tick (ax) = Delay time in ticks

Return:

     int n (ax)

     n >  0:  Data transmitted
       =  0:  Free buffer not enough
         -1:  No such port
         -3:  Bad function call
         -5:  Port is not opened
         -6:  Data block large than the driver's output buffer.
              Please adjust the data block size

Example (C language):

     int stat, port=1, len=40; char buf[40];
     stat = sio_putb_x(port, buf, len, 1);


Function 28  sio_lstatus()

Gets the status of the line.

     Language        Syntax

     DOS C           sio_lstatus(int port)
     DOS PASCAL      sio_lstatus(port:integer):integer
     DOS QBASIC      SioLstatus(port%, n%)
     DOS CLIPPER     sio_lstatu(port)
     DOS Assembly    __sio_lstatus
     Windows C       int WINAPI sio_lstatus(port)
     DOS C           sio_lstatus(int port)

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n >= 0:  Line status : Bit 0 -- S_CTS
                            Bit 1 -- S_DSR
                            Bit 2 -- S_RI
                            Bit 3 -- S_CD
         -1:  No such port
         -2:  Can't control MOXA board
              or time out (UNIX only)
         -3:  Bad function call

Example (C language):

     int port=1;
     if(sio_lstatus(port) & S_DSR)
         printf("DSR ON\n");
     else
         printf("DSR OFF\n");


Function 29  sio_iqueue()

Gets the size of data accumulated in the driver's input buffer.

     Language        Syntax

     DOS C           sio_iqueue(int port)
     DOS PASCAL      sio_iqueue(port:integer):integer
     DOS QBASIC      SioIQueue(port%, n%)
     DOS CLIPPER     sio_iqueue(port)
     DOS Assembly    __sio_iqueue
     Windows C       long WINAPI sio_iqueue(port)
     UNIX C          sio_iqueue(int port)

Argument:

     int port (dx) = Port number

Return:

     long int n (ax)

     n >= 0:  Data in input buffer (bytes)
         -1:  No such port
         -2:  Time out
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int port=1; long stat;
     stat = sio_iqueue(port);
     if(stat>0)
         printf("%ld bytes data in receive buffer\n", stat);



Function 30  sio_oqueue()

Gets the length of data not yet sent out in the driver's output buffer.  (User
must be aware of the fact that there may have a couple of characters still kept
in RS-232 UART chip and not yet transmitted when the sio_oqueue() return a zero
value.)

     Language        Syntax

     DOS C           sio_oqueue(int port)
     DOS PASCAL      sio_oqueue(port:integer):integer
     DOS QBASIC      SioOQueue(port%, n%)
     DOS CLIPPER     sio_oqueue(port)
     DOS Assembly    __sio_oqueue
     Windows C       long WINAPI sio_oqueue(port)
     UNIX C          sio_oqueue(int port)

Argument:

     int port (dx) = Port number

Return:

     long int n (ax)

     n >= 0:  Length of data still kept in the driver's output buffer
         -1:  No such port
         -2:  Time out
         -5:  Port is not opened

Example (C language):

     int port=1; long stat;
     stat = sio_oqueue(port);
     if(stat>0)
         printf ("%ld bytes data in transmit buffer\n", stat);


Function 31  sio_ifree()

Gets the length of free space in driver's input buffer.

     Language        Syntax

     DOS C           sio_ifree(int port)
     DOS PASCAL      sio_ifree(port:integer):integer
     DOS QBASIC      SioIFree(port%, n%)
     DOS CLIPPER     sio_ifree(port)
     DOS Assembly    __sio_ifree
     Windows C       long WINAPI sio_ifree(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:

     long int n (ax)

     n >= 0:  Free space in input buffer
         -1:  No such port
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int port=1; long stat;
     stat = sio_ifree(port);
     if(stat > 0)
         printf("Free receive buffer size=%d\n", stat);


Function 32  sio_ofree()

Gets the length of free space in the driver's output buffer.

     Language        Syntax

     DOS C           sio_ofree(int port)
     DOS PASCAL      sio_ofree(port:integer):integer
     DOS QBASIC      SioOFree(port%, n%)
     DOS CLIPPER     sio_ofree(port)
     DOS Assembly    __sio_ofree
     Windows C       long WINAPI sio_ofree(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:

     long int n (ax)

     n => 0:  Free space in output buffer
         -1:  No such port
         -3:  Bad function call
         -5:  Port is not opened

Example (C language):

     int port=1; long stat;
     if((stat = sio_ofree(port)) > 0);
         printf("Free transmit buffer size=%ld\n", stat)



Function 33  sio_Tx_hold()

Check the reason why data could not be transmitted.

     Language        Syntax

     DOS C           sio_Tx_hold(int port)
     DOS PASCAL      sio_Tx_hold(port:integer):integer
     DOS QBASIC      SioTxHold(port%, n%)
     DOS CLIPPER     sio_Txhold(port)
     DOS Assembly    __sio_Tx_hold
     Windows C       int WINAPI sio_Tx_hold(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n >= 0:  Bit 0 on -- Could not transmit data because CTS is low
              Bit 1 on -- Could not transmit data because XOFF char received
              Bit 2 on -- Could not transmit data because sio_disableTx()
                          function is called
         -1:  No such port
         -2:  Time out
         -3:  Bad function call

Example (C language):

     int stat, port=1;
     if((stat = sio_Tx_hold(port)) == 1)
         printf("Tx disabled by CTS low\n")


Function 34  sio_getbaud()

Gets the serial port's baud rate.  The return value is the actual baud rate.
For example, return value 9600 means 9600 bps while 200 means 200 bps.

     Language        Syntax

     DOS C           sio_getbaud(int port)
     DOS PASCAL      sio_getbaud(port:integer):integer
     DOS QBASIC      SioGetBaud(port%, n%)
     DOS CLIPPER     sio_gbaud(port)
     DOS Assembly    __sio_getbaud
     Windows C       int WINAPI sio_getbaud(port)
     UNIX            ---

Argument:

     long port (dx) = Port number

Return:

     int n (ax)

     n >  0:  The actual baud rate
         -1:  No such port
         -3:  Bad function call

Example (C language):

     int, port=1; long baud;
     baud = sio_getbaud(port);



Function 35  sio_getmode()

Gets the serial port's mode setting.  Please refer to sio_ioctl() for the mode
setting.

     Language        Syntax

     DOS C           sio_getmode(int port)
     DOS PASCAL      sio_getmode(port:integer):integer
     DOS QBASIC      SioGetMode(port%, n%)
     DOS CLIPPER     sio_gmode(port)
     DOS Assembly    _ _sio_getmode
     Windows C       int WINAPI sio_getmode(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n >= 0:  Mode (see sio_ioctl() )
         -1:  No such port
         -3:  Bad function call

Example (C language):

     int stat, port=1;
     stat = sio_getmode(port);


Function 36  sio_getflow()

Gets the serial port's hardware and software flow control setting.  See the
sio_flowctrl() function.

     Language        Syntax

     DOS C           sio_getflow(int port)
     DOS PASCAL      sio_getflow(port:integer):integer
     DOS QBASIC      SioGetFlow(port%, n%)
     DOS CLIPPER     sio_gflow(port)
     DOS Assembly    _ _sio_getflow
     Windows         int WINAPI sio_getflow(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n >= 0:  Bit 0=CTS flow control
              Bit 1=RTS flow control
              Bit 2=Tx XON/XOFF flow control, XON=0x11, XOFF=0x13
              Bit 3=Rx XON/XOFF flow control, XON=0x11, XOFF=0x13
              (0=OFF; 1=ON)
         -1:  No such port
         -3:  Bad function call

Example (C language):

     int stat, port=1;
     stat = sio_getflow(port);
     switch(stat) {
         case 0:  printf("Port 1 flow control OFF\n"); break;
         case 1:  printf("Port 1 CTS flow control ON\n"); break;
         .
         .
         .
     }


Function 37  sio_brk_cnt()

Gets the counter value of received BREAK signal and then clear.

     Language        Syntax

     DOS C           sio_brk_cnt(int port)
     DOS PASCAL      sio_brk_cnt(port:integer):integer
     DOS QBASIC      SioBrkCnt(port%, n%)
     DOS CLIPPER     sio_brkcnt(port)
     DOS Assembly    __sio_brk_cnt
     Windows C       int WINAPI sio_brk_cnt(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n >= 0:  Break count
         -1:  No such port
         -3:  Bad function call

Example (C language):

     int stat, port=1;
     stat = sio_brk_cnt(port);
     if(stat >= 0)
         printf("%d counts break signal received\n", stat);
     else
         printf("Fail to access\n");


Function 38  sio_overflow()

Checks if driver's input buffer is overflow.

     Language        Syntax

     DOS C           sio_overflow(int port)
     DOS PASCAL      sio_overflow(port:integer):integer
     DOS QBASIC      SioOverflow(port%, n%)
     DOS CLIPPER     sio_oflow(port)
     DOS Assembly    _ _sio_overflow
     Windows C       int WINAPI sio_overflow(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n =  0:  No overflow
          1:  Received data overflow
         -1:  No such port
         -3:  Bad function

Example (C language):

     int stat, port=1;
     stat = sio_overflow(port);
     if(stat == 1)
         printf("Port#%d received data overflow\n", port);


Function 39 (N)  sio_data_status()

Check if any error happened when receiving data.

     Language        Syntax

     DOS C           sio_data_status(int port)
     DOS PASCAL      sio_data_status(port:integer) :integer
     DOS QBASIC      SioDataStatus(port%, n%)
     DOS CLIPPER     sio_dstatu(port)
     DOS Assembly    __sio_data_status
     Windows C       int WINAPI sio_data_status(port)
     UNIX C          ---

Argument:

     int port (dx) = Port number

Return:

     int n (ax)

     n >= 0:  Bit 0 on: parity error
              Bit 1 on: framing error
              Bit 2 on: overrun error
              Bit 3 on: overflow error
         -1:  No such port
         -3:  Bad function call

Example (C language):

     int port=1;
     if(sio_data_status(port) == 0)
         printf("No error occurs in port 1\n");

Function 40  sio_term_irq()

Sets an interrupt service rountine for the case when terminator character is
received. The service routine must read all the data in the input buffer when
the interrupt is issued.  When `terminator' is encountered, the system will be
interrupted and will call the interrupt service routine.  Once the interrupt
service is complete, the system will return to the point where it was
interrupted. (Note that some DOS functions, e.g. printf(), are not allowed to
be used in the interrupt service routine.)

     Language       Syntax

     DOS C           sio_term_irq(int port, interrupt (*func)(), char code)
     DOS PASCAL      ----
     DOS QBASIC      ----
     DOS CLIPPER     ----
     DOS Assembly    _ _sio_term_irq
     Windows C       int WINAPI sio_term_irq(port, far_p, terminator)
     UNIX            ---

Argument:

     int port (dx) = Port number
     cahr code (al) = Terminator code
     interrupt (*func)() (es:di) = Service function entry

     FARPROC far_p;
     int terminator;

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -3:  Bad function call

Example (C language):

     int stat, port=1; char code=13;
     void interrupt func (void);
     stat = sio_term_irq(port, func, code);

Example (Windows MSC):

     void WINAPI term_isr();
     far_p=MakeProcInstance(term_isr, hInst);
     sio_term_irq(port, far_p, 13);
     .
     .
     .
     void WINAPI term_isr()
     {
              /* interrupt service routine */
     }



Function 41  sio_cnt_irq()

Sets an interrupt service routine for the case when a certain amount of data
has been received. When there are `count' bytes of data received in the input
buffer, the system will be interrupted and will call the interrupt service
routine. Once the interrupt has been served, the system will return to the
point where it was interrupted. (Note that some DOS functions, e.g. printf(),
are not allowed to be used in the interrupt service routine.)

     Language        Syntax

     DOS C           sio_cnt_irq(int port, interrupt(*func)(), int count)
     DOS PASCAL      ----
     DOS QBASIC      ----
     DOS CLIPPER     ----
     DOS Assembly    _ _sio_cnt_irq
     Windows C       int WINAPI sio_cnt_irq(port, far_p, count)
     UNIX            ---

Argument:

     int port, count; interrupt (*func)();

     port (dx) =port number
     count (cx) =data count
     func(es:di) =service function entry

     FARPROC far_p;

Return:

     int n (ax)

     n =  0:  OK
         -1:  no such port
         -2:  Time out
         -3:  bad function call
         -5:  Port not open

Example (C language):

     int stat, port=1, count=255;
     void interrupt func (void);
     .
     .
     stat = sio_cnt_irq(port, func, count);
     .
     .
     void interrupt func()
     {
              /* intrrupt service routine */
     }

Example (Windows MSC):

     void WINAPI cnt_isr();
     far_p=MakeProcInstance(cnt_isr, hInst);
     sio_cnt_irq(port, far_p, count)
     .
     .
     .
     void WINAPI cnt_isr()
     {
              /* intrrupt service routine */
     }


Function 42  sio_modem_irq()

Sets an interrupt service routine for the case when the line status is changed.
When line status (CTS, DSR, CD, RI) changes, the system will be interrupted and
call the interrupt service routine.  After the interrupt has been served, the
system will return to the point where it was interrupted. (Note that some DOS
functions, e.g. printf(), are not allowed to be used in the interrupt service
routine.)

     Language        Syntax

     DOS C           sio_modem_irq(int port, interrupt (*func)())
     DOS PASCAL      ----
     DOS QBASIC      ----
     DOS CLIPPER     ----
     DOS Assembly    _ _sio_modem
     Windows C       int WINAPI sio_modem_irq(port, far_p)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     interrupt (*func)() (es:di) = Service function entry

     FARPROC far_p;

Return:

     int n (ax)

     n =  0:  OK
         -1:  no such port
         -2:  Time out
         -3:  bad function call
         -5:  Port not open

Example (C language):

     int stat, port=1;
     void interrupt func (void);
     .
     .
     stat = sio_modem_irq(port, func);
     .
     .
     void interrupt func()
     {
              /* intrrupt service routine */
     }

Example (Windows MSC)

     void WINAPI modem_isr();
     far_p=MakeProcInsatance(modem_isr, hInst);
     sio_modem_irq(port, far_p)
     .
     .
     .
     void WINAPI modem_isr()
     {
              /* intrrupt service routine */
     }



Function 43  sio_break_irq()

Sets an interrupt service routine for the case when a BREAK signal is
received. When a BREAK signal is encountered, the system will be interrupted
and will call interrupt service routine.  Once the interrupt service is
complete, the system will return to the point where it was interrupted. (Note
that some DOS functions, e.g. printf(), are not allowed to be used in the
interrupt service routine.)

     Language        Syntax

     DOS C           sio_break_irq(int port, interrupt (*func)())
     DOS PASCAL      ----
     DOS QBASIC      ----
     DOS CLIPPER     ----
     DOS Assembly    _ _sio_break_irq
     Windows C       int WINAPI sio_break_irq(port, far_p)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     interrupt (*func)() (es:di) = Service function entry

     FARPROC far_p;

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Time out
         -3:  Bad function call
         -5:  Port not open

Example (C language):

     int stat, port=1;
     void interrupt func (void);
     .
     .
     stat = sio_break_irq(port, func);
     .
     .
     void interrupt func()
     {
              /* interrupt service routine */
     }

Example (Windows MSC):

     void WINAPI break_isr();
     far_p=MakeProcInstance(break_isr, hInst);
     sio_break_irq(port, far_p);
     .
     .
     .
     void WINAPI break_isr()
     {
              /* intrrupt service routine */
     }

Function 44  sio_disableIRQ()

Disable the 'interrupt-driven' operation. Temporarily disable the
'interrupt-driven' operation which is set by sio_term_irq(), sio_break_irq(),
sio_modem_irq() or sio_cnt_irq(). That is, the interrupt will be ignored after
the sio_disableIRQ() function issued.

     Language        Syntax

     DOS C           sio_disableIRQ(int port, int intrr_type)
     DOS PASCAL      sio_disableIRQ(port:integer; intrr_type:integer):integer
     DOS QBASIC      ---
     DOS CLIPPER     ---
     DOS Assembly    __sio_disableIRQ
     Windows C       int WINAPI sio_disableIRQ(port, intrr_type)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     int intrr_type (ax) = 1  to disable sio_term_irq()
                           2  to disable sio_break_irq()
                           4  to disable sio_modem_irq()
                           8  to disable sio_cnt_irq()

Return:

     int n (ax)

     n =  0:  Disable OK
         -1:  Fail to disable
         -2:  Time out
         -5:  Port not open

Example (C language):

     int port=1, intrr_type = 1;

     if(sio_disableIRQ(port, intrr_type) == 0)
         printf("sio_term_irq() is disabled!\n");


Function 45  sio_enableIRQ()

Enable the 'interrupt-driven' operation. To enable the 'interrupt-driven'
operation which is temporarily disabled by sio_disableIRQ() function.

     Language        Syntax

     DOS C           sio_enableIRQ(int port, int intrr_type)
     DOS PASCAL      sio_enableIRQ(port:integer; intrr_type:integer):integer
     DOS QBASIC      ---
     DOS CLIPPER     ---
     DOS Assembly    __sio_enableIRQ
     Windows C       int WINAPI sio_enableIRQ(port, intrr_type)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     int intrr_type (ax) = 1  to enable sio_term_irq()
                           2  to enable sio_break_irq()
                           4  to enable sio_modem_irq()
                           8  to enable sio_cnt_irq()

Return:

     int n (ax)

     n =  0:  Disable OK
         -1:  Fail to disable
         -2:  Time out
         -5:  Port not open

Example (C language):

     int port=1, intrr_type = 1;

     if(sio_enableIRQ(port, intrr_type) == 0)
         printf("sio_term_irq() is enabled!\n");


Function 46  sio_getports()

Gets the number of ports and stores "port no." in a specified array. The "port
no.", which is set in the setup program, is actually an identification for each
port.

     Language        Syntax

     DOS C           sio_getports(int *p_no_array, int array_size)
     DOS PASCAL      sio_getports(@p_no_array: point;
                                  array_aise:integer):integer
     DOS QBASIC      ----
     DOS CLIPPER     ----
     DOS Assembly    _ _sio_getports
     Windows C       int WINAPI sio_getports(int far *p_no_array, array_size)
     UNIX            ---

Argument:

     int *p_no_array (ds:si) = Port number array table
     int array_size (cx) = Array table size (must be large enough to hold all
                           port numbers)

Return:

     int n (ax), *p_no_array

     n >= 0:  Total number of ports
         -1:  No driver found

Example (C language):

     #define ArraySize 1024;
     int stat, p_no_array[ArraySize];
     if((stat = sio_getports(p_no_array, ArraySize)) <=0)
         printf("No port found!\n");
     else
         printf("%d ports found.\n", stat);



Function 47  sio_break()

Sends out a break signal.

     Language        Syntax

     DOS C           sio_break(int port, int time)
     DOS PASCAL      sio_break(port, time:integer):integer
     DOS QBASIC      SioBreak(port%, time%, n%)
     DOS CLIPPER     sio_break(port, time)
     DOS Assembly    __sio_break
     Windows C       int WINAPI sio_break(port, time)
     UNIX C          sio_break(int port, int time)

Argument:

     int port (dx) = Port number
     int time (cx) = Break time in tics (1/18.2 second)

Return:

     int n (ax)

     n =  0:  OK
         -1:  No such port
         -2:  Time out
         -3:  Bad function call
         -4:  Xmit disable
         -5:  Port is not opened

Example (C language):

     int port=1, time=2;

     if(sio_break(port, time) ==0)
         printf("Send 0.11 second break signal from port 1\n");
     else
         printf("Unable to send break signal from port 1\n");


Function 48  sio_bank()

Gets the memory mapping address segment to which the MOXA board is mapped.

     Language        Syntax

     DOS C           sio_bank(int drvname, int boardno)
     DOS PASCAL      sio_bank(drvname:integer; boardno:integer):interger
     DOS QBASIC      SioBank(drvname%, boardno%, n%)
     DOS CLIPPER     sio_bank(drvname, boardno)
     DOS Assembly    __sio_bank
     Windows C       int WINAPI sio_bank(drvname, boardno)
     UNIX C          ---

Argument:

     int drvname (dx) = 0x320 (for MOXA-C218 and C320)
     int boardno (ax) = Board number (1 - 4)

Return:

     int n (ax)

     n >  0:  Dual-port memory mapped segment address (0xC800, ...)
         -1:  If selected board not found
         -3:  Bad function

Example (C language):

     int stat, drvname=0x320, boardno=1;
     stat = sio_bank(drvname, boardno);


Function 49  sio_timeout()

Sets the sio_linput_t() and sio_putb_t() time-out time in ticks.

     Language        Syntax

     DOS C           sio_timeout(time_tic)
     DOS PASCAL      sio_timeout(time_tic:integer):integer
     DOS QBASIC      SioTimeout(time_tic%)
     DOS CLIPPER     sio_timout(time_tic)
     DOS Assembly    _ _sio_timeout
     Windows C       int WINAPI sio_timeout(time_tic)
     UNIX C          ---

Argument:

     int time_tic (ax) = Time out tic counts (1 tic=1/18.2 sec.)

Return:

     None

Example (C language):

     int tic=2;
     sio_timeout(tic);


Function 50  sio_loopback()

Serial port internal loopback transmit/receive test. The port will be closed
automatically after the loopback function is completed. The port must be
re-opened before further operation. This function is not applicable for C360
and C320 Turbo. It will always return 0 for C320 Turbo. For C360, sio_ACdiag()
is recommend to be used, instead, to test the port condition.

     Language        Syntax

     DOS C           sio_loopback(int port, char *buf, int len)
     DOS PASCAL      sio_loopback(port:integer; buf:string):integer
     DOS QBASIC      SioLoopBack(port%, buf$, n%)
     DOS CLIPPER     sio_loopbk(port, buf)
     DOS Assembly    __sio_loopback
     Windows C       int WINAPI sio_loopback(port, LPSTR buf, len)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     char *buf (ds:si) = Test character string buffer pointer
     int len (cx) = Buffer length > 0

Return:

     int n (ax)

     n =  0:  OK
       >  0:  Error
         -1:  No such port
         -3:  Bad function call

Example (C language):

     char *buf= "This is a test string";
     int port=0;

     if(sio_loopback(port, buf, 19) == 0)
         printf("Port #%d sio_loopback test O.K.\n", port);
     else
         printf("Port #%d sio_loopback fail\n", port);


Function 51 sio_view()

View the received data. This function is similiar to sio_read() except that it
only 'view' the content of the input buffer. That is, this functon does not
extract the data out from the input buffer. The data will still remain in the
input buffer after sio_view().

     Language        Syntax

     DOS C           sio_view(int port, char *ibuf, int len)
     DOS PASCAL      sio_view(port:integer; var len:integer):string
     DOS QBASIC      SioView(port%, buf$, n%)
     DOS CLIPPER     sio_view(port, buf)
     DOS Assembly    __sio_view
     Windows C       int WINAPI sio_view(int port, LPSTR buf, int len)
     UNIX C          ---

Argument:

     int port (dx) = Port number
     char *buf (es:di) = Receive buffer pointer with sufficient space
     int len (cx) = Buffer length

Return:

     int n (ax)

     n >  0:  Length of data received and viewed
       =  0:  No data received
         -1:  No such port
         -5:  Port is not opened

Example (C language):

     #define LEN 80; char buf [LEN];
     int stat, port;
     if((stat = sio_view(port, buf, LEN)) > 0)
         printf("%d characters viewed\n", stat);


Function 52 sio_linked()

Check if the C320 CPU Module is in link state or not.

     Language        Syntax

     DOS C           sio_linked(int drvname, int boardno)
     DOS PASCAL      sio_linked(drvname:integer; boardno:integer):integer
     DOS QBASIC      SioLinked(drvname%, boardno%, n%)
     DOS CLIPPER     sio_linked(drvname, boardno)
     DOS Assembly    __sio_linked
     Windows C       int WINAPI sio_linked(drvname, boardno)
     UNIX C          ---

Argument:

     int drvname (dx) = 0x320 for C320
     int boardno (ax) = Board number (1 - 4)

Return:

     int n (ax)

     n =  0:  CPU Module is in normal link state
          1:  CPU Module is not linked with control board, e.g. the power of
              the CPU Module is off or the cable between control board and CPU
              Module is disconnected
          2:  CPU Module has once been reset,the application must re-initialize
              the C320 again. Otherwise, the port configuration may not be
              present as what you expect.
         -3:  Bad function

Example (C language):

     int drvname=0x320, boardno = 1;

     if(sio_linked(drvname, boardno) == 0)
         printf("CPU Module of C320 is linked\n");


Function 53 sio_getACs()

Get C360 Connectrators serial numbers

     Language        Syntax

     DOS C           sio_getACs(int drvname, int boardno,
                     int *serial_no_array, int array_size)
     DOS PASCAL      sio_getACs(drvname:integer; boardno:integer;
                     @serial_no_array:point; array_size:integer):integer
     DOS QBASIC      ---
     DOS CLIPPER     ---
     DOS Assembly    _ _sio_getACs
     Windows C       ---
     UNIX C          ---

Argument:

     int drvname (dx) = 0x360 for C360
     int boardno (ax) = Board number (1 - 4)
     int *serial_no_array (ds:si) = Serial number array buffer
     int array_size (cx) = Array size

Return:

     int n (ax)

     n >= 0:  Total connectrators
         -1:  No driver found
         -3:  Bad function

Example (C language):

     int drvname=0x360, boardno = 1;
     int serial_no_array[16], array_size = 16;
     if((stat = sio_getACs(drvname, boardno, serial_no_array, array_size))==2)
         printf("There are %d Async Concentrators\n", stat);


Function 54 sio_ACstate()

Get C360 Async Connectrator's status

     Language        Syntax

     DOS C           sio_ACstate(int drvname, int serialno)
     DOS PASCAL      sio_ACstate(drvname:integer; serialno:integer):integer
     DOS QBASIC      SioACState(drvname%, serialno%, n%)
     DOS CLIPPER     sio_ACSt(drvname, serialno)
     DOS Assembly    _ _sio_ACstate
     Windows C       ---
     UNIX C          ---

Argument:

     int drvname (dx) = 0x360 for C360
     int serialno (ax) = Concentrator's serial number

Return:

     long int n (ax)

     n >= 0:  bit0    Connectrator with wrong version firmware
              bit1    Connectrator found
              bit2    Connectrator current is down
              bit3    Connectrator had down after last read status
         -1:  Bad driver name
         -3:  Bad function
         -4:  Bad connectrator's serial number

Example (C language):

     int drvname=0x360, serialno= 100;

     if(sio_ACstate(drvname, serialno) == 2)
         printf("Async Concentrator 100 is O.K.\n");



Function 55 sio_ACdiag()

C360 concentrator's port diagnostics.

     Language        Syntax

     DOS C           sio_ACdiag(int drvname, int serialno)
     DOS PASCAL      sio_ACdiag(drvname:integer; serialno:integer):longint
     DOS QBASIC      SioACDiag(drvname%, serialno%, n%)
     DOS CLIPPER     sio_ACDg(drvname, serialno)
     DOS Assembly    _ _sio_ACdiag
     Windows C       ---
     UNIX C          ---

Argument:

     int drvname (dx) = 0x360 for C360
     int serialno (ax) = Concentrator's serial number

Return:

     long int n (dx:ax)

     n =  0:  OK
       >  0:  Port error
              b15 b14 b13 ... b1 b0 (port status)
              x   x   x  ...  x  x  <-- 0: O.K.  1: Fail
         -1:  Bad driver name
         -3:  Bad function
         -4:  Bad connectrator's serial number

Example (C language):

     int drvname=0x360, serialno= 100;

     if(sio_ACdiag(drvname, serialno) == 0)
         printf("Ports of Async Concentrator 100 are all O.K.\n");



Function 100 (N)  sio_McAnswer()
*******  WARNING !!!!!!*********************************
* For DOS programmer:                                  *
* If connection speed is higher than 32767(bps),       *
* please use sio_McAnwser_ex(), or you will fail       *
* to get the correct return value.                     *
*******  WARNING !!!!!!*********************************
This function answers the caller manually by sending "ATA" command to the
modem and then wait for carrier. After the command is invoked, the application
program can use sio_McIsConnect_ex() to see if a "CONNECT" message comes in
and take appropriate action.


     Language        Syntax

     DOS C           sio_McAnswer(port)
     Windows C       int WINAPI sio_McAnswer(port)

Argument:

     int port = Port number

Return:

     int n

     n   >0:  Connected
         -1:  No such port or port not opened
         -2:  Timeout
         -3:  Connection fail, no carrier
         -4:  Connection fail, no dialtone
         -5:  Connection fail, busy
         -6:  Connection fail, no answer

Example (C language):

     int stat, port=1;
     stat = sio_McAnswer(port);



Function 101(N)  sio_McAutoAnswer()

Automatically go off hook and answer the caller after a number of rings.


     Language        Syntax

     DOS C           sio_McAutoAnswer(port, rings)
     Windows C       int WINAPI sio_McAutoAnswer(port, rings);

Argument:

     int port = Port number
     int rings = The number of rings before

Return:

     int n

     n =  0:  OK
         -1:  No such port or port not opened
         -2:  AT command timeout

Example (C language):

     int stat, port=1, rings = 3;
     stat = sio_McAutoAnswer(port, rings);  /* answer caller after 3 rings */



Function 102(N)  sio_McCommandMode()

Tell the modem to go off line. This function tells the modem to go off line
by sending "+++" string.

     Language        Syntax

     DOS C           sio_McCommandMode(port)
     Windows C       int WINAPI sio_McCommandMode(port)

Argument:

     int port = Port number

Return:

     int n

     n =  0:  OK
         -1:  No such port or port not opened
         -2:  AT command timeout

Example (C language):

     int stat, port=1;
     stat = sio_McCommandMode(port);



Function 103(N)  sio_McDataMode()
*******  WARNING !!!!!!**********************************
* For DOS programmer:                                   *
* If connection speed is higher than 32767(bps),        *
* please use sio_McDataMode_ex(), or you will fail      *
* to get the correct return value.                      *
*******  WARNING !!!!!!**********************************
Tell the modem to go on line. This function tells the modem to go on line
by sending "ATO" string.

     Language        Syntax

     DOS C           sio_McDataMode(port)
     Windows C       int WINAPI sio_McDataMode(port)

Argument:

     int port = Port number

Return:

     int n

     n >  0:  OK
       = -1:  No such port or port not opened
         -2:  AT command timeout
         -3:  Connection fail, no carrier
         -4:  Connection fail, no dialtone
         -5:  Connection fail, busy
         -6:  Connection fail, no answer

Example (C language):

     int stat, port=1;
     stat = sio_McDataMode(port);



Function 104(N)  sio_McDial()

Dial a phone number and wait for carrier. By default, the command will be sent
in the format "ATDTnnnnnnn\r", where nnnnnnn is the phone number.

If pulse dialing is required, add a 'P' in front of the phone number. The
command will be sent in "ATDPnnnnnnn\r" format in this case.


     Language        Syntax

     DOS C           sio_McDial(port, phone_number)
     Windows C       int WINAPI sio_McDial(port, phone_number)

Argument:

     int port = Port number
     char *phone_number = Phone number

Return:

     int n

     n =  0:  OK
         -1:  No such port or port not opened

Example (C language):

     int stat, port=1;
     stat = sio_McDial(port, "2134567");



Function 105(N)  sio_McGetSRegister()

Read the value of one of the modem S registers. The format of the command will
be "ATSnn?\r". This will cause the modem to return a numeric value for the
status register, followed by the OK message.


     Language        Syntax

     DOS C           sio_McGetSRegister(port, sreg)
     Windows C       int WINAPI sio_McGetSRegister(port, sreg)

Argument:

     int port = Port number
     int sreg = The modem S register to read

Return:

     int n

     n >= 0:  The S register's value
       = -1:  No such port or port not opened
         -2:  AT command timeout

Example (C language):

     int stat, port=1;
     stat = sio_McGetSRegister(port, 7); /* read S register #7 */


Function 106(N)  sio_McHangUp()

Hang up the line. This function will hang up the line by sending "ATH0"
command.

     Language        Syntax

     DOS C           sio_McHangUp(port)
     Windows C       int WINAPI sio_McHangUp(port)

Argument:

     int port = Port number

Return:

     int n

     n =  0:  OK
         -1:  No such port or port not opened
         -2:  AT command timeout

Example (C language):

     int stat, port=1;
     stat = sio_McHangUp(port);



Function 107(N)  sio_McIsConnect()
*******  WARNING !!!!!!*********************************
* For DOS programmer:                                  *
* If you connection speed is higher than 32767(bps),   *
* please use sio_McIsConnect_ex(), or you will fail    *
* to get the correct return value.                     *
*******  WARNING !!!!!!*********************************
Check if the line is connected. This routine will check if there is a "CONNECT"
message received. If so, the "CONNECT xxxx" message, "CONNECT 19200" for
example, will be stored into the user's buffer.


     Language        Syntax

     DOS C           sio_McIsConnect(port, return_msg)
     Windows C       int WINAPI sio_McIsConnect(port, return_msg)

Argument:

     int port = Port number
     char *return_msg = The buffer to hold the return message

Return:

     int n

     n >  0:  Connected
       =  0:  Not connected yet
         -1:  No such port or port not opened
         -3:  Connection fail, no carrier
         -4:  Connection fail, no dialtone
         -5:  Connection fail, busy
         -6:  Connection fail, no answer

Example (C language):

     int stat, port=1; char return_msg[100];
     stat = sio_McIsConnect(port, return_msg);



Function 108(N)  sio_McOffHook()

Tell the modem to go off hook. This function will send "ATH1" command to
the modem.

     Language        Syntax

     DOS C           sio_McOffHook(port)
     Windows C       int WINAPI sio_McOffHook(port)

Argument:

     int port = Port number

Return:

     int n

     n =  0:  OK
         -1:  No such port or port not opened
         -2:  AT command timeout

Example (C language):

     int stat, port=1;
     stat = sio_McOffHook(port);



Function 109(N)  sio_McReset()

Performs a reset of the modem by sending the "ATZ" command; "ATV1" for deatil
result code. This function also sets the escape code (S register #2) to '+'
and escape code guard time (S register #12) to 1 second.

     Language        Syntax

     DOS C           sio_McReset(port)
     Windows C       int WINAPI sio_McReset(port)

Argument:

     int port = Port number

Return:

     int n

     n =  0:  OK
         -1:  No such port or port not opened
         -2:  AT command timeout

Example (C language):

     int stat, port=1;
     stat = sio_McReset(port);



Function 110(N)  sio_McRings()

Read how many rings has come in.

     Language        Syntax

     DOS C           sio_McRings(port)
     Windows C       int WINAPI sio_McRings(port)

Argument:

     int port = Port number

Return:

     int n

     n >= 0:  The number of rings has come in
         -1:  No such port or port not opened
         -2:  AT command timeout

Example (C language):

     int stat, port=1;
     stat = sio_McRings(port);



Function 111(N)  sio_McSetSRegister()

Send a register set command to the modem.

     Language        Syntax

     DOS C           sio_McSetSRegister(port, sreg, value)
     Windows C       int WINAPI sio_McSetSRegister(port, sreg, value)

Argument:

     int port = Port number
     int sreg = The S register
     int value = The new value to be assigned to the register

Return:

     int n

     n =  0:  OK
         -1:  No such port or port not opened
         -2:  AT command timeout

Example (C language):

     int stat, port=1;
     stat = sio_McSetSRegister(port, 0, 3);  /* set S register #0 to 3 */


Function 112(N)  sio_McSetString()

Set the to-be-waited string echoed from modem while connected.

     Language        Syntax

     DOS C           sio_McSetString(int str_index, char *string)
     Windows C       int WINAPI sio_McSetString(str_index, LPSTR string)

Argument:

     int str_index = String index
                     0: indicates the connect string pointer
                        default value "CONNECT"
                     1: indicates the no carrier string pointer
                        default value "NO CARRIER"
                     2: indicates the no dialtone string pointer
                        default value "NO DIALTONE"
                     3: indicates the no answer string pointer
                        default value "NO ANSWER"
                     4: indicates the busy string pointer
                        default value "BUSY"
     char *string = The longest length of string is 20 bytes, and the string
                    comparison is case-sensitivity.

Return:

     int n

     n =  0:  OK
         -1:  Error string index number
         -2:  String length too long

Example (C language):

     int stat;
     stat = sio_McSetString(0, "Connect");



Function 113(N)  sio_McSetTimeout()

Set the time-out value for sio_McAnswer() function to check if the line is
connected.

     Language        Syntax

     DOS C           sio_McSetTimeout(seconds)
     Windows C       int WINAPI sio_McSetTimeout(seconds)

Argument:

     int seconds = The time out value in second for waiting "CONNECT"
                   Default value is 120 seconds.

Return:

     int n

     n =  0:  OK

Example (C language):

     int stat;
     stat = sio_McSetTimeout(100);



Function 114(N)  sio_McWaitConnect()

Check if the line is connected. This routine will check if there is a "CONNECT"
message received. If so, the "CONNECT xxxx" message, "CONNECT 19200" for
example, will be stored into user's buffer. Otherwise it will wait for timout
time.

     Language        Syntax

     DOS C           sio_McWaitConnect(int port, int timeout, char *return_msg)
     Windows C       int WINAPI sio_McWaitConnect(int port, int timeout,
                                                  LPSTR return_msg)

Argument:

     int port = Port number
     int timeout = Wait time (seconds) before return
     char *return_msg = The buffer to hold the return message

Return:

     int n

     n >  0:  OK
       = -1:  No such port or port not opened
         -2:  Timeout
         -3:  Connection fail, no carrier
         -4:  Connection fail, no dialtone
         -5:  Connection fail, busy
         -6:  Connection fail, no answer

Example (C language):

     int stat, port=1, timeout=3; char return_msg[100];
     stat = sio_McWaitConnect(port, timeout, return_msg);



Function 115 (N)  sio_McAnswer_ex()

This function answers the caller manually by sending "ATA" command to the
modem and then wait for carrier. After the command is invoked, the application
program can use sio_McIsConnect() to see if a "CONNECT" message comes in and
take appropriate action.

     Language        Syntax

     DOS C           sio_McAnswer_ex(port)

Argument:

     int port = Port number

Return:

     long n

     n   >0:  Connected
         -1:  No such port or port not opened
         -2:  Timeout
         -3:  Connection fail, no carrier
         -4:  Connection fail, no dialtone
         -5:  Connection fail, busy
         -6:  Connection fail, no answer

Example (C language):

     int  port=1;
     long stat;
     stat = sio_McAnswer(port);



Function 116(N)  sio_McDataMode_ex()

Tell the modem to go on line. This function tells the modem to go on line
by sending "ATO" string.

     Language        Syntax

     DOS C           sio_McDataMode_ex(port)

Argument:

     int port = Port number

Return:

     long n

     n >  0:  OK
       = -1:  No such port or port not opened
         -2:  AT command timeout
         -3:  Connection fail, no carrier
         -4:  Connection fail, no dialtone
         -5:  Connection fail, busy
         -6:  Connection fail, no answer

Example (C language):

     int  port=1;
     long stat;
     stat = sio_McDataMode_ex(port);




Function 117(N)  sio_McIsConnect_ex()

Check if the line is connected. This routine will check if there is a "CONNECT"
message received. If so, the "CONNECT xxxx" message, "CONNECT 19200" for
example, will be stored into the user's buffer.


     Language        Syntax

     DOS C           sio_McIsConnect_ex(port, return_msg)

Argument:

     int port = Port number
     char *return_msg = The buffer to hold the return message

Return:

     long n

     n >  0:  Connected
       =  0:  Not connected yet
         -1:  No such port or port not opened
         -3:  Connection fail, no carrier
         -4:  Connection fail, no dialtone
         -5:  Connection fail, busy
         -6:  Connection fail, no answer

Example (C language):

     int  port=1; char return_msg[100];
     long stat;
     stat = sio_McIsConnect_ex(port, return_msg);



Function 200(N)  sio_FtASCIIRx()

Receive a file from the remote end using ASCII file capture. This means there
is no protocol being used to receive the file.

     Language        Syntax

     DOS C           sio_FtASCIIRx(int port,
                               char *file_name,
                               int (*callback)(long, int, char far *, long),
                               int key,
                               int seconds);
    Windows C        int WINAPI sio_FtASCIIRx(int port, LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key,
                               int seconds);

Argument:

     int port = Port number
     char *file_name = The name of the file where the download will be stored
     int key = Abort key defined by user
     int seconds = Timeout time (in seconds)
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the download

            Argument:
              long rcvlen = Data length currently received
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = The length of the file being received if > 0

            Return:
              >= 0:  If wish to continue receiving
              <  0:  If wish to stop receiving (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files

Example (C language):

     int stat, port=1, seconds=300, key=18; char fname[30];
     int callback(rcvlen, len, buffer, flen)
     {
      long rcvlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtASCIIRx(port, fname, callback, key, seconds);



Function 201(N)  sio_FtASCIITx()

Transmit an ASCII file to the remote end. This means there is no protocol
being used to transmit the file.

     Language        Syntax

     DOS C           sio_FtASCIITx(int port,
                               char *file_name,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtASCIITx(int port,
                               LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     char *file_name = The name of the file that will be sent
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the upload

            Argument:
              long xmitlen = Data length currently sent
              int len = Tx data length in the buffer
              char far *buffer = Tx data buffer pointer
              long flen = current xmit file length if > 0

            Return:
              >= 0:  Continue to send
              <  0:  Stop sending (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files

Example (C language):

     int stat, port=1, key=18; char fname;
     int callback(xmitlen, len, buffer, flen)
     {
      long xmitlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtASCIITx(port, "MY_FILE", call_func, key);



Function 202(N)  sio_FtKermitRx()

Receive files using Kermit protocol.

     Language        Syntax

     DOS C           sio_FtKermitRx(int port,
                               char ** ffname,
                               int fno,
                               int (*callback)(long, int, char far *, long),
                               int key);
     Windows C       int WINAPI sio_FtKermitRx(int port,
                               LPSTR far * ffname,
                               int fno,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     cahr **ffname = Pointer to a array that hold received file names
     int fno = max. number of files can be received
     int key = abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the download

            Argument:
              long rcvlen = Data length currently received
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = The length of the file being received if > 0

            Return:
              >= 0:  Continue to receive
              <  0:  Stop receiving (user abort)

Return:

     int n

     n >  0:  Number of files received
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files
         -7:  Protocol checking error abort

Example (C language):

     int stat, port=1, key=18, fno=2; char fname1[80], fname2[80];
     char *ffname[2]={fname1, fname2};
     int callback(rcvlen, len, buffer, flen)
     {
      long rcvlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtKermitRx(port, ffname, fno, callback, key);



Function 203(N)  sio_FtKermitTx()

Transmit files using Kermit protocol.

     Language        Syntax

     DOS C           sio_FtKermitTx(int port,
                               char *file_name,
                               int (*callback)(long,int,char far *,long),
                               int key);
     WIndows C       int WINAPI sio_FtKermitTx(int port,
                               LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     char *file_name = The name of the file that will be sent
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the upload

            Argument:
              long xmitlen = Data length currently sent
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = current xmit file length if > 0

            Return:
              >= 0:  Continue to send
              <  0:  Stop sending (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files


Example (C language):

     int stat, port=1, key=18; char fname;
     int callback(xmitlen, len, buffer, flen)
     {
      long xmitlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtKermitTx(port, "MY_FILE", call_func, key);



Function 204(N)  sio_FtXmodem1KCRCRx()

Receive a file using the XMODEM, 1K block size, 16 bit CRC.

     Language        Syntax

     DOS C           sio_FtXmodem1KCRCRx(int port,
                               char *file_name,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtXmodem1KCRCRx(int port,
                               LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     cahr *file_name = The name of the file where the download will be stored
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the download

            Argument:
              long rcvlen = data length currently received
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = The length of the file being received if > 0

            Return:
              >= 0:  Continue to receive
              <  0:  Stop receiving (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files
         -7:  Protocol checking error abort

Example (C language):

     int stat, port=1, key=18; char fname[30];
     int callback(rcvlen, len, buffer, flen)
     {
      long rcvlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtXmodem1KCRCRx(port, fname, callback, key);



Function 205(N)  sio_FtXmodem1KCRCTx()

Transmit a file using XMODEM, 1K block size, 16 bit CRC.

     Language        Syntax

     DOS C           sio_FtXmodem1KCRCTx(int port,
                               char *file_name,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtXmodem1KCRCTx(int port,
                               LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     char *file_name = The name of the file that will be sent
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the upload

            Argument:
              long xmitlen = Data length currently sent
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = Current xmit file length if > 0

            Return:
              >= 0:  Continue to send
              <  0:  Stop sending (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files

Example (C language):

     int stat, port=1, key=18; char fname;
     int callback(xmitlen, len, buffer, flen)
     {
      long xmitlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtXmodem1KCRCTx(port, "MY_FILE", call_func, key);



Function 206(N)  sio_FtXmodemCheckSumRx()

Receive a file using standard XMODEM and additive checksum calculation.

     Language        Syntax

     DOS C           sio_FtXmodemCheckSumRx(int port,
                               char *file_name,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtXmodemCheckSumRx(int port,
                               LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

 Argument:

     int port = Port number
     char *file_name = The name of the file where the download will be stored
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the download

            Argument:
              long rcvlen = Data length currently received
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = The length of the file being received if > 0

            Return:
              >= 0:  Continue to receive
              <  0:  Stop receiving (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files
         -7:  Protocol checking error abort

Example (C language):


     int stat, port=1, key=18; char fname[30];
     int callback(rcvlen, len, buffer, flen)
     {
      long rcvlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtXmodemCheckSumRx(port, fname, callback, key);



Function 207(N)  sio_FtXmodemCheckSumTx()

Transmit a file using standard XMODEM and additive checksum.

     Language        Syntax

     DOS C           sio_FtXmodemCheckSumTx(int port,
                               char *file_name,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtXmodemCheckSumTx(int port,
                               LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     char *file_name = The name of the file that will be sent
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the upload

            Argument:
              long xmitlen = Data length currently sent
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = Current xmit file length if > 0

            Return:
              >= 0:  Continue to send
              <  0:  Stop sending (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files

Example (C language):

     int stat, port=1, key=18; char fname;
     int callback(xmitlen, len, buffer, flen)
     {
      long xmitlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtXmodemCheckSumTx(port, "MY_FILE", call_func, key);



Function 208(N)  sio_FtXmodemCRCRx()

Receive a file using standard XMODEM, 16 bit CRC.

     Language        Syntax

     DOS C           sio_FtXmodemCRCRx(int port,
                               char *file_name,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtXmodemCRCRx(int port,
                               LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     char *file_name = The name of the file where the download will be stored
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the download

            Argument:
              long rcvlen = Data length currently receive
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = The length of the file being received if > 0

            Return:
              >= 0:  Continue to receive
              <  0:  Stop receiving (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files
         -7:  Protocol checking error abort

Example (C language):

     int stat, port=1, key=18; char fname[30];
     int callback(rcvlen, len, buffer, flen)
     {
      long rcvlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtXmodemCRCRx(port, fname, callback, key);


Function 209(N)  sio_FtXmodemCRCTx()

Transmit a file using standard XMODEM, 16 bit CRC.

     Language        Syntax

     DOS C           sio_FtXmodemCRCTx(int port,
                               char *file_name,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtXmodemCRCTx(int port,
                               LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     char *file_name = The name of the file that will be sent
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the upload

            Argument:
              long xmitlen = Data length currently sent
              int len = Rx data length in the buffer
              char far *buffer;/*  Rx data buffer pointer
              long flen = Current xmit file length if > 0

            Return:
              >= 0:  Continue to send
              <  0:  Stop sending (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files

Example (C language):

     int stat, port=1, key=18; char fname;
     int callback(xmitlen, len, buffer, flen)
     {
      long xmitlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtXmodemCRCTx(port, "MY_FILE", call_func, key);



Function 210(N)  sio_FtYmodemRx()

Receive files using the YMODEM protocol.

     Language        Syntax

     DOS C           sio_FtYmodemRx(int port,
                               char ** ffname,
                               int fno,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtYmodemRx(int port,
                               LPSTR far *ffname,
                               int fno,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     char **ffname = Pointer to a array that hold received file names
     int fno = Max. number of files can be received
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the download

             Argument:
               long rcvlen = Data length currently received
               int len = Rx data length in the buffer
               char far *buffer = Rx data buffer pointer
               long flen = The length of the file being received if > 0

             Return:
               >= 0: Continue to receive
               <  0: Stop receiving (user abort)

Return:

     int n

     n >  0:  Number of files received
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files
         -6:  Ymodem CAN signal abort
         -7:  Protocol checking error abort

Example (C language):

     int stat, port=1, key=18, fno=2; char fname1[80], fname2[80];
     char *ffname[2]={fname1, fname2};
     int callback(rcvlen, len, buffer, flen)
     {
      long rcvlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtYmodemRx(port, ffname, fno, callback, key);



Function 211(N)  sio_FtYmodemTx()

Transmit a file using the YMODEM protocol.

     Language        Syntax

     DOS C           sio_FtYmodemTx(int port,
                               char *file_name,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtYmodemTx(int port,
                               LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     char *file_name = The name of the file that will be sent
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the upload

            Argument:
              long xmitlen = data length currently sent
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = Current xmit file length if > 0

            Return:
              >= 0:  Continue to send
              <  0:  Stop sending (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files
         -6:  Ymodem CAN signal abort
         -7:  Protocol checking error abort

Example (C language):

     int stat, port=1, key=18; char fname;
     int callback(xmitlen, len, buffer, flen)
     {
      long xmitlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtYmodemTx(port, "MY_FILE", call_func, key);



Function 212(N)  sio_FtZmodemRx()

Receive files using the ZMODEM protocol.

     Language        Syntax

     DOS C           sio_FtZmodemRx(int port,
                               char ** ffname,
                               int fno,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtYmodemRx(int port,
                               LPSTR far *ffname,
                               int fno,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int key);

Argument:

     int port = Port number
     char **ffname = Pointer to a array that hold received file names
     int fno = Max. number of files can be received
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the download

            Argument:
              long rcvlen = Data length currently received
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = the length of the file being received if > 0

            Return:
              >= 0:  Continue to receive
              <  0:  Stop receiving (user abort)

Return:

     int n

     n >  0:  Number of files received
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files
         -7:  Protocol checking error abort
         -8:  Zmodem remote skip this send file
         -9:  Receive buffer size must be large than 1K bytes

Example (C language):

     int stat, port=1, key=18, fno=2; char fname1[80], fname2[80];
     char *ffname[2]={fname1, fname2};
     int callback(rcvlen, len, buffer, flen)
     {
      long rcvlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtZmodemRx(port, ffname, fno, callback, key);


Function 213(N)  sio_FtZmodemTx()

Transmit a file using the ZMODEM protocol.

     Language        Syntax

     DOS C           sio_FtZmodemTx(int port,
                               char *file_name,
                               int (*callback)(long,int,char far *,long),
                               int key);
     Windows C       int WINAPI sio_FtZmodemTx(int port,
                               LPSTR file_name,
                               int (CALLBACK _export *)(long, int, LPSTR, long),
                               int);

Argument:

     int port = Port number
     char *file_name = The name of the file that will be sent
     int key = Abort key defined by user
     int callback() = User-supplied message routine which keeps the user
                      updated on the progress of the upload

            Argument:
              long xmitlen = Data length currently sent
              int len = Rx data length in the buffer
              char far *buffer = Rx data buffer pointer
              long flen = Current xmit file length

            Return:
              >= 0:  Continue to send
              <  0:  Stop sending (user abort)

Return:

     int n

     n >  0:  Number of files received
       =  0:  Send OK
         -1:  No such port
         -2:  Protocol timeout
         -3:  User key abort
         -4:  Function return abort
         -5:  Can not open files
         -7:  Protocol checking error abort
         -8:  Zmodem remote skip this send file

Example (C language):

     int stat, port=1, key=18; char fname;
     int callback(xmitlen, len, buffer, flen)
     {
      long xmitlen; int len; char far *buffer; long flen;
      .
      .
      .
     }
     stat = sio_FtZmodemTx(port, "MY_FILE", call_func, key);


Chapter 3                                 Troubleshooting Programming Problems
------------------------------------------------------------------------------

The following are common programming problems.

1. MOXA board cannot transfer data through its port.

   Reasons:
   (a) Data cannot be transferred through a port unless the port is first
       opened using sio_open().

   (b) Configuration may be incorrectly set. Run SETUP.EXE, then press F2 to
       confirm the correct configuration.

2. After using the sio_loopback() function, ports can no longer access data.

   Reason:  The sio_loopback() function automatically closes ports after use.
            You must re-open the ports to access data again.

3. Data was lost during transmission

   Solution:  Apply hardware flow control to prevent data loss. The RS-232
              cable should have full handshaking signal lines such as RTS, CTS,
              DTR, DSR, TxD, RxD and GND. Hardware handshaking has to be
              specified using the setup program, or else the sio_flowctrl()
              function must be used to tell the driver to use hardware flow
              control.

   If hardware flow control cannot be applied, software flow control (XON/XOFF)
   is a solution. However, software flow control should only be used with text
   data instead of binary data transmission.

4. After receiving a certain amount of data, a receive-bound, interrupt-driven
   application cannot be interrupted by the MOXA driver, and thus cannot
   recieve any further data.

   Reason:  Each time a MOXA driver issues an interrupt, it may consist of
            several interrupt conditions. The solution is to read out or
            serves the data in the driver's input buffer until it is empty
            within the interrupt service routine.

