home *** CD-ROM | disk | FTP | other *** search
/ PC-Test Pro / PCTESTPRO.iso / commtls / comtst / entp / testport.doc < prev   
Encoding:
Text File  |  1994-10-25  |  24.3 KB  |  505 lines

  1.         Copy(c)right 1986,1994 by Gary Raymond, New Orleans, La.
  2.                 Port Modem Register Test Program V1.1
  3.  
  4.                            Gary Raymond
  5.                              POB 8184
  6.                       New Orleans, La. 70182
  7.                           (504) 288-6550
  8.                        Compuserve 70613,3165
  9.  
  10.  
  11.  
  12.    Files Provided:
  13.    ====================================================================
  14.  
  15.    TESTPORT.COM   Serial Port Test Utility.
  16.    TESTPORT.DOC   This document.
  17.  
  18.    TestPort will run on just about any version of DOS and with any
  19.    amount of RAM. If nothing else, TestPort will assist you in learning
  20.    more about serial communications and understanding your modem. Having
  21.    written and supported several terminal programs over the past seven
  22.    years, I have long ago realized that most problems involving terminal
  23.    software are actually modem or modem configuration problems. This
  24.    utility should take some of the mystery away from configuring,
  25.    understanding, and diagnosing serial communications hardware. If for
  26.    no other reason than curiosity, you owe it to your modem to use
  27.    TestPort at least once and read through this file.
  28.  
  29.    ====================================================================
  30.    TestPort is a basic, easy to use, modem diagnostic tool. Although the
  31.    information TestPort provides will at first be seemingly cryptic to
  32.    the novice user, it can easily be learned and put to good use.  Bit
  33.    mapping the modem registers provides a wealth of information about
  34.    the state of your modem. Your modem is both configured and monitored
  35.    through these registers or electronic switches. Everything from baud
  36.    rate to data parity is determined by the one (on) or zero (off) bit
  37.    settings in these registers. Particular register bits are also used
  38.    to inform the terminal program that a character has arrived or is
  39.    ready to be transmitted along with numerous other useful information.
  40.  
  41.    According to the IBM scheme of things, you could have as many as
  42.    65,536 port addresses. These ports have an address in the hardware
  43.    set up according to IBM's scheme. Each address points to a one byte
  44.    location called a base address. Since we can both set and retrieve
  45.    bits in these bytes we refer to them as maskable base registers. Each
  46.    of the next subsequent nine bytes (BASE+1, BASE+2 etc) form that
  47.    ports general register set as outlined in the text below. Serial
  48.    communication ports begin with COM Port number one (COM1) with an
  49.    address assigned by IBM as decimal 1016 or 3F8 hex. Hence, the
  50.    address for the COM1 port register is 3F8. This is the place where a
  51.    byte of data is received (3F8 - Received Data Register) or sent (3F8
  52.    - Transmitter Holding Register) depending on requirements at the
  53.    moment. Therefore the base address allows indirect access to both the
  54.    THR and RDR (plus BRDL when bit 7 of LCR is set). The next register
  55.    (the IER) is located at this base address plus one, (3F8 + 1 = 3F9)
  56.    and so on.
  57.  
  58.    There are two general methods of obtaining bytes of data from a
  59.    serial port after it has been set up. The first involves stopping
  60.    every so often and looking to see if a byte has arrived, and if so,
  61.    taking it. This method of polling the modem registers is ok when
  62.    working at very slow baud rates. Polling is the method used by the
  63.    PC's Basic Input Output Service (BIOS firmware.) Unfortunately, if a
  64.    byte of data arrives before we have had a change to remove the
  65.    previous one, information can be lost. To overcome this drawback of
  66.    polling we can force the PC to react to the arrival of a byte by
  67.    removing and saving it in a special storage area until we have time
  68.    to use it. This is done by designing a special Interrupt Service
  69.    Routine (ISR) that will be activated instantly (no matter what else
  70.    the PC may be doing) to collect and store the byte of data. This is
  71.    referred to as an "interrupt on receive" terminal program, such as
  72.    our product, SLICK terminal.
  73.  
  74.    There are many things that can go wrong when installing a modem
  75.    on your computer. Usually, problems are evenly divided between
  76.    hardware and software configuration errors. In general, the modem
  77.    itself must be mechanically set, via jumper pins or dip switches,
  78.    to address whatever available serial port is usable on your PC.
  79.    The selected port must also be paired with an interrupt request line
  80.    (IRQ). Note, no two serial devices (examp: modem and mouse) may share
  81.    actively the same serial port IRQ address. Some modems force, or
  82.    allow you to force, certain register bits either high (1) or low (0)
  83.    in lieu of preferred software control. TestPort is useful in
  84.    EXAMINING all of the register settings that occur as a results of
  85.    these various configurations. Improper configuration of software is
  86.    another problem. Here, there are generally three areas of trouble.
  87.    Improper comm port, interrupt and modem command (initialization)
  88.    string settings. So, to review, One: the serial services must first
  89.    be available on the PC. Two: both the modem and terminal software
  90.    must agree in settings with the PC hardware you are attempting to
  91.    access. And finally, the modem initialization command string must
  92.    correctly complete the job of setting any other registers that
  93.    require attention, such as setting FAX mode on or off, hardware error
  94.    correction enabled or disabled, etc. etc. For what its worth, just
  95.    one wrong AT command in the string will cause the entire string to
  96.    FAIL. So, if your particular brand modem does not use &D1 (set dtr)
  97.    as an example, and, it is inserted into your complete string, such as
  98.    ATM1S0=0V1X4&D1S7=45, then the entire string will fail returning an
  99.    error message, leaving your modem still waiting to be configured.
  100.  
  101.    ====================================================================
  102.    USING TestPort's register mapping ability:
  103.  
  104.    To run TestPort with mapping action, you must pass the active port
  105.    number via a command parameter. TestPort will work on the four
  106.    standard IBM default ports of 1 (3F8), 2 (2F8), 3 (3E8), and 4 (2E8).
  107.    Let's assume your modem is configured to operate using COM2. Type
  108.    TESTPORT 2 at the DOS prompt. In most cases, you will really want to
  109.    do this while your terminal program is active. You do this by
  110.    dropping to DOS from within your terminal program, then executing
  111.    TestPort. Most all Terminal programs have a drop to DOS feature,
  112.    although it might be called something else. TestPort does a passive
  113.    read only on these registers and therefore will in no way alter or
  114.    change their bit settings. By using the drop to dos feature, which
  115.    allows the modem code to remain loaded in ram, you eliminate the
  116.    possibility that any modem registers will be inadvertently altered,
  117.    by your terminal program, before you get to read the registers. Some
  118.    terminal programs also have features that allow the naming and
  119.    execution of any external dos utility via a combination of trigger
  120.    hot keys. This is a MUCH better way of quickly running TestPort.
  121.    Don't forget in either case to pass the active port number in use.
  122.    (i.e. TESTPORT 2.)  If TestPort is executed as an external utility,
  123.    screen output data will remain until a key is pressed. This will give
  124.    you opportunity to hit Shft PrtSc and save a copy of the screen to
  125.    your printer for evaluation and analysis. If you do not have a
  126.    printer, you should make a long hand record on paper.
  127.  
  128.    USING TestPort's UART finder:
  129.  
  130.    Running TestPort without a port parameter will cause TestPort to
  131.    cycle through the four common UART addresses looking for an active
  132.    (U)niversal (A)synchronous (C)ommunications (C)ontroller. (8250 IC)
  133.    If active port addresses are located, TestPort will notify you of
  134.    those that appeared active. Notice, I said appeared active. It is
  135.    possible to have two serial ports but only one terminated to a
  136.    modem. The other may be just a jack on the rear of your PC, there
  137.    for some later expansion. A simple serial card with its open jack
  138.    will still show as an active port.
  139.  
  140.    Screen Output:
  141.    ------------------------------------------------------------------------
  142.    The Correct Syntax is TESTPORT #, (# to test), i.e. TESTPORT 4,
  143.    however, TestPort will now try to determine what if any serial
  144.    port is responding to TestPort's Inquiries....................
  145.  
  146.    COM1 appears to have an active UART!
  147.    COM2 appears to be inactive.
  148.    COM3 appears to be inactive.
  149.    COM4 appears to have an active UART!
  150.  
  151.    Enter Port# to test or Esc to exit ->
  152.  
  153.    In five seconds type AT <Enter>, active port will echo OK or 0, else Esc!
  154.    ------------------------------------------------------------------------
  155.  
  156.    Although this kind of information is by far un-conclusive, it does
  157.    give you enough insights to continue experimenting. In the case of
  158.    the information given above, the modem must be attached to either
  159.    COM1 or COM4. To determine which it is, try entering 1 first. If
  160.    there is no echoing of your keystroke or an OK reply to AT (the modem
  161.    attention command) the probability is COM1 is not the port connected
  162.    to your modem. Now try 4. This should test ok! More than likely, COM1
  163.    is an extra, as of yet unused, serial adapter.
  164.  
  165.    Although this testing facility is only a raw polling terminal, set to
  166.    1200 baud, N81, it can easily be used for simple task, like dialing
  167.    out to test other modems etc. Try typing ATH1 and see if you hear
  168.    your modem take the line off hook....ATH0 to replace it. Fun hun?
  169.  
  170.    ====================================================================
  171.    SCREEN GENERATED BY TESTPORT when mapping registers:
  172.  
  173.    When TestPort is run, it produces the following screen, indicating
  174.    the various one byte registers that have been read, their decimal,
  175.    hex, and (binary) bit map values. It's those bit settings you are
  176.    most interested in. The two indirect registers (THR and RDR) read
  177.    via the base register are not useful here. However, those two plus
  178.    the eight indicated account for the 10 registers of a UART chip.
  179.  
  180.          *******************************************************
  181.                 Modem Register Bit Map by Gary Raymond
  182.                         Phone (504) 288-6550
  183.  
  184.          Modem Registers     Dec Value    Hex Value     Bit Map
  185.                                                         76543210
  186.          IER (Int Enable)             0           00    00000000
  187.          IIR (Int ID)                 1           01    00000001
  188.          LCR (Line Control)           3           03    00000011
  189.          MCR (Modem Cont)             8           08    00001000
  190.          LSR (Line Status)           97           61    01100001
  191.          MSR (Modem Status)          48           30    00110000
  192.          BRDL (Low Register)          6           06    00000110
  193.          BRDH (Hi  Register)          0           00    00000000
  194.          *******************************************************
  195.  
  196.  
  197.          Hit Any Key to Exit!
  198.  
  199.  
  200.  
  201.    NOTE: Bit positions are read left to right, starting with position
  202.          0 (zero) and ending with 7. This accounts for a full byte of
  203.          eight bits.
  204.  
  205.    ====================================================================
  206.    SAMPLE USES for TESTPORT:
  207.  
  208.    Q) My modem wont hang up, what do I look for?
  209.    A) Look at bits 0 and 1 of MCR after starting your terminal program
  210.       but before dialing a number. They should both be set to 1. If not
  211.       check to see if your modem requires external dip switch settings
  212.       to force DTR, RTS or software AT commands like &D2 and &C1.
  213.  
  214.    Q) How can I tell if my terminal program is interrupt driven or
  215.       a polling BIOS type?
  216.    A) Look at bit 0 of IER, it will be set to 1 if the terminal is
  217.       interrupt driven. Also, bit 3 of MCR is usually set to 1 as
  218.       well. These bits are set to 0 (zero) in a polling terminal.
  219.  
  220.    Q) My modem wont respond on COM2.
  221.    A) Run TESTPORT 2. If If you see each modem register returning FF hex
  222.       (dec 255 or 11111111 binary) odds are this port is not activated
  223.       correctly via pin or dip settings on the modem card. Check your
  224.       modem manual for correct pin or dip switch settings.
  225.  
  226.    Q) How can I tell what Baud rate my modem is locked at?
  227.    A) First, run TestPort and obtain the BRDL and BRDH register values.
  228.       Then cross reference them with the Baud Rate Value chart in this
  229.       document file.
  230.  
  231.    Q) Can I use TestPort to place a call to a BBS?
  232.    A) Yes, but it's VERY limited as a polling terminal and not intended
  233.       for that kind of application. No protocols, no dial directory, no
  234.       no nothing, just a bare foot terminal!
  235.  
  236.    Q) My modem and software configured for COM3 is brain dead, can
  237.       TestPort help?
  238.    A) You bet! Some serial communications software, especially tsr type,
  239.       use BIOS services for communicating with the serial ports. BIOS
  240.       then depends on DOS to insert the correct port addresses into the
  241.       BIOS area of memory. Some versions of DOS fail to place the
  242.       default addresses for COM3 and COM4 in the required BIOS area of
  243.       memory. TestPort overcomes this limitation by poking ALL of the
  244.       IBM default addresses (3F8 - 2F8 - 3E8 - 2E8) into the correct
  245.       area of bios memory starting at segment 0040. This feature is
  246.       automatic anytime you run TestPort in any mode. To cancel out
  247.       these values, you only need reboot the PC. I will also provide a
  248.       seperate utility (PCA.COM) that can be used via your autoexec.bat
  249.       to insure these addresses are always available after bootup.
  250.  
  251.    Q) My terminal program has a host mode that allows remote access to
  252.       DOS via a redirection statement in a batch file. Only guess what?
  253.       It locks up my computer. Can TestPort help me?
  254.    A) Well, maybe. There are many computers (clones or otherwise) that
  255.       just do not take kindly to re-direction. (CTTY COM1 or CTTY > AUX1
  256.       type calls) If the reason is due to the problem outlined in the
  257.       answer above, TestPort or PCA will solve it. If not, there is
  258.       a device driver in the public domain called GateWay that usually
  259.       will accept re-direction. It can be found on most BBS'es. One
  260.       nice thing about GateWay is it still allows access to the host
  261.       keyboard and monitor; simple re-direction does not.
  262.  
  263.    Q) Can I use TestPort to see the default and or active settings
  264.       of all registers in my modem?
  265.    A) Yes, actually, you can do that with any terminal program. To use
  266.       TestPort, type TESTPORT at the dos prompt. Select the active port
  267.       number and wait five seconds for the terminal to respond. Type
  268.       AT&V then hit enter. On some older modems you cannot dump the
  269.       entire register set and you must poll each individually. Say
  270.       you want to see the present value in S7, type ATS7? and so on.
  271.  
  272.    Q) My old modem had a volume control on the card. My new one does
  273.       not. Can TestPort save my marriage and turn down the volume?
  274.    A) Yes, and again, it can also be done with your present terminal.
  275.       By default most modems allow the speaker on at full volume. You
  276.       can control this by resetting the M and L registers. ATM1 will
  277.       turn off the sound after a connect and ATL0 will reduce the volume
  278.       to the lowest setting. Of cource, these switches belong together
  279.       in your initialization command string. (ATM1L1etc.etc.etc.)
  280.  
  281.    ====================================================================
  282.    MODEM REGISTER BIT MAP DATA:
  283.  
  284.        For general purpose information, the port addresses of
  285.        these registers are as follows:
  286.  
  287.        BASE = COMPORT ADDRESS  (COM1 = 3F8h)
  288.        Therefore, MCR for COM1 equals 3F8h + 4 or 3FCh
  289.  
  290.        Ten Modem Registers
  291.        ---------------------------------------------
  292.        THR,RDR, *BRDL =  BASE
  293.        IER,     *BRDH =  BASE  + 1  ;  Interrupt Enable Register
  294.        IIR            =  BASE  + 2  ;  Interrupt Identification Register
  295.        LCR            =  BASE  + 3  ;  Line Control Register
  296.        MCR            =  BASE  + 4  ;  Modem Control Register
  297.        LSR            =  BASE  + 5  ;  Line Status Register
  298.        MSR            =  BASE  + 6  ;  Modem Satus Register
  299.        ---------------------------------------------
  300.                 *requires bit 7 set to 1 in LCR for access
  301.    ====================================================================
  302.  
  303.        IER  BIT MAPPING   (Interrupt Enable Register)
  304.        ---------------------------------------------
  305.        BIT     Activates             Action
  306.        0    =  Data Received         Read RDR
  307.        1    =  THR empty             Output to THR
  308.        2    =  Data error/break      Read LSR
  309.        3    =  MSR change            Read MSR
  310.        4    =  zero
  311.        5    =  zero
  312.        6    =  zero
  313.        7    =  zero
  314.  
  315.        Although the 8250 Uart has 10 one byte registers, only seven have
  316.        direct access, and of the seven, three of these are used
  317.        redundantly to gain access to the three non directly accessible
  318.        registers. This indirect access is achieved by setting bit 7 of
  319.        LSR to 1. Then, the BRDL and BRDH registers are accesses at BASE
  320.        and BASE + 1. These two registers are used to lock the port baud
  321.        rate. The BRD (Baud Rate Divisor) is a 16 bit number (two bytes)
  322.        and therefore requires two (one byte) register access through
  323.        BASE and BASE + 1. Interesting enough, the high byte is only
  324.        necessary for baud rates of 300 or below. At 1200 or higher BRDH
  325.        is set at zero. The formula for calculating the BRD value
  326.        demonstrates why.
  327.  
  328.                       UART CLOCK SPEED (1.8432mhz)
  329.               BRD =   ----------------------------
  330.                       16 x bit transfer rate (not really baud)
  331.  
  332.                       1,843,200
  333.               BRD =   ---------   =   256 or    110000000  or 100h
  334.                       16 x 300
  335.                                                 B   B
  336.                                                 R   R
  337.                                                 D   D
  338.                       breaking the result into  H   L
  339.                       two bytes produces =      1 & 1000000
  340.  
  341.                       where BRDH = 1hex and BRDL = 80h (128 dec)
  342.  
  343.               FOR 1200 BAUD:
  344.  
  345.                       1,843,200
  346.               BRD =   ---------   =   96 or    1100000  or 60h
  347.                       16 x 1200
  348.                                                 B   B
  349.                                                 R   R
  350.                                                 D   D
  351.                       breaking the result into  H   L
  352.                       two bytes produces =      0 & 1100000
  353.  
  354.                       where BRDH = 0hex and BRDL = 60h (96 dec)
  355.  
  356.  
  357.        The THR (Transmit Holding Register) and RDR (Received Data Register)
  358.        are accessed via the same physical address as the port base address.
  359.        Since you cannot in theory send and receive at the same instant, this
  360.        little scheme seems ok.
  361.  
  362.  
  363.  
  364.        IIR  BIT MAPPING   (Interrupt Identification Register)
  365.        ---------------------------------------------
  366.        BIT
  367.        0    =  more than 1 intr has occurred
  368.  
  369.                12                       12
  370.        1-2  =  00  change in MSR        10    data received
  371.                01  THR empty            11    recv error/break
  372.  
  373.        3    =  zero
  374.        4    =  zero
  375.        5    =  zero
  376.        6    =  zero
  377.        7    =  zero
  378.  
  379.  
  380.        LCR  BIT MAPPING   (Line Control Register)
  381.        ---------------------------------------------
  382.        BIT                      01                 01
  383.        01   =  Data Length      00=5bits           10=7bits
  384.                                 01=6bits           11=8bits
  385.  
  386.        2    =  Stop Bits        0=1bit             1=2bits
  387.  
  388.                                 345                345
  389.        345  =  Parity           000=NONE           101=MARK
  390.                                 100=ODD            111=SPACE
  391.                                 110=EVEN
  392.  
  393.        6    =  Break Condition  0=disabled         1=enabled
  394.        7    =  Port Toggle      0=Use THR/RDR/IER  1=Use BRDL/BRDH
  395.  
  396.  
  397.        SAMPLE: Using N parity, 8 data bits and 1 stop bit requires
  398.        the LCR register of 00000000 to be then set as follows:
  399.                            76543210 = bit pattern
  400.                                  11 = 8 bits
  401.                                 0   = 1 stop bit
  402.                              000    = no parity
  403.                             0       = break disabled
  404.                            0        = toggle inactive
  405.                          ----------
  406.                            00000011 = 3h to send to LCR
  407.  
  408.  
  409.        Bit 7 of LCR controls the dual function of bits 0 and 1 in the
  410.        IER Register and should be set to zero in the above example.
  411.  
  412.  
  413.  
  414.        MCR  BIT MAPPING   (Modem Control Register)
  415.        ---------------------------------------------
  416.        BIT
  417.        0    =  Set DTR line active
  418.        1    =  Set RTS line active
  419.        2    =  USER BIT #1
  420.        3    =  USER BIT #2
  421.        4    =  UART loopback
  422.        5    =  zero
  423.        6    =  zero
  424.        7    =  zero
  425.  
  426.        Bit 3 is normally set to 1 for interrupt driven terminal
  427.        programs. Most programs force the modem to hang up by setting
  428.        bits 0 and 1 to 0. Modem software setup for these first two bits
  429.        therefore is usually 1 and 1.
  430.  
  431.  
  432.        LSR  BIT MAPPING   (Line Status Register)
  433.        ---------------------------------------------
  434.        BIT
  435.        0    =  byte in RDR (received)
  436.        1    =  overrun in RDR
  437.        2    =  Parity error detected
  438.        3    =  Framing error (out of sync, no stop bit received)
  439.        4    =  Break Detect
  440.        5    =  THR empty
  441.        6    =  TSR empty (removes char from THR)
  442.        7    =  Time Out
  443.  
  444.  
  445.        A communications program usually checks bit 5 here before sending
  446.        another character out the base port.
  447.  
  448.  
  449.        MSR  BIT MAPPING   (Modem Status Register)
  450.        ---------------------------------------------
  451.        BIT
  452.        0    =  change in [C]lear [T]o [S]end  CTS
  453.        1    =  change in [D]ata [S]et [R]eady DSR
  454.        2    =  change in ring indicator RI
  455.        3    =  change in [D]ata [C]arrier [D]etect  DCD
  456.        4    =  Clear to send ..... [CTS] set high
  457.        5    =  Data set ready .... [DSR] set high
  458.        6    =  Ring Indicator .... [RI]  set high
  459.        7    =  Data Carrier detect [DCD] set high
  460.  
  461.        Most BBS programs monitor bit 7 of the MSR to determine
  462.        if carrier is lost during a logon.
  463.  
  464.    ===================================================================
  465.        BAUD RATE DIVISOR (BRD Register) CHART
  466.  
  467.        Bit Rate            BRDH           BRDL
  468.        ---------------------------------------
  469.        50                   09h            00h
  470.        110                  04h            17h
  471.        300                  01h            80h
  472.        ---------------------------------------
  473.        1200                 00h            60h   From 1200 up, BRDH is
  474.        2400                 00h            30h   always set to zero!
  475.        4800                 00h            18h
  476.        9600                 00h            0Ch
  477.        19200                00h            06h
  478.  
  479.    ===================================================================
  480.  
  481.    Registering your copy will help continue the competitive advantages
  482.    of providing economical shareware. As an additional bonus, I will
  483.    ship you several other useful modem and dos utilities free!  If
  484.    you have any comments or suggestions about this utility, feel free
  485.    to write or call.
  486.  
  487.    Name_____________________________________________________________
  488.  
  489.    Mailing Address__________________________________________________
  490.  
  491.    City & State ___________________________________________________
  492.  
  493.    ZIP _____________________________ Phone _________________________
  494.  
  495.    Send $4 + $1 (ship & hand) check or money order to:
  496.  
  497.                            Gary Raymond
  498.                              POB 8184
  499.                       New Orleans, La. 70182
  500.                           (504) 288-6550
  501.                        Compuserve 70613,3165
  502.    ====================================================================
  503.                                      EOF
  504.  
  505.