



















                                    D L M

                              An IBM P.C. Based
                             RS-232 Asynchronous
                              Data Line Monitor





                                 Release 1.9

                              Revised 25-Aug-06










                         Dunfield Development Systems
                         ----------------------------
                            High quality tools for
                             Embedded Development
                                at low prices.

                           http://www.dunfield.com


                      Copyright 1989-2005 Dave Dunfield
                             All rights reserved



                              Data Line Monitor

                              TABLE OF CONTENTS


                                                                        Page

    1. INTRODUCTION                                                        1

       1.1 What is DLM?                                                    2
       1.2 Hardware Required                                               2

    2. HARDWARE SETUP                                                      3

       2.1 IBM P.C. serial ports                                           3
       2.2 Passive Monitor Cable                                           4

    3. USING DLM                                                           5

       3.1 Begin data capture                                              5
       3.2 Review captured data                                            6
       3.3 Clear capture buffer                                            7
       3.4 RS-232 Signal monitor                                           7
       3.5 Serial port parameters                                          7
       3.6 Disk transfer functions                                         8
       3.7 Exit to DOS                                                     8

    4. COMMAND LINE OPTIONS                                                9


    5. DEBUGGING TIPS                                                     10

       5.1 Hardware Connections                                           10
       5.2 Speed and Data format                                          10
       5.3 Flow Control                                                   11

    6. FILE FORMAT                                                        13


    7. ASCII code chart                                                   14

   Data Line Monitor                                                Page: 1


   1. INTRODUCTION

         Have you ever been in the situation  where  you  have  two  serial
      devices  (such as a PC and a printer),  which SHOULD  work  but  just
      don't seem to communicate? Or perhaps you are trying to debug  a  new
      communications  protocol,  and  when  you  start  the  file  transfer
      everything just LOCKS UP!!!

         In such situations,  wouldn't it be nice to be able to SEE exactly
      what is happening over the RS-232 cable? To SEE when characters  were
      received in relation to characters going out?  To  SEE  flow  control
      characters and their effect? To SEE the modem carrier drop?

         Wouldn't it be nice to do  all  this  WITHOUT  spending  $5,000  -
      $10,000 on a commercial data scope?

         If your requirements are simple monitoring of ASYNCHRONOUS  RS-232
      serial communications, DLM (Data Line Monitor) is for you!!!

      Dunfield Development Services  (DDS)  offers  software  and  firmware
      development   services   specializing   in   systems   and   embedded
      applications. For more information, visit: http://www.dunfield.com

         DLM is provided on an "as is" basis, with no warranty of any kind.
      In no event shall the author be liable for any damages  arising  from
      its use or distribution.
   Data Line Monitor                                                Page: 2


      1.1 What is DLM?

            DLM is an easy to use DATA LINE MONITOR for use on the IBM P.C.
         It displays DTE and DCE data in a  split  line  format  (DTE  over
         DCE),  and records up to 32767 events  (characters  and/or  signal
         transitions)  in a circular buffer for later review (If the buffer
         overflows, the LAST 32767 events are available).

            Recorded data may be saved to disk,  allowing a problem  to  be
         captured in the field,  and the results viewed at another time and
         place.  Since the data is stored as a standard DOS file, it may be
         transmitted over a modem  and  viewed  (using  DLM)  at  a  remote
         location.  This allows an engineer at the main office  to  provide
         better (and faster) support to a technician in the field, since he
         can also SEE the problem.

            It supports ASYNCHRONOUS operation at speeds up to  57600  BPS;
         5,6,7 and 8 data bits; Even, Odd, Mark, Space and No parity; and 1
         or 2 stop bits.  The DTE configuration may be set independently of
         the DCE configuration for split speed/format operation.

            The configuration may also be saved to disk,  allowing  you  to
         have several "canned" setups for common situations.

            In addition to the data line monitor, DLM incorporates a SIGNAL
         MONITOR  (LIGHT BOX)  for real time  monitoring  of  the  hardware
         signals.

      1.2 Hardware Required

            All that is required to use DLM is an IBM P.C.  (or compatible)
         which has two serial  (COMM)  ports.  A special "Y"  adapter cable
         (described later)  must be constructed to allow monitoring of both
         DTE and DCE data.
   Data Line Monitor                                                Page: 3


   2. HARDWARE SETUP

         Before you use DLM, you must construct a special "Y" adapter cable
      which allows it to monitor  "both sides"  (DTE and DCE)  of a  single
      communications line using the IBM P.C. serial ports (COM1 and COM2).

      2.1 IBM P.C. serial ports

            The serial ports of the IBM P.C.  are RS-232 DTE configuration,
         and will be in either a 25 or 9 pin configuration.  The ports have
         the following pinout:

           Signal name                Origin   25-Pin(PC)  9-Pin(AT)
           ---------------------------------------------------------
           Transmit Data       (TXD)   DTE         2           3
           Receive Data        (RXD)   DCE         3           2
           Request To Send     (RTS)   DTE         4           7
           Clear To Send       (CTS)   DCE         5           8
           Data Set Ready      (DSR)   DCE         6           6
           Signal Ground       (GND)   ---         7           5
           Data Carrier Detect (DCD)   DCE*        8           1
           Data Terminal Ready (DTR)   DTE        20           4
           Ring Indicator      (RI )   DCE        22           9

       *   In order to be able to record this signal in data capture
           mode, DLM records it as if it were originated by the DTE.

            Note that since the PC serial port is  a  DTE,  it  drives  the
         signals with DTE origin, and monitors the signals with DCE origin.
         Therefore,  all connections to the line being monitored will be to
         the DCE signals of the COMM port.
   Data Line Monitor                                                Page: 4


      2.2 Passive Monitor Cable

            DLM monitors DTE data on COM1, and DCE data on COM2. Therefore,
         you must connect the input (DCE) lines from COM1 to the DTE origin
         signals on the monitored line, and the input (DCE) lines from COM2
         to the DCE origin signals.

            To do this,  you must construct  a  "Y"  adapter  cable,  which
         contains a set of "straight through" connectors which are inserted
         in the RS-232 line being monitored,  and also connects the DTE and
         DCE signals to the appropriate input (DCE)  pins on COM1 and COM2.
         Be sure to mark which COMM port each of the  two  "PC"  connectors
         connects to.  If you get  them  backward,  the  DTE/DCE  data  and
         signals will appear reversed.

            "Straight  through"                          "IBM PC"
          Line Monitor Connector                   COMM port connectors


               DB-25    Male                    /----- COM1 (Monitor DTE)
               | | | | | | |                   /
               +-+-+-+-+-+-+==================<
               | | | | | | |                   \
               DB-25  Female                    \----- COM2 (Monitor DCE)


       The signals must be connected as follows:

           Line   Pin          Port    25-Pin(PC)  9-Pin(AT)
           -------------------------------------------------
           TXD     2   ----    COM1        3           2
           RXD     3   ----    COM2        3           2
           RTS     4   ----    COM1        5           8
           CTS     5   ----    COM2        5           8
           DSR     6   ----    COM2        6           6
           GND     7   ----  COM1+COM2     7           5
           DCD     8   ----    COM1       22           9
           DTR    20   ----    COM1        6           6
           RI     22   ----    COM2       22           9
           Aux 1*  -   ----    COM1        8           1
           Aux 2*  -   ----    COM2        8           1

       *   These signals will be shown in "signal monitor" function,
           but will not be recorded in "data capture" function.
           You may use them to monitor any signals you like.
   Data Line Monitor                                                Page: 5


   3. USING DLM

         To set up DLM,  connect the  "straight through"  end  of  the  "Y"
      adapter cable to the line to be monitored, and the "PC" connectors to
      the appropriate COMM ports on the IBM P.C.

         Execute DLM from the DOS command line,  and you  will  be  greeted
      with The following menu:

                   +-------------------------+
                   | Begin data capture      |
                   | Review captured data    |
                   | Clear capture buffer    |
                   | RS-232 Signal monitor   |
                   | Serial port parameters  |
                   | Disk transfer functions |
                   | Exit to DOS             |
                   +-------------------------+

         Each of the above menu items is described below:

      3.1 Begin data capture

            This option causes DLM to begin monitoring the data  line.  Any
         data or signal transitions detected  are  displayed  in  a  "split
         line"  screen format  (in real time),  as well as recorded in  the
         circular capture buffer.

            The data stream appears in pairs of two lines  on  the  screen.
         DTE data DTE data appears on the upper line,  and  DCE  data  will
         appears below the line.  A cursor is displayed below the line pair
         indicating where the next data item will be displayed.

            Signal transitions and line errors are displayed as an  "arrow"
         which points UP if the event was from the DTE,  and  DOWN  if  the
         event was from the DCE.  One exception to this is the  DCD  signal
         which occurs from the DCE,  but is recorded by DLM as if  it  were
         from the DTE.  This is because each "direction" (DTE/DCE) may only
         have three  (3)  signals recorded in the capture buffer.  The  DCE
         signals are DSR, CTS and RI; The DTE signals are DTR, RTS and DCD.
         The exact signal or error occurring may be  displayed  in  "Review
         captured data".

            Press ESCAPE at any time to exit this function,  and return  to
         the main menu.
   Data Line Monitor                                                Page: 6


      3.2 Review captured data

            In this function,  the same  "split line"  screen as  above  is
         displayed,  however it shows data  previously  captured.  You  may
         press F1 to toggle between the ASCII display,  and a HEX  display,
         in which the data values  are  displayed  in  HEX  (occupies  both
         lines), and the DTE data in hilighted.

            The ARROW keys may be  used  to  move  the  cursor  around  the
         display.  The PGUP and PGDN keys may be used to advance and backup
         by entire screens.  The HOME key returns you to the  beginning  of
         the buffer,  the END key positions you on the last  entry  in  the
         buffer.

            When the cursor is positioned under an entry, it will contain a
         'T' for entries originating from the DTE,  or 'C'  indicating that
         the entry originated from the DCE  (In most  cases  this  will  be
         obvious since data will be shown in the upper (DTE) or lower (DCE)
         line).

            The time stamp of the entry is shown near  the  center  of  the
         status line at the top of the screen.  This  marks  the  time  (in
         seconds)  at which this entry occurred relative to the first entry
         in the buffer.  Note  that  although  the  display  shows  1/100th
         seconds,  the actual resolution of  the  timer  is  approx  1/18th
         second.  Also,  the timestamp wraps to  zero  after  3640  seconds
         (slightly over one hour).

            The hex value of the data under the  cursor  is  shown  to  the
         right of the timestamp,  and to the right of that are  four  "data
         flags":

               F   - Framing error
               P   - Parity error
               O   - Overrun error
               D   - Data is present

            To the right of that, three signals will be shown:

                  DTE             DCE
               ---------       ---------
               X   - DCD       X   - RI
               T   - DTR       S   - DSR
               R   - RTS       C   - CTS

            At the extreme right side of the status line will be shown  two
         numbers.  The first is the current position in the capture buffer,
         and the second is the total  number  of  entries  in  the  capture
         buffer.

            Press ESCAPE at any time to exit this function,  and return  to
         the main menu.
   Data Line Monitor                                                Page: 7


      3.3 Clear capture buffer

            This function  removes  any  data  which  has  been  previously
         recorded from the  "capture"  buffer.  It is useful to remove  old
         data before starting a new monitoring session,  otherwise any  new
         data will be appended to the old data already in the buffer.

            When you execute this function,  DLM  displays  the  number  of
         entries currently residing in the capture buffer.  Press ENTER  to
         clear the buffer, or ESCAPE to exit and leave it unchanged.

      3.4 RS-232 Signal monitor

            This function provides a  "light-box",  which shows all of  the
         hardware signals being monitored (DTR, DSR, RTS, CTS, DCD, RI, AS1
         and AS2).  Each signal has a "light" which will be ON  (white)  if
         the signal is asserted,  and OFF  (dark)  if  the  signal  is  not
         asserted.

            Changes  occurring  in  the  signal   states   are   shown   in
         "real-time",  so that the display always reflects the actual state
         of the line signals.

            Press ESCAPE at any time to exit this function,  and return  to
         the main menu.

      3.5 Serial port parameters

            This function allows you to set the speed and  data  format  of
         the ports monitoring DTE  and  DCE  data.  In  order  for  DLM  to
         correctly monitor the data line,  these parameters must be set  up
         the same as the devices being monitored.

            Sub-menus are provided which allow you to set both the DTE  and
         DCE parameters simultaneously, or individually. Most modern serial
         communications operate the DTE and  DCE  at  the  same  speed  and
         format.

            Press ESCAPE at any time to exit each menu level, and return to
         the next higher menu.
   Data Line Monitor                                                Page: 8


      3.6 Disk transfer functions

            This function provides you with a sub-menu, which allows you to
         load/save configuration or captured data to/from disk files:

                   +--------------------+
                   | Load Data Image    |
                   | Load Configuration |
                   | Save Data Image    |
                   | Save Configuration |
                   +--------------------+

            Once you select a transfer operation,  you will be prompted for
         a file name. The following special keys may be used:

           Left arrow      - Move to left
           Right arrow     - Move to right
           Home            - Move to beginning of name
           End             - Move to end of name
           PgUp            - Clear entire field
           PgDn            - Clear from cursor to end of field
           ESC             - Cancel and return to higher menu
           ENTER           - Accept filename & perform operation

      3.7 Exit to DOS

            This function terminates DLM,  and returns to the  DOS  command
         prompt.
   Data Line Monitor                                                Page: 9


   4. COMMAND LINE OPTIONS

         DLM accepts the following options on the command line when  it  is
      started:

           DTE=1-4   - Specify DTE COM port number (COM1-COM4)
           DTE=5+    - Specify DTE COM port address in HEX (5-FFFF)
           DTE!      - Disable DTE monitoring (Requires no DTE port)

           DCE=1-4   - Specify DCE COM port number (COM1-COM4)
           DCE=5+    - Specify DCE COM port address in HEX (5-FFFF)
           DCE!      - Disable DCE monitoring (Requires no DCE port)

           /R        - Review mode - no COM ports - same as DTE! + DCE!

           A=xx      - Specify video attribute used for the display
                       of DTE data when reviewing in HEX mode. This
                       attribute is used to differentiate the DTE from
                       the DCE data (displayed in normal video). The
                       default is 0F, which displays the DTE data as
                       intensified. To see the effect of various video
                       attribute values on your PC, please run the
                       VIDEO.COM utility program provided.

           C=file    - Loads a previously saved DLM configuration.

           F=file    - Loads a DLM VGA font from the specified file, and
                       uses it when Capturing/Reviewing data. The following
                       optional font files are provided with DLM:
                         CONTROL.DLF - Shows 00-1F as two letter words
                         HEX.DLF     - Shows 00-1F,7F-FF as HEX values
                       You may create and customize your own fonts with
                       the supplied DLMFE.COM program.

                       NOTE! DLM FONTS WORK ONLY WITH VGA DISPLAYS!

                       Also note: DLM uses standard VGA (16 line) fonts.
                       Some video systems (noteably laptops) have "stretch"
                       modes which use custom fonts having more lines. If
                       more than 16 lines are found in the active font, DLM
                       will attempt to stretch its fonts to match. If you
                       experience font problems on such a system, try turning
                       off any special modes and using standard VGA text.

                       Finally: ALLHEX.DLF is a special all-hex display font
                       which works with MDLM's dual character set mode only.
                       It does not provide a meaningful display with DLM.

           M=xx      - Specify a mask value (hex) to be ANDed with each
                       character before it is displayed. Most commonly
                       used to remove the high bit from ASCII data (M=7F).
   Data Line Monitor                                                Page: 10


   5. DEBUGGING TIPS

         Here  are  several  common  problems  which  occur   with   serial
      communications,  and information on how you could use DLM to diagnose
      them:

      5.1 Hardware Connections

            You can easily check out the  hardware  signals  by  using  the
         "RS-232 Signal monitor".

            Connecting the DTE to the monitor cable should "raise"  the DTR
         and RTS signals.  If this is not the case, either your connections
         are incorrect, or the DTE device is not online properly.  (In some
         rare cases this may be a normal state for the device).

            Connecting the DCE to the monitor cable should "raise"  the DSR
         and CTS signals.  If this is not the case, either your connections
         are incorrect,  or the DTE device is not online properly.  (RI and
         DCD are not always ON,  so you  can't  expect  them  to  be  in  a
         particular state).

            Once you get the above signals correctly connected,  switch  to
         "Begin data capture".

            Data transmitted from the DTE should appear  ABOVE  the  dashed
         separating line, data transmitted from the DCE should appear BELOW
         the line.

      5.2 Speed and Data format

            If the speed of the two sending and receiving  devices  is  not
         the same, no communication will occur.  Assuming you know what the
         speed SHOULD be,  it is easy to recognize  data  at  an  incorrect
         speed with DLM.

            Capture a good sample of ASCII data with DLM set to  the  speed
         and format which you think the communication should  be  occurring
         at, and then look at it in review mode.

            If the data  completely  readable,  the  speed  and  format  is
         correct.

            If the data is partly legible, but about half of the characters
         seem to be corrupted, the speed is correct, but you have incorrect
         PARITY.

            If the data is completely unreadable, examine the HEX values of
         several characters (by moving the cursor and looking at the status
         line).  If the data has the high bit set (80-FF),  check to see if
         it would be readable without the high bit  set.  If  this  is  the
         case, the speed is correct, but the data format (Data bits/Parity)
         is incorrect. DATA BITS is the most likely suspect.
   Data Line Monitor                                                Page: 11


            If the above test does not reveal any readable data,  the speed
         is probably incorrect.  This will also manifest itself with "lots"
         of 'F'raming and 'O'verrun errors.

      5.3 Flow Control

            Many  modern  devices  are  not  capable  of   receiving   data
         continuously at the highest speeds supported on the interface.  An
         example of this is a  printer  which  prints  200  Characters  per
         second (CPS),  and has a serial interface running at 9600 bits per
         second which is about 960 CPS.

            Such devices usually have an  internal  buffer,  which  absorbs
         data at full speed,  and stores it so that it can be printed at  a
         slower speed.  When this buffer approaches being full, the printer
         will assert FLOW CONTROL on the sending device, which causes it to
         stop sending data until it is later instructed to proceed.

            If flow control is not working properly,  the usual symptom  is
         that the first few lines of data are  correctly  received  by  the
         device, after which symptoms vary from "lost data" to "lock up".

            There are two common forms of flow control,  one uses  hardware
         signals,  and is called HARDWARE  FLOW  CONTROL.  The  other  uses
         reserved data characters, and is called SOFTWARE FLOW CONTROL.

         5.3.1 Hardware Flow Control

               With  HARDWARE  flow  control,  the  receiving  device  will
            deassert  one  of  its  hardware  output  leads   (DTE=DTR/RTS,
            DCE=DSR/CTS)  to inform the sender to stop sending.  When it is
            ready to receive more data,  it will reassert the  signal,  and
            transmission will proceed.

               Using DLM,  you can monitor the hardware signals during data
            transmission, and see if one of them is lowered to perform flow
            control.  You can also see if the sending devices  responds  to
            the flow control  (stops sending),  and how quickly it responds
            (by noting how  many  characters  are  sent  after  the  signal
            drops).

               If the signal dropping appears to have no effect on the data
            stream,  then you know that hardware flow control is not  being
            recognized or acted upon.
   Data Line Monitor                                                Page: 12


         5.3.2 Software Flow Control

               With SOFTWARE flow control, the receiving device transmits a
            character to the sending device to command it to stop  sending.
            This character is usually CONTROL-S ($13).  When it is ready to
            receive more data,  a different character is transmitted.  This
            character is usually CONTROL-Q ($11).

               Using DLM,  you  can  monitor  the  data  to  and  from  the
            receiving device,  and check for flow control  characters.  You
            can also see if the sending device responds to the flow control
            (stops sending), and how quickly is responds (by noting how may
            characters are sent after the CONTROL-S is received).

               If a CONTROL-S is transmitted,  and it appears  to  have  no
            effect on the data stream,  then you know  that  software  flow
            control is not being recognized or acted upon.
   Data Line Monitor                                                Page: 13


   6. FILE FORMAT

         This section describes the format of the data file which is  saved
      by the "Save Data Image" function, should you have need to manipulate
      this data from an external program.

         The image file is 131080 bytes in size,  which contains  65540  16
      bit entries.  Each entry is stored in Little Endian format (the least
      significant byte occurs first).  The meaning of  the  entries  is  as
      follows:

         Entry        Address              Description of entry
       --------------------------------------------------------------------
           1        (0000-0001)    Pointer to start of valid data in buffer
           2        (0002-0003)    Pointer to end of valid data in buffer
           3        (0004-0005)    Status of DTE at end of last capture
           4        (0006-0007)    Status of DCE at end of last capture
          5-32772   (0008-10007)   Data buffer (see below)
      32773-65538  (10008-32770)   Time-Stamps (DOS timer tick count)

         The start and end pointers indicate the area of valid data in  the
      circular data buffer.  To read the entire buffer content,  you should
      begin reading at an offset into the  data  buffer  indicated  by  the
      start pointer,  and read each  entry,  wrapping  at  64K  bytes  (32K
      entries)  back to the beginning,  and continuing until you reach  the
      offset in the end pointer.

         The DTE/DCE status entries are used internally by DLM,  and should
      be ignored.

         Each data buffer entry has the following format:

         Bit(s)                  Description
         --------------------------------------------------------
           15  - Framing error has occurred
           14  - Parity  error has occurred
           13  - Overrun error has occurred
           12  - Data byte is available for this entry (bits 7-0)
           11  - 0=Entry applies to DTE, 1=Entry applies to DCE
           10  - DCD/RI  signal status
            9  - DTR/DSR signal status
            8  - RTS/CTS signal status
          7-0  - Data if Bit12=1, otherwise undefined
   Data Line Monitor                                                Page: 14


   7. ASCII code chart





                            Most Significant Figure

             HEX||  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |
             ===++=====+=====+=====+=====+=====+=====+=====+=====+
              0 || NUL | DLE |     |  0  |  @  |  P  |  `  |  p  |
             ---++-----+-----+-----+-----+-----+-----+-----+-----+
              1 || SOH | DC1 |  !  |  1  |  A  |  Q  |  a  |  q  |
         L   ---++-----+-----+-----+-----+-----+-----+-----+-----+
         e    2 || STX | DC2 |  "  |  2  |  B  |  R  |  b  |  r  |
         a   ---++-----+-----+-----+-----+-----+-----+-----+-----+
         s    3 || ETX | DC3 |  #  |  3  |  C  |  S  |  c  |  s  |
         t   ---++-----+-----+-----+-----+-----+-----+-----+-----+
              4 || EOT | DC4 |  $  |  4  |  D  |  T  |  d  |  t  |
         S   ---++-----+-----+-----+-----+-----+-----+-----+-----+
         i    5 || ENQ | NAK |  %  |  5  |  E  |  U  |  e  |  u  |
         g   ---++-----+-----+-----+-----+-----+-----+-----+-----+
         n    6 || ACK | SYN |  &  |  6  |  F  |  V  |  f  |  v  |
         i   ---++-----+-----+-----+-----+-----+-----+-----+-----+
         f    7 || BEL | ETB |  '  |  7  |  G  |  W  |  g  |  w  |
         i   ---++-----+-----+-----+-----+-----+-----+-----+-----+
         c    8 || BS  | CAN |  (  |  8  |  H  |  X  |  h  |  x  |
         a   ---++-----+-----+-----+-----+-----+-----+-----+-----+
         n    9 || HT  | EM  |  )  |  9  |  I  |  Y  |  i  |  y  |
         t   ---++-----+-----+-----+-----+-----+-----+-----+-----+
              A || LF  | SUB |  *  |  :  |  J  |  Z  |  j  |  z  |
         F   ---++-----+-----+-----+-----+-----+-----+-----+-----+
         i    B || VT  | ESC |  +  |  ;  |  K  |  [  |  k  |  {  |
         g   ---++-----+-----+-----+-----+-----+-----+-----+-----+
         u    C || FF  | FS  |  ,  |  <  |  L  |  \  |  l  |  |  |
         r   ---++-----+-----+-----+-----+-----+-----+-----+-----+
         e    D || CR  | GS  |  -  |  =  |  M  |  ]  |  m  |  }  |
             ---++-----+-----+-----+-----+-----+-----+-----+-----+
              E || SO  | RS  |  .  |  >  |  N  |  ^  |  n  |  ~  |
             ---++-----+-----+-----+-----+-----+-----+-----+-----+
              F || SI  | US  |  /  |  ?  |  O  |  _  |  o  | DEL |
             ---++-----+-----+-----+-----+-----+-----+-----+-----+
