home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 October / PCO_10.ISO / filesbbs / rs203.arj / RS.DOC next >
Encoding:
Text File  |  1986-06-23  |  9.4 KB  |  222 lines

  1.              RS - An RS-232 Port Status Utility
  2.                    Author: Fred E. Davis
  3.  
  4.                        What RS does.
  5.  
  6.      RS is  an uncomplicated  utility  that  prints  a  full
  7. status report  of a selected RS-232 "COM" port.  It provides
  8. information about  the communications  protocol,  handshake,
  9. line, error and interrupt status.
  10.  
  11.                       How to call RS.
  12.  
  13.      RS is  called by  entering "RS"  followed by  either no
  14. argument  or  a  "1"  or  "2"  then  <enter>.  The  argument
  15. specifies which  COM port  you wish to view; "1" will select
  16. COM1 and "2" will select COM2.  When no argument is given or
  17. an illegal  value is  used, the  result will  be the same as
  18. entering "1".  If the  specified COM port is not present (or
  19. not responding),  RS will notify you with a "not installed!"
  20. message.  The command syntax is:
  21.  
  22.               [d:][pathspec]RS [1 | 2]<enter>
  23.  
  24.                      What it all means.
  25.  
  26.      The report  is divided into five sections: A. Protocol,
  27. B. Handshake  Status, C. Line Status, D. Error Status and E.
  28. Interrupt Status.
  29.  
  30. A. Protocol
  31.  
  32. Parity, Rate,  Stick and  Break. The  first four  items  are
  33. those values set by the DOS "mode COMx:" command.
  34.  
  35.      1. Data  Bits refers  to the number of binary bits used
  36.      to send  data. The  choices are 5, 6, 7 and 8. Five and
  37.      six are rarely used. Most text can be communicated with
  38.      7 bits.  An exception is a Wordstar formatted text file
  39.      that  uses  the  eighth  bit.  Most  binary  files  and
  40.      programs are transmitted with 8 data bits.
  41.  
  42.      2.  Stop   Bits  are   used  to  identify  the  end  of
  43.      transmission of one character. The possibilities are 1,
  44.      1.5 and  2 stop  bits. Most  protocols request one stop
  45.      bit; some  older (and slower) protocols required 1.5 or
  46.      2 stop bits.
  47.  
  48.      3.  Parity is used  in an  error detection  function to
  49.      identify a character distorted during transmission. The
  50.      choices are none, even and odd. All of these are likely
  51.      to be  encountered. None  is most often used with eight
  52.      data  bits;   odd  and   even  with  seven  data  bits.
  53.      Practically any  combination is possible and you should
  54.      refer  to   the  specific   protocol  requested  by  an
  55.      application to determine which is right.
  56.  
  57.      4.  Rate  refers  to  the  timing  of  the  bits  being
  58.      transmitted. The  choices are  many,  though  the  more
  59.      common ones are 1200, 2400, 4800 and 9600 baud, or bits
  60.      per second.  If the  rate isn't  right you'll soon find
  61.      out! You'll receive either nothing or garbage.
  62.  
  63.      5. Stick  refers to  making the parity bit (if used) to
  64.      "stick" at   logical  1 or  0.  If "stick" is "normal",
  65.      the parity bit function will follow the message in item
  66.      3. If  "stick" is  "set" and  "parity" is  "even",  the
  67.      parity bit will be forced to a logical zero. If "stick"
  68.      is "set"  and "parity" is "odd", the parity bit will be
  69.      forced to logical one.
  70.  
  71.      6. Break forces the transmitted data output to stay on.
  72.      It is  used mostly  in computer terminal communications
  73.      to grab  the attention  of a computer. If set, any data
  74.      to be transmitted is ignored.
  75.  
  76. B. Handshake Status
  77.  
  78.      There are  six handshake  lines: DTR, RTS, CTS, DSR, CD
  79. and RI.  These handshake lines are often used to control the
  80. transfer of  information between  the communicating systems,
  81. but not  always.  They  are  more  frequently  used  between
  82. computers and  modems, especially  CD and RI. The directions
  83. "In" and  "Out" used here are relative to the COM port. Some
  84. communications rely  on software handshake protocols such as
  85. XON/XOFF,   ETX/ACK    and   XMODEM   (which   goes   beyond
  86. handshaking). If  hardware handshaking  is used,  DTR and/or
  87. RTS must  be high  to enable the external device to receive.
  88. Likewise CTS  and DSR  should be high to enable the COM port
  89. to transmit.
  90.  
  91.      1.  DTR   Out  is  often  used  in  hardware  handshake
  92.      protocols  to   indicate  Data   Terminal  Ready.  Data
  93.      Terminal is  an old  term referring in this case to the
  94.      computer (PC).
  95.  
  96.      2. RTS  Out notifies  the external  device that the COM
  97.      port is Ready To Send.
  98.  
  99.      3. CTS  In is  the Clear To Send line. It is used often
  100.      in hardware handshake protocols with the DTR line.
  101.  
  102.      4. DSR In refers to Data Set Ready. It is often used to
  103.      inform a  Data Terminal  (or computer)  that a Data Set
  104.      (such as a modem) is ready to communicate.
  105.  
  106.      5. CD  In is  the Carrier Detect input from a modem. It
  107.      is asserted  when a  communications link is established
  108.      with another modem.
  109.  
  110.      6. RI  In refers  to Ring  Indicate from a modem. It is
  111.      used  primarily   for  auto-answer  operations  so  the
  112.      computer can accept incoming telephone calls (even on a
  113.      specific number of rings by counting RI transitions).
  114.  
  115. C. Line Status
  116.  
  117.      The four  Line Status  bits, Receive  Buffer,  Transmit
  118. Buffer, Break  Status and  Loop Back,  refer to the state of
  119. internal registers and a test function.
  120.  
  121.      1. Receive  Buffer is  the register that holds incoming
  122.      data. When holding data that hasn't been read, a "full"
  123.      message  will   be  displayed,  otherwise  it  will  be
  124.      "empty".
  125.  
  126.      2. Transmit  Buffer holds  data to  be sent.  When  not
  127.      currently holding  information waiting  to be  sent  it
  128.      will indicate "empty"; if data is waiting to be sent it
  129.      will show "full".
  130.  
  131.      3. Break  Status indicates  the presence  of a  "Break"
  132.      signal from  the sender. This often initiates some form
  133.      of interrupt to normal communications. (See A.6.)
  134.  
  135.      4. Loop  Back is  a special  state for internal testing
  136.      and verification  of hardware  and  register  function.
  137.      When "set", the internal output registers are connected
  138.      to the  input registers  (and  vice  versa)  such  that
  139.      transmitted  data  is  immediately  received.  It  must
  140.      indicate "normal" if communications are to take place.
  141.  
  142. D. Error Status
  143.  
  144.      The three  error  status  lines,  Overrun,  Parity  and
  145. Frame, are  set by  the COM  ports receiver  to  indicate  a
  146. communications problem.
  147.  
  148.      1. Overrun  "set" means that another character has been
  149.      received before  the first one has been read by the PC.
  150.      A possible cause for this is a baud rate too high.
  151.  
  152.      2.  Parity   "set"  means   that  the   last  character
  153.      transmission was  corrupted somehow.  It  obviously  is
  154.      significant only  when parity checking has been enabled
  155.      (See  A.3.).  Possible  causes  can  be  noise  in  the
  156.      communications lines  or improper  parity polarity (odd
  157.      or even).
  158.  
  159.      3. Frame  errors occur  when a  character was  received
  160.      without a  valid  stop  bit.  Possible  causes  include
  161.      improper communications protocol (See A.).
  162.  
  163. E. Interrupt Status
  164.  
  165.      Several  conditions   in  the   COM  port  cause  cause
  166. interrupts to the PCs Microprocessor to demand some service.
  167. The four  conditions are:  Received Data  Ready (See  C.1.),
  168. Transmit Buffer  Empty (See  C.2.), Line Status (See D.) and
  169. Modem Status (See B.).
  170.  
  171.      1. Output  refers to  an interrupt  control signal that
  172.      can enable  or disable  all interrupt requests from the
  173.      COM port.  If interrupts  are to  be used, it must show
  174.      "enable".
  175.  
  176.      2. Data Ready, if enabled, causes an interrupt when the
  177.      Received Data Buffer is full (See C.1.).
  178.  
  179.      3. Xmit Empty, if enabled, causes an interrupt when the
  180.      Transmit Data Buffer is empty and another character can
  181.      be sent.
  182.  
  183.      4. Line  Status would cause an interrupt, when enabled,
  184.      if C.1., C.2., C.3., D.1., D.2. or D.3. are asserted.
  185.  
  186.      5. Modem  Status, like Line Status, causes an interrupt
  187.      if B.3., B.4., B.5. or B.6 are asserted.
  188.  
  189.                        How RS works.
  190.  
  191.      RS is  written in assembly language, which explains its
  192. small size. The speed limitation on its execution is imposed
  193. by the  BIOS and  DOS display  routines. RS  is not a memory
  194. resident program;  it does  not trap any interrupts; it uses
  195. only BIOS  and DOS display interfaces; it does not alter the
  196. port configuration.
  197.  
  198.      After displaying  the  title  message,  RS  checks  the
  199. "command  tail"  (any  characters  entered  after  the  "RS"
  200. command) to  see if any arguments are being passed. If a "2"
  201. is present, RS will access COM2: starting at port 2F8h. If a
  202. "1", no  argument or an illegal value is passed, RS will use
  203. COM1: starting at port 3F8h.
  204.  
  205.      RS then  reads all  of the  port registers  and buffers
  206. into temporary  RAM buffers  used by  RS. The  Line  Control
  207. Register is read, altered, and restored. RS checks to see if
  208. a port  really exists  there  by  verifying  the  read/write
  209. operation. Once  all the  registers are  read, RS then scans
  210. the values  in the  RAM buffers  to generate the messages to
  211. the display.  This minimizes  interruption of port activity.
  212. In the  case of  the baud  rate, RS  first compares the rate
  213. divisor to a table of standard values. If the port's rate is
  214. not found, the actual baud rate is calculated and displayed.
  215.  
  216.      RS terminates  with a type 4Ch function call to DOS Int
  217. 21h. If  the  program  executed  normally  a  value  00h  is
  218. returned. If  the COM port is not installed or functional, a
  219. value of 01h is returned.
  220.  
  221. Fred E. Davis                                   26 June 1986
  222.