home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / asm / RS232DVR.ZIP / RS232.DOC < prev    next >
Encoding:
Text File  |  1987-08-13  |  9.6 KB  |  226 lines

  1.                           RS232 Communications Driver
  2.  
  3.                Original Author: Greg Haley, Texas Instruments
  4.  
  5.                                Version 3.00 by
  6.                                  Joe McDaniel
  7.                          Fein-Marquart Associates, Inc.
  8.                                 7215 York Road
  9.                               Baltimore, MD 21212
  10.                                 (301) 821-5980
  11.  
  12. History:
  13.     The original work on this package was done by Greg Haley 
  14. of Texas Instruments. The system I took and modified had severe problems
  15. in that it could support input, but output didn't work. Also it did
  16. not support interrupt driven output, only input. The original version
  17. also had support for (I assume) debugging aids which allowed for echoing
  18. of characters received and transmitted and for direct keyboard input.
  19. None of these features is currently present - I felt they were of no
  20. value and just kludged up the code. Xon/Xoff now works. RS232.COM now reports
  21. on the status of the control lines. I eliminated the TI specific stuff as I had
  22. no way to test it. Also, the original distribution had a terminal emulator
  23. that took advantage of the echoing features - it is now gone, too. I fixed
  24. the 19,200 baud stuff so it will work.
  25.  
  26. Introduction
  27.  
  28.   The purpose of this package is to provide RS232 communications support
  29. in device driver form for the IBM PC. All machine dependent code is confined
  30. to the device drivers. The device drivers in this package use the
  31. MS-DOS I/O control channel to configure the driver and to check or change the
  32. modem RS232 signals. Some of the features of the drivers used here that make
  33. them useful for communications are:
  34.  
  35.         o Interrupt driven communications
  36.         o Optional flow control
  37.         o Access to the modem signals
  38.         o Ability to change communication settings without disconnecting
  39.         o Ability to force a disconnect by dropping RTS and DTR
  40.         o 110 - 19200 baud rates
  41.         o EVEN, ODD, or no parity using 7 or 8 data bits
  42.         o Device driver is configured using standard MS-DOS function calls
  43.         o Access the number of characters in the receive queue
  44.         o Ability to purge the receive queue
  45.  
  46.   These drivers support all the major needs of any communications program,
  47. and are a substantial improvement over most of the default device drivers
  48. that come standard with each MS-DOS computer.
  49.  
  50.   Using these drivers, any language that can write to the device "AUX" can
  51. now do interrupt driven RS232 I/O. If the language is not capable of issuing
  52. the MS-DOS functions call 44 hex (I/O control) to configure the driver, the
  53. assembly program RS232 is provided to set up the port, baud rate, parity,
  54. etc. for the device driver. The source code for this program is provided as
  55. an example of using the MS-DOS I/O control function call.
  56.  
  57. Here's a list of the files in this package with a brief description of each
  58. file:
  59.         IBMRS232.ASM    Source for IBM PC machine dependent code
  60.         RS232.ASM       Source for RS232 configuration program
  61.         RS232.DOC       Documentation for this package
  62.         RS232.INC       Source for general device driver routines
  63.  
  64. Assembling the routines
  65.  
  66. Edit IBMRS232.ASM ans RS232.ASM to set the name of the device being created.
  67. It is currently set to AUX. Assemble as follows:
  68.     masm ibmrs232;
  69.     masm rs232;
  70.  
  71. Link:
  72.     link ibmrs232;
  73.     exe2bin ibmrs232.exe auxdvr.sys
  74.     link rs232;
  75.     exe2bin rs232.exe rs232.com
  76.  
  77. Installing the Device Driver
  78.  
  79.   Installing the device driver of your choice is done by editing your
  80. CONFIG.SYS file and putting a copy of the driver in your root directory.
  81. As an example, to install the IBM driver on drive C:, first copy the file
  82. AUXDVR.SYS to someplace where you can access it during boot such as 
  83. C:\AUXDVR.SYS. Next, add the following statement to your CONFIG.SYS file:
  84.  
  85.   DEVICE = AUXDVR.SYS
  86.  
  87. The next time you reboot, the driver will be installed and will take the
  88. device name "AUX". The driver will not respond until you configure it by
  89. writing the Device Configuration Word (DCW) to the I/O control channel.
  90. This is accomplished using the MS-DOS function call 44h (hex) and is covered
  91. in the next section.
  92.  
  93. Using the I/O Control Function Call
  94.  
  95.   All I/O control to the device driver is done in one or two byte forms.
  96. The two byte form is used to set up the communications paramenters. The
  97. single byte form is used to select all other options such as checking the
  98. modem signals. We'll cover the single byte form first. Reading one byte
  99. from the I/O control channel causes the driver return the current modem
  100. signals and I/O configuration. (See function 44h, AL=2 in your MS-DOS manual)
  101. The modem signals and options are encoded as follows:
  102.  
  103.              Bit number
  104.   +-------------------------------+
  105.   | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  106.   |-------------------------------|
  107.   |   |   |   | RI|SCF|DSR|CTS|DCD|
  108.   +-------------------------------+
  109.  
  110.   Bit   Description
  111.    4    0 = RI (Ring Indicator) is down.
  112.         1 = RI (Ring Indicator) is up.
  113.  
  114.    3    0 = SCF (High speed line) is down.
  115.         1 = SCF (High speed line) is up.
  116.           * The signal SCF is not supported by the IBM PC.
  117.             For the IBM PC, this signal will always be down (0).
  118.  
  119.    2    0 = DSR (Data Set Ready) is down.
  120.         1 = DSR (Data Set Ready) is up.
  121.  
  122.    1    0 = CTS (Clear to Send) is down.
  123.         1 = CTS (Clear to Send) is up.
  124.  
  125.    0    0 = DCD (Data Carrier Detect) is down.
  126.         1 = DCD (Data Carrier Detect) is up.
  127.  
  128.  
  129.   Writing a single byte to the I/O control channel (function 44h, AL=3)
  130. is used to set the driver options, flush the receive buffer, and disconnect
  131. (by dropping RTS and DTR). Below is a chart showing the various values for
  132. the byte code and the action taken:
  133.  
  134.              Bit number
  135.   +-------------------------------+
  136.   | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  137.   |-------------------------------|
  138.   |   |   |   |   |   |LEN|FIB|DTR|
  139.   +-------------------------------+
  140.  
  141. Name    Bit     Description
  142. LEN      2      0 = Output DCW on 2 byte I/O channel reads. (Default)
  143.                 1 = Output receive queue length on 2 byte I/O channel reads.
  144.                   * Note that this field need only be set once. The current
  145.                     state is used until LEN is changed again.
  146.  
  147. FIB      1      0 = Don't flush receive buffer
  148.                 1 = Flush receive buffer
  149.  
  150. DTR      0      0 = Disconnect (drop DTR and RTS) and reset driver.
  151.                 1 = DTR and RTS up.
  152.  
  153. N.B.: The read byte and write byte have no relation to each other! If you
  154. read, do not write the read value. Set your own parameters!
  155.  
  156.  
  157.   The two byte form of I/O control can be used to read or write the
  158. communications settings. Writing a 2 byte value to the control channel
  159. will set the Device Configuration Word (DCW). Reading 2 bytes from the
  160. control channel will do one of two things depending on the state of the
  161. LEN bit. (The LEN bit is set by the user in the single byte control channel
  162. write.) If LEN = 0, the DCW will be read. If LEN = 1, the receive buffer
  163. length is read. The default mode is LEN = 0, read the DCW. Below is a bit
  164. map showing the various fields within the Device Control Word:
  165.  
  166.  +-------------------------------+-------------------------------+
  167.  |           Upper Byte          |           Lower Byte          |
  168.  +-------------------------------+-------------------------------+
  169.  | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
  170.  +-------------------------------+-------------------------------+
  171.  | 1 | 2 | 0 | 3 | 3 | 0 | 4 | 4 | 5 | 5 | 5 | 5 | 6 | 7 | 8 | 8 |
  172.  +-------------------------------+-------------------------------+
  173.  |                           Bit Codes                           |
  174.  +-------------------------------+-------------------------------+
  175.  
  176.         Bit Code        Description
  177.  
  178.            2            Number of data bits
  179.                           0 = 7 data bits
  180.                           1 = 8 data bits
  181.  
  182.            3            Port Number
  183.                           00 = Port 1
  184.                           01 = Port 2
  185.                           10 = Port 3
  186.                           11 = Port 4
  187.  
  188.            4            Flow Control
  189.                           00 = none
  190.                           01 = SCF     (NONE for IBM PC)
  191.                           10 = DSR
  192.                           11 = XON-XOFF
  193.  
  194.            5            Baud Rate
  195.                           0000 = 110
  196.                           0001 = 150
  197.                           0010 = 300
  198.                           0011 = 600
  199.                           0100 = 1200
  200.                           0101 = 2400
  201.                           0110 = 4800
  202.                           0111 = 9600
  203.                           1000 = 19200
  204.  
  205.            6            Number of Stop Bits
  206.                           0 = 1
  207.                           1 = 2
  208.  
  209.            8            Parity
  210.                           00 = none
  211.                           01 = ODD
  212.                           10 = none
  213.                           11 = EVEN
  214.  
  215. Writing a New Driver
  216.  
  217.   Additional RS232 drivers may be written for other MS-DOS (2.xx and greater)
  218. machines by changing the machine dependent portion of the driver. The two
  219. driver provided has machine dependent code in IBMRS232.ASM. The file RS232.INC
  220. is an include file and provides the general device driver functions. Any general
  221. changes to the driver should be made here. To make a new driver, only the 
  222. machine dependent portion needs to be written, and any new driver should also 
  223. use the INCLUDE directive to add the code from RS232.INC. Following this form 
  224. will make maintaining the various drivers much easier.
  225.  
  226.