home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / MOUSE / RS.ZIP / RS.DOC < prev   
Encoding:
Text File  |  1987-03-26  |  13.9 KB  |  529 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                          RS - An RS-232 Port Status Utility
  8.                                           
  9.                                Author: Fred E. Davis
  10.                                           
  11.                                           
  12.                                           
  13.                                    What RS does.
  14.             
  15.  
  16.                  RS is  an uncomplicated  utility  that  prints  a  full
  17.  
  18.             status report  of a  selected RS-232 'COM' port. It provides
  19.  
  20.             information about  the communications  protocol,  handshake,
  21.  
  22.             line, error and interrupt status.
  23.  
  24.             
  25.  
  26.                                   How to call RS.
  27.  
  28.                  RS is  called by  entering 'RS'  followed by  either no
  29.  
  30.             argument  or  a  '1'  or  '2'  then  <enter>.  The  argument
  31.  
  32.             specifies which  COM port  you wish to view; '1' will select
  33.  
  34.             COM1 and  '2' will select COM2. When no argument is given or
  35.  
  36.             an illegal  value is  used, the  result will  be the same as
  37.  
  38.             entering '1'.  If the  specified COM port is not present (or
  39.  
  40.             not responding),  RS will notify you with a 'not installed!'
  41.  
  42.             message. The command syntax is:
  43.  
  44.                           [d:][pathspec]RS [1 | 2]<enter>
  45.  
  46.                                           
  47.  
  48.                                  What it all means.
  49.  
  50.                  The report  is divided into five sections: A. Protocol,
  51.  
  52.             B. Handshake  Status, C. Line Status, D. Error Status and E.
  53.  
  54.             Interrupt Status.
  55.  
  56.             A. Protocol
  57.  
  58.  
  59.  
  60.  
  61.             Fred E. Davis                                   26 June 1986
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.             An RS-232 Port Status Utility                              2
  71.  
  72.  
  73.                  Protocol lists  six  items:    Data  Bits,  Stop  Bits,
  74.  
  75.             Parity, Rate,  Stick and  Break. The  first four  items  are
  76.  
  77.             those values set by the DOS 'mode COMx:' command.
  78.  
  79.                  
  80.  
  81.                  1. Data  Bits refers  to the number of binary bits used
  82.  
  83.                  to send  data. The  choices are 5, 6, 7 and 8. Five and
  84.  
  85.                  six are rarely used. Most text can be communicated with
  86.  
  87.                  7 bits.  An exception is a Wordstar formatted text file
  88.  
  89.                  that  uses  the  eighth  bit.  Most  binary  files  and
  90.  
  91.                  programs are transmitted with 8 data bits.
  92.  
  93.                  
  94.  
  95.                  2.  Stop   Bits  are   used  to  identify  the  end  of
  96.  
  97.                  transmission of one character. The possibilities are 1,
  98.  
  99.                  1.5 and  2 stop  bits. Most  protocols request one stop
  100.  
  101.                  bit; some  older (and slower) protocols required 1.5 or
  102.  
  103.                  2 stop bits.
  104.  
  105.                  
  106.  
  107.                  3. Parity  is used  in an  error detection  function to
  108.  
  109.                  identify a character distorted during transmission. The
  110.  
  111.                  choices are none, even and odd. All of these are likely
  112.  
  113.                  to be  encountered. None  is most often used with eight
  114.  
  115.                  data  bits;   odd  and   even  with  seven  data  bits.
  116.  
  117.                  Practically any  combination is possible and you should
  118.  
  119.                  refer  to   the  specific   protocol  requested  by  an
  120.  
  121.                  application to determine which is right.
  122.  
  123.                  
  124.  
  125.  
  126.  
  127.             Fred E. Davis                                   26 June 1986
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.             An RS-232 Port Status Utility                              3
  137.  
  138.  
  139.                  4.  Rate  refers  to  the  timing  of  the  bits  being
  140.  
  141.                  transmitted. The  choices are  many,  though  the  more
  142.  
  143.                  common ones are 1200, 2400, 4800 and 9600 baud, or bits
  144.  
  145.                  per second.  If the  rate isn't  right you'll soon find
  146.  
  147.                  out! You'll receive either nothing or garbage.
  148.  
  149.                  
  150.  
  151.                  5. Stick  refers to  making the parity bit (if used) to
  152.  
  153.                  "stick" at   logical  1 or  0.  If 'stick' is 'normal',
  154.  
  155.                  the parity bit function will follow the message in item
  156.  
  157.                  3. If  'stick' is  'set' and  'parity' is  'even',  the
  158.  
  159.                  parity bit will be forced to a logical zero. If 'stick'
  160.  
  161.                  is 'set'  and 'parity' is 'odd', the parity bit will be
  162.  
  163.                  forced to logical one.
  164.  
  165.                  
  166.  
  167.                  6. Break forces the transmitted data output to stay on.
  168.  
  169.                  It is  used mostly  in computer terminal communications
  170.  
  171.                  to grab  the attention  of a computer. If set, any data
  172.  
  173.                  to be transmitted is ignored.
  174.  
  175.             
  176.  
  177.             B. Handshake Status
  178.  
  179.                  There are  six handshake  lines: DTR, RTS, CTS, DSR, CD
  180.  
  181.             and RI.  These handshake lines are often used to control the
  182.  
  183.             transfer of  information between  the communicating systems,
  184.  
  185.             but not  always.  They  are  more  frequently  used  between
  186.  
  187.             computers and  modems, especially  CD and RI. The directions
  188.  
  189.             'In' and  'Out' used here are relative to the COM port. Some
  190.  
  191.  
  192.  
  193.             Fred E. Davis                                   26 June 1986
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.             An RS-232 Port Status Utility                              4
  203.  
  204.  
  205.             communications rely  on software handshake protocols such as
  206.  
  207.             XON/XOFF,   ETX/ACK    and   XMODEM   (which   goes   beyond
  208.  
  209.             handshaking). If  hardware handshaking  is used,  DTR and/or
  210.  
  211.             RTS must  be high  to enable the external device to receive.
  212.  
  213.             Likewise CTS  and DSR  should be high to enable the COM port
  214.  
  215.             to transmit.
  216.  
  217.             
  218.  
  219.                  1.  DTR   Out  is  often  used  in  hardware  handshake
  220.  
  221.                  protocols  to   indicate  Data   Terminal  Ready.  Data
  222.  
  223.                  Terminal is  an old  term referring in this case to the
  224.  
  225.                  computer (PC).
  226.  
  227.                  
  228.  
  229.                  2. RTS  Out notifies  the external  device that the COM
  230.  
  231.                  port is Ready To Send.
  232.  
  233.                  
  234.  
  235.                  3. CTS  In is  the Clear To Send line. It is used often
  236.  
  237.                  in hardware handshake protocols with the DTR line.
  238.  
  239.                  
  240.  
  241.                  4. DSR In refers to Data Set Ready. It is often used to
  242.  
  243.                  inform a  Data Terminal  (or computer)  that a Data Set
  244.  
  245.                  (such as a modem) is ready to communicate.
  246.  
  247.                  
  248.  
  249.                  5. CD  In is  the Carrier Detect input from a modem. It
  250.  
  251.                  is asserted  when a  communications link is established
  252.  
  253.                  with another modem.
  254.  
  255.                  
  256.  
  257.  
  258.  
  259.             Fred E. Davis                                   26 June 1986
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.             An RS-232 Port Status Utility                              5
  269.  
  270.  
  271.                  6. RI  In refers  to Ring  Indicate from a modem. It is
  272.  
  273.                  used  primarily   for  auto-answer  operations  so  the
  274.  
  275.                  computer can accept incoming telephone calls (even on a
  276.  
  277.                  specific number of rings by counting RI transitions).
  278.  
  279.             
  280.  
  281.             C. Line Status
  282.  
  283.                  The four  Line Status  bits, Receive  Buffer,  Transmit
  284.  
  285.             Buffer, Break  Status and  Loop Back,  refer to the state of
  286.  
  287.             internal registers and a test function.
  288.  
  289.             
  290.  
  291.                  1. Receive  Buffer is  the register that holds incoming
  292.  
  293.                  data. When holding data that hasn't been read, a 'full'
  294.  
  295.                  message  will   be  displayed,  otherwise  it  will  be
  296.  
  297.                  'empty'.
  298.  
  299.                  
  300.  
  301.                  2. Transmit  Buffer holds  data to  be sent.  When  not
  302.  
  303.                  currently holding  information waiting  to be  sent  it
  304.  
  305.                  will indicate 'empty'; if data is waiting to be sent it
  306.  
  307.                  will show 'full'.
  308.  
  309.                  
  310.  
  311.                  3. Break  Status indicates  the presence  of a  'Break'
  312.  
  313.                  signal from  the sender. This often initiates some form
  314.  
  315.                  of interrupt to normal communications. (See A.6.)
  316.  
  317.                  
  318.  
  319.                  4. Loop  Back is  a special  state for internal testing
  320.  
  321.                  and verification  of hardware  and  register  function.
  322.  
  323.  
  324.  
  325.             Fred E. Davis                                   26 June 1986
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.             An RS-232 Port Status Utility                              6
  335.  
  336.  
  337.                  When 'set', the internal output registers are connected
  338.  
  339.                  to the  input registers  (and  vice  versa)  such  that
  340.  
  341.                  transmitted  data  is  immediately  received.  It  must
  342.  
  343.                  indicate 'normal' if communications are to take place.
  344.  
  345.             
  346.  
  347.             D. Error Status
  348.  
  349.                  The three  error  status  lines,  Overrun,  Parity  and
  350.  
  351.             Frame, are  set by  the COM  ports receiver  to  indicate  a
  352.  
  353.             communications problem.
  354.  
  355.             
  356.  
  357.                  1. Overrun  'set' means that another character has been
  358.  
  359.                  received before  the first one has been read by the PC.
  360.  
  361.                  A possible cause for this is a baud rate too high.
  362.  
  363.                  
  364.  
  365.                  2.  Parity   'set'  means   that  the   last  character
  366.  
  367.                  transmission was  corrupted somehow.  It  obviously  is
  368.  
  369.                  significant only  when parity checking has been enabled
  370.  
  371.                  (See  A.3.).  Possible  causes  can  be  noise  in  the
  372.  
  373.                  communications lines  or improper  parity polarity (odd
  374.  
  375.                  or even).
  376.  
  377.                  
  378.  
  379.                  3. Frame  errors occur  when a  character was  received
  380.  
  381.                  without a  valid  stop  bit.  Possible  causes  include
  382.  
  383.                  improper communications protocol (See A.).
  384.  
  385.                  
  386.  
  387.             E. Interrupt Status
  388.  
  389.  
  390.  
  391.             Fred E. Davis                                   26 June 1986
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.             An RS-232 Port Status Utility                              7
  401.  
  402.  
  403.                  Several  conditions   in  the   COM  port  cause  cause
  404.  
  405.             interrupts to the PCs Microprocessor to demand some service.
  406.  
  407.             The four  conditions are:  Received Data  Ready (See  C.1.),
  408.  
  409.             Transmit Buffer  Empty (See  C.2.), Line Status (See D.) and
  410.  
  411.             Modem Status (See B.).
  412.  
  413.             
  414.  
  415.                  1. Output  refers to  an interrupt  control signal that
  416.  
  417.                  can enable  or disable  all interrupt requests from the
  418.  
  419.                  COM port.  If interrupts  are to  be used, it must show
  420.  
  421.                  'enable'.
  422.  
  423.                  
  424.  
  425.                  2. Data Ready, if enabled, causes an interrupt when the
  426.  
  427.                  Received Data Buffer is full (See C.1.).
  428.  
  429.                  
  430.  
  431.                  3. Xmit Empty, if enabled, causes an interrupt when the
  432.  
  433.                  Transmit Data Buffer is empty and another character can
  434.  
  435.                  be sent.
  436.  
  437.                  
  438.  
  439.                  4. Line  Status would cause an interrupt, when enabled,
  440.  
  441.                  if C.1., C.2., C.3., D.1., D.2. or D.3. are asserted.
  442.  
  443.                  
  444.  
  445.                  5. Modem  Status, like Line Status, causes an interrupt
  446.  
  447.                  if B.3., B.4., B.5. or B.6 are asserted.
  448.  
  449.                  
  450.  
  451.             
  452.  
  453.                                    How RS works.
  454.  
  455.  
  456.  
  457.             Fred E. Davis                                   26 June 1986
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.             An RS-232 Port Status Utility                              8
  467.  
  468.  
  469.                  RS is  written in assembly language, which explains its
  470.  
  471.             small size. The speed limitation on its execution is imposed
  472.  
  473.             by the  BIOS and  DOS display  routines. RS  is not a memory
  474.  
  475.             resident program;  it does  not trap any interrupts; it uses
  476.  
  477.             only BIOS  and DOS display interfaces; it does not alter the
  478.  
  479.             port configuration.
  480.  
  481.                  After displaying  the  title  message,  RS  checks  the
  482.  
  483.             'command  tail'  (any  characters  entered  after  the  'RS'
  484.  
  485.             command) to  see if any arguments are being passed. If a '2'
  486.  
  487.             is present, RS will access COM2: starting at port 2F8h. If a
  488.  
  489.             '1', no  argument or an illegal value is passed, RS will use
  490.  
  491.             COM1: starting at port 3F8h.
  492.  
  493.                  RS then  reads all  of the  port registers  and buffers
  494.  
  495.             into temporary  RAM buffers  used by  RS. The  Line  Control
  496.  
  497.             Register is read, altered, and restored. RS checks to see if
  498.  
  499.             a port  really exists  there  by  verifying  the  read/write
  500.  
  501.             operation. Once  all the  registers are  read, RS then scans
  502.  
  503.             the values  in the  RAM buffers  to generate the messages to
  504.  
  505.             the display.  This minimizes  interruption of port activity.
  506.  
  507.             In the  case of  the baud  rate, RS  first compares the rate
  508.  
  509.             divisor to a table of standard values. If the port's rate is
  510.  
  511.             not found, the actual baud rate is calculated and displayed.
  512.  
  513.                  RS terminates  with a type 4Ch function call to DOS Int
  514.  
  515.             21h. If  the  program  executed  normally  a  value  00h  is
  516.  
  517.             returned. If  the COM port is not installed or functional, a
  518.  
  519.             value of 01h is returned.
  520.  
  521.  
  522.  
  523.             Fred E. Davis                                   26 June 1986
  524.  
  525.  
  526.  
  527.  
  528.