home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Inc&AD1.3 / Text_Autodocs / serial.doc < prev    next >
Encoding:
Text File  |  1992-09-12  |  20.2 KB  |  537 lines

  1. TABLE OF CONTENTS
  2.  
  3. serial.device/AbortIO
  4. serial.device/BeginIO
  5. serial.device/CloseDevice
  6. serial.device/CMD_BREAK
  7. serial.device/CMD_CLEAR
  8. serial.device/CMD_FLUSH
  9. serial.device/CMD_READ
  10. serial.device/CMD_RESET
  11. serial.device/CMD_START
  12. serial.device/CMD_STOP
  13. serial.device/CMD_WRITE
  14. serial.device/OpenDevice
  15. serial.device/SDCMD_QUERY
  16. serial.device/SDCMD_SETPARAMS
  17.  
  18.  
  19. serial.device/AbortIO                                     serial.device/AbortIO
  20.  
  21.    NAME
  22.        AbortIO(ioRequest) -- abort an I/O request
  23.                A1
  24.    FUNCTION
  25.       This is an exec.library call.
  26.  
  27.       This function attempts to aborts a specified read or write request.
  28.       If the request is active, it is stopped immediately. If the request is
  29.       queued, it is painlessly removed.  The request will be returned
  30.       in the same way any completed request it.
  31.  
  32.       After AbortIO(), you must generally do a WaitIO().
  33.  
  34.    INPUTS
  35.       iORequest  -- pointer to the IORequest Block that is to be aborted.
  36.  
  37.    RESULTS
  38.        io_Error -- if the Abort succeded, then io_Error will be #IOERR_ABORTED
  39.  
  40.            (-2) and the request will be flagged as aborted (bit 5 of 
  41.            io_Flags is set).  If the Abort failed, then the Error will be zero.
  42.    BUGS
  43.        Previous to version 34, the serial.device would often hang when
  44.        aborting CTS/RTS handshake requests.  This was the cause of the
  45.        incorrect assumption that AbortIO() does not need to be followed
  46.        by a wait for a reply (or a WaitIO()). 
  47.  
  48.  
  49. serial.device/BeginIO                                     serial.device/BeginIO
  50.  
  51.    NAME
  52.        BeginIO(ioRequest),deviceNode -- start up an I/O process
  53.                 A1        A6
  54.    FUNCTION
  55.        This is a direct function call to the device.  It is intended for
  56.        more advanced programmers.  See exec's DoIO() and SendIO() for
  57.        the normal method of calling devices.
  58.  
  59.        This function initiates a I/O request made to the serial
  60.        device. Other than read or write, the functions are performed 
  61.        synchronously, and do not depend on any interrupt handling 
  62.        logic (or it's associated discontinuities), and hence should
  63.        be performed as IO_QUICK.
  64.        With some exceptions, reads and writes are merely initiated by 
  65.        BeginIO, and thusly return to the caller as begun, not completed.
  66.        Completion is signalled via the standard ReplyMsg routine.
  67.        Multiple requests are handled via FIFO queueing.
  68.        One exception to this non-QUICK handling of reads and writes
  69.        is for READS when:
  70.          - IO_QUICK bit is set
  71.          - There are no pending read requests
  72.          - There is already enough data in the input buffer to satisfy
  73.            this I/O Request immediately.
  74.        In this case, the IO_QUICK flag is not cleared, and the request
  75.        is completed by the time it returns to the caller. There is no
  76.        ReplyMsg or signal bit activity in this case.
  77.           
  78.    INPUTS
  79.        ioRequest  -- pointer to an I/O Request Block of size 
  80.            io_ExtSerSize (see serial.i for size/definition), 
  81.            containing a valid command in io_Command to process,
  82.            as well as the command's other required parameters.
  83.        deviceNode -- pointer to the "serial.device", as found in
  84.            the IO_DEVICE of the ioRequest.
  85.  
  86.    RESULTS
  87.        io_Error -- if the BeginIO succeded, then Error will be null.
  88.            If the BeginIO failed, then the Error will be non-zero.
  89.            I/O errors won't be reported until the io completes.
  90.  
  91.    SEE ALSO
  92.     devices/serial.h
  93.  
  94.  
  95. serial.device/CloseDevice                             serial.device/CloseDevice
  96.  
  97.    NAME
  98.        CloseDevice -- close the serial port
  99.  
  100.    SYNOPSIS
  101.        CloseDevice(deviceNode)
  102.                     A1
  103.    FUNCTION
  104.        This is an exec call that terminates communication with the
  105.        serial device.  Upon closing, the device's input buffer is freed.
  106.  
  107.        Note that all IORequests MUST be complete before closing.
  108.     If any are pending, your program must AbortIO() then WaitIO()
  109.        to complete them.
  110.  
  111.    INPUTS
  112.        deviceNode - pointer to the device node, set by Open
  113.  
  114.    SEE ALSO
  115.        serial.device/OpenDevice
  116.  
  117.  
  118. serial.device/CMD_BREAK                                 serial.device/CMD_BREAK
  119.  
  120.    NAME
  121.        Break -- send a break signal over the serial line
  122.  
  123.    FUNCTION
  124.        This command sends a break signal (serial line held low
  125.        for an extended period) out the serial port. This is accom-
  126.        plished by setting the UARTBRK bit of reg ADKCON. After a
  127.        duration (user specifiable via setparams, default 250000
  128.        microseconds) the bit is reset and the signal discontinued.
  129.        If the QUEUEDBRK bit of io_SerFlags is set in the io_Request 
  130.        block, the request is placed at the back of the write-request 
  131.        queue and executed in turn. If the QUEUEDBRK bit is not set, 
  132.        the break is started immediately, control returns to the 
  133.        caller, and the timer discontinues the signal after the 
  134.        duration is completed. Be aware that calling BREAK may
  135.     affect other commands such as ABORT, FLUSH, STOP, START, etc...
  136.  
  137.    IO REQUEST
  138.        io_Message      mn_ReplyPort initialized
  139.        io_Device       set by OpenDevice
  140.        io_Unit         set by OpenDevice
  141.        io_Command      SDCMD_BREAK
  142.        io_Flags        set/reset IO_QUICK per above description
  143.  
  144.    RESULTS
  145.        Error -- if the Break succeded, then Error will be null.
  146.            If the Break failed, then the Error will be non-zero.
  147.  
  148.  
  149. serial.device/CMD_CLEAR                                 serial.device/CMD_CLEAR
  150.  
  151.    NAME
  152.        Clear -- clear the serial port buffers
  153.  
  154.    FUNCTION
  155.        This command resets the serial port's read buffer pointers.
  156.  
  157.    IO REQUEST
  158.        io_Message      mn_ReplyPort initialized
  159.        io_Device       set by OpenDevice
  160.        io_Unit         set by OpenDevice
  161.        io_Command      CMD_CLEAR
  162.  
  163.    RESULTS
  164.        Error -- If the Clear succeded, then io_Error will be null.
  165.                 If the Clear failed, then the io_Error will be non-zero.
  166.  
  167.  
  168. serial.device/CMD_FLUSH                                 serial.device/CMD_FLUSH
  169.  
  170.    NAME
  171.        Flush -- clear all queued I/O requests for the serial port
  172.  
  173.    FUNCTION
  174.        This command purges the read and write request queues for the
  175.        serial device. Flush will not affect active requests.
  176.  
  177.    IO REQUEST
  178.        io_Message      mn_ReplyPort initialized
  179.        io_Device       set by OpenDevice
  180.        io_Unit         set by OpenDevice
  181.        io_Command      CMD_FLUSH
  182.  
  183.    RESULTS
  184.        Error -- if the Flush succeded, then io_Error will be null.
  185.                 If the Flush failed, then the io_Error will be non-zero.
  186.  
  187.  
  188. serial.device/CMD_READ                                   serial.device/CMD_READ
  189.  
  190.    NAME
  191.        Read -- read input from serial port
  192.  
  193.    FUNCTION
  194.     This command causes a stream of characters to be read in from
  195.     the serial port buffer.  The number of characters is specified
  196.     in io_Length.
  197.  
  198.     The Query function can be used to check how many characters
  199.     are currently waiting in the serial port buffer.  If more characters
  200.     are requested than are currently available, the ioRequest
  201.     will be queued until it can be satisfied.
  202.  
  203.  
  204.     The best way to handle reads is to first Query to get the number
  205.     of characters currently in the buffer.  Then post a read request
  206.     for that number of characters (or the maximum size of your buffer).
  207.  
  208.     If zero characters are in the buffer, post a request
  209.     for 1 character.  When at least one is ready, the device will return
  210.     it.  Now start over with another Query.
  211.  
  212.     Before the program exits, it must be sure to AbortIO() then WaitIO()
  213.     any outstanding ioRequests.
  214.  
  215.    IO REQUEST
  216.        io_Message      A mn_ReplyPort is required
  217.        io_Device       set by OpenDevice
  218.        io_Unit         set by OpenDevice
  219.        io_Command      CMD_READ
  220.        io_Flags        If the IOB_QUICK bit is set, read will try
  221.             to complete the IO quickly
  222.        io_Length       number of characters to receive.
  223.        io_Data         pointer to buffer
  224.  
  225.    RESULTS
  226.        Error -- if the Read succeded, then io_Error will be null.
  227.            If the Read failed, then io_Error will be non-zero.
  228.          io_Error will indicate problems such as parity mismatch,
  229.          break, and buffer overrun.
  230.  
  231.    SEE ALSO
  232.     serial.device/CMD_QUERY
  233.     serial.device/SDCMD_SETPARAMS
  234.  
  235.    BUGS
  236.     Having multiple outstanding read IORequests at any one time will
  237.     probably fail.
  238.  
  239.     Old documentation mentioned a mode where io_Length was set to -1.
  240.     If you want a NULL terminated read, use the io_TermArray instead.
  241.  
  242.  
  243. serial.device/CMD_RESET                                 serial.device/CMD_RESET
  244.  
  245.    NAME
  246.        Reset -- reinitializes the serial port
  247.  
  248.    FUNCTION
  249.        This command resets the serial port to its freshly initialized
  250.        condition. It aborts all I/O requests both queued and current,
  251.        relinquishes the current buffer, obtains a new default sized
  252.        buffer, and sets the port's flags and parameters to their 
  253.        boot-up time default values. The functions places the reset
  254.        parameter values in the ioRequest block.
  255.  
  256.    IO REQUEST
  257.        io_Message      mn_ReplyPort initialized
  258.        io_Device       set by OpenDevice
  259.        io_Unit         set by OpenDevice
  260.        io_Command      CMD_RESET
  261.  
  262.    RESULTS
  263.        Error -- if the Reset succeded, then Error will be null.
  264.            If the Reset failed, then the Error will be non-zero.
  265.  
  266.  
  267. serial.device/CMD_START                                 serial.device/CMD_START
  268.  
  269.    NAME
  270.        Start -- restart paused I/O over the serial port
  271.  
  272.    FUNCTION
  273.        This function restarts all current I/O on the serial port by 
  274.        sending an xON to the "other side", and submitting a "logical
  275.        xON" to "our side", if/when appropriate to current activity.
  276.  
  277.    IO REQUEST
  278.        io_Message      mn_ReplyPort initialized
  279.        io_Device       set by OpenDevice
  280.        io_Unit         set by OpenDevice
  281.        io_Command      CMD_START
  282.  
  283.    RESULTS
  284.  
  285.    SEE ALSO
  286.        serial.device/CMD_STOP
  287.  
  288.  
  289. serial.device/CMD_STOP                                   serial.device/CMD_STOP
  290.  
  291.    NAME
  292.        Stop -- pause all current I/O over the serial port
  293.  
  294.    FUNCTION
  295.        This command halts all current I/O on the serial port by 
  296.        sending an xOFF to the "other side", and submitting a "logical
  297.        xOFF" to "our side", if/when appropriate to current activity.
  298.  
  299.    IO REQUEST
  300.        io_Message      mn_ReplyPort initialized
  301.        io_Device       set by OpenDevice
  302.        io_Unit         set by OpenDevice
  303.        io_Command      CMD_STOP
  304.  
  305.    RESULTS
  306.  
  307.    SEE ALSO
  308.        serial.device/CMD_START
  309.  
  310.  
  311. serial.device/CMD_WRITE                                 serial.device/CMD_WRITE
  312.  
  313.    NAME
  314.        Write -- send output to serial port
  315.  
  316.    FUNCTION
  317.        This command causes a stream of characters to be written out
  318.        the serial port. The number of characters is specified in
  319.        io_Length, unless -1 is used, in which case output is sent until
  320.        a null(0x00) is encountered. 
  321.  
  322.    IO REQUEST
  323.        io_Message      must have mn_ReplyPort initialized
  324.        io_Device       set by OpenDevice
  325.        io_Unit         set by OpenDevice
  326.        io_Command      CMD_WRITE
  327.        io_Flags        Set IOF_QUICK to try quick I/O
  328.        io_Length       number of characters to transmit, or if set
  329.                        to -1 transmit until null encountered in buffer
  330.        io_Data         pointer to block of data to transmit
  331.  
  332.    RESULTS
  333.        Error -- if the Write succeded, then io_Error will be null.
  334.            If the Write failed, then the io_Error will be non-zero.
  335.  
  336.    SEE ALSO
  337.     serial.device/SDCMD_SETPARAMS
  338.  
  339.  
  340. serial.device/OpenDevice                               serial.device/OpenDevice
  341.  
  342.    NAME
  343.        OpenDevice -- Request an opening of the serial device.
  344.  
  345.    SYNOPSIS
  346.        error = OpenDevice(SERIALNAME, unit, ioRequest, flags)
  347.        D0                 A0          D0    A1         D0
  348.  
  349.    FUNCTION
  350.        This is an exec call.  Exec will search for the serial.device, and
  351.        if found, will pass this call on to the device.
  352.  
  353.        Unless the shared-access bit (bit 5 of io_SerFlags) is set, 
  354.        exclusive use is granted and no other access to that unit is
  355.        allowed until the owner closes it.  All the serial-specific fields
  356.        in the ioRequest are initialized to their most recent values (or
  357.        the Preferences default, for the first time open).
  358.  
  359.        If support of 7-wire handshaking (i.e. RS232-C CTS/RTS protocol)
  360.        is required, set the 7WIRE bit in io_SerFlags before opening
  361.        the serial device.
  362.  
  363.    INPUTS
  364.        SERIALNAME    - pointer to literal string "serial.device"
  365.        unit          - Must be zero, or a user setable unit number.
  366.               (This field is used by multiple port controllers)
  367.                          Zero specifies the built-in serial port.
  368.        ioRequest     - pointer to an ioRequest block of size io_ExtSerSize
  369.                          to be initialized by the serial.device.
  370.                          (see devices/serial.h for the definition)
  371.                            NOTE use of io_SerFlags (see FUNCTION above)
  372.         IMPORTANT: The ioRequest block MUST be of size io_ExtSerSize !
  373.        flags         - Must be zero for future compatibility
  374.  
  375.    RESULTS
  376.        D0       - same as io_Error
  377.        io_Error  - If the Open succeded, then io_Error will be null.
  378.                    If the Open failed, then io_Error will be non-zero.
  379.        io_Device - A pointer to whatever device will handle the calls
  380.                    for this unit.  This pointer may be different depending
  381.                    on what unit is requested.
  382.  
  383.    BUGS
  384.     If 7-wire handshaking is specified, this enables a timeout "feature".
  385.     If the device holds off the computer for more than about 30-60
  386.     seconds, the device will return the write request with the error
  387.     SerErr_TimerErr.  Don't depend on this, however.  If you want a timeout,
  388.     set up the timer.device and wait for either timer, or serial IO to
  389.     complete.
  390.  
  391.     On open, the serial.device allocates the misc.resource for the
  392.     serial port.  It does not return it until the serial.device is
  393.     expunged from memory.  It should return it when no more openers
  394.     exist.
  395.  
  396.    SEE ALSO
  397.     serial.device/CloseDevice
  398.     devices/serial.h
  399.  
  400.  
  401. serial.device/SDCMD_QUERY                             serial.device/SDCMD_QUERY
  402.  
  403.    NAME
  404.        Query -- query serial port/line status
  405.  
  406.    FUNCTION
  407.        This command return the status of the serial port lines and
  408.        registers. The number of unread bytes in the serial device's
  409.        read buffer is shown in io_Actual.
  410.  
  411.     The break send & received flags are cleared by a query, and
  412.     whenever a read IORequest is returned with a error
  413.     in io_Error.
  414.  
  415.    IO REQUEST
  416.        io_Message      mn_ReplyPort initialized
  417.        io_Device       preset by OpenDevice
  418.        io_Unit         preset by OpenDevice
  419.        io_Command      SDCMD_QUERY
  420.  
  421.    RESULTS
  422.        io_Status        BIT  ACTIVE  FUNCTION
  423.  
  424.               LSB       0    ---    reserved
  425.                         1    ---    reserved
  426.                         2    high   parallel "sel" on the A1000
  427.                                     On the A500 & A2000, "sel" is also
  428.                                     connected to the serial port's
  429.                                     "Ring Indicator".  Be cautious when
  430.                                     making cables.
  431.                         3    low    Data Set Ready
  432.                         4    low    Clear To Send
  433.                         5    low    Carrier Detect
  434.                         6    low    Ready To Send
  435.                         7    low    Data Terminal Ready
  436.               MSB       8    high   hardware overrun
  437.                         9    high   break sent (most recent output)
  438.                        10    high   break received (as latest input)
  439.                        11    high   transmit x-OFFed       
  440.                        12    high   receive x-OFFed       
  441.                     13-15    ---    reserved
  442.  
  443.        io_Actual       set to count of unread input characters
  444.  
  445.        io_Error -- Query will always succeded.
  446.  
  447.  
  448. serial.device/SDCMD_SETPARAMS                     serial.device/SDCMD_SETPARAMS
  449.  
  450.    NAME
  451.        SetParams -- change parameters for the serial port
  452.  
  453.    FUNCTION
  454.        This command allows the caller to change parameters for the
  455.        serial device. Except for xON-xOFF enable/disable, it will
  456.        reject a setparams call if any reads or writes are active 
  457.        or pending. 
  458.           Note specifically:
  459.  
  460.     1. Valid input for io_Baud is between 112 and 292000 baud inclusive;
  461.        asynchronous i/o above 32KB (especially on a busy system) may
  462.        be ambitious.
  463.     2. The EOFMODE and QUEUEDBRK bits of io_SerFlags can be set/reset 
  464.        in the io_Rqst block without a call to SetParams. The SHARED 
  465.        and 7WIRE bits of io_SerFlags can be used in OpenDevice calls.
  466.        ALL OTHER PARAMETERS CAN ONLY BE CHANGED BY THE SetParams 
  467.        COMMAND.
  468.     3. RBufLen must be at least 64.
  469.     4. If not used, io_ExtFlags MUST be set to zero.
  470.     5. xON-xOFF is by default enabled. The XDISABLED bit is the only
  471.        parameter that can be changed via a SetParams call while the
  472.        device is active. Note that this will return the value
  473.        SerErr_DevBusy in the io_Error field.
  474.     
  475.     xON/xOFF handshaking is inappropriate for certain binary transfer
  476.     protocalls, such as Xmodem.  The binary data might contain the
  477.     xON (ASCII 17) and xOFF (ASCII 19) characters.
  478.  
  479.     6. If trying to run MIDI, you should set the RAD_BOOGIE bit of
  480.        io_SerFlags to eliminate unneeded overhead. Specifically, this skips
  481.        checks for parity, x-OFF handling, character lengths other than
  482.        8 bits, and testing for a break signal. Setting RAD_BOOGIE will
  483.        also set the XDISABLED bit.
  484.        Note that writing data (that's already in MIDI format) at MIDI rates
  485.        is easily accomplished. Using this driver alone for MIDI reads may,
  486.        however, may not be reliable, due to MIDI timestamping requirements,
  487.        and possibility of overruns in a busy multitasking and/or display
  488.        intensive environment.
  489.     7. If you select mark or space parity (see io_ExtFlags in serial.h),
  490.        this will cause the SERB_PARTY_ON bit to be set, and the setting
  491.        of SERB_PARTY_ODD to be ignored.
  492.     8. For best results, set the RAD_BOOGIE flag whenever possible.  See
  493.     #6 for details.
  494.     9. Note that at this time parity is *not* calculated for the xON-xOFF
  495.     characters.  If you have a system that is picky about the parity of
  496.     these, you must set your own xON-xOFF characters in io_CtlChar.
  497.  
  498.    IO REQUEST
  499.        io_Message      mn_ReplyPort initialized
  500.        io_Device       preset by OpenDevice
  501.        io_Unit         preset by OpenDevice
  502.        io_Command      SDCMD_SETPARAMS (0x0B)
  503.               NOTE that the following fields are filled in by Open 
  504.                        to reflect the serial device's current configuration.
  505.        io_CtlChar      a longword containing byte values for the
  506.                        xON,xOFF,INQ,ACK fields (respectively)
  507.                        (INQ/ACK not used at this time)
  508.        io_RBufLen      length in bytes of input buffer
  509.               NOTE that any change in buffer size causes the
  510.                        current buffer to be deallocated and a new,
  511.                        correctly sized one to be allocated. Thusly,
  512.                        the CONTENTS OF THE OLD BUFFER ARE LOST.
  513.        io_ExtFlags     additional serial flags (bitdefs in devices/serial.h)
  514.             mark & space parity may be specified here.
  515.        io_Baud         baud rate for reads AND writes. (See 1 above)
  516.        io_BrkTime      duration of break signal in MICROseconds
  517.        io_TermArray    ASCII descending-ordered 8-byte array of
  518.                        termination characters. If less than 8 chars
  519.                        used, fill out array w/lowest valid value.
  520.                        Terminators are checked only if EOFMODE bit of
  521.                        io_Serflags is set. (e.g. x512F040303030303 )
  522.        io_ReadLen      number of bits in read word (1-8) not including parity
  523.        io_WriteLen     number of bits in write word (1-8) "      "       "
  524.        io_StopBits     number of stop bits (0, 1 or 2)
  525.        io_SerFlags     see devices/serial.h for bit equates, NOTE that x00
  526.                        yields exclusive access, xON/OFF-enabled, no
  527.                        parity checking, 3-wire protocol and TermArray
  528.                        inactive.
  529.  
  530.    RESULTS
  531.        Error -- if the SetParams succeded, then Error will be null.
  532.            If the SetParams failed, then the Error will be non-zero.
  533.  
  534.    SEE ALSO
  535.     exec/OpenDevice
  536.  
  537.