Dec 272017
Displays RS-232 status, great comm port Diag.
File RS.ZIP from The Programmer’s Corner in
Category Communications
Displays RS-232 status, great comm port Diag.
File Name File Size Zip Size Zip Type
RS.ASM 15232 4315 deflated
RS.COM 2136 1113 deflated
RS.TXT 14094 4040 deflated

Download File RS.ZIP Here

Contents of the RS.TXT file

RS - An RS-232 Port Status Utility

Author: Fred E. Davis

What RS does.

RS is an uncomplicated utility that prints a full

status report of a selected RS-232 'COM' port. It provides

information about the communications protocol, handshake,

line, error and interrupt status.

How to call RS.

RS is called by entering 'RS' followed by either no

argument or a '1' or '2' then . The argument

specifies which COM port you wish to view; '1' will select

COM1 and '2' will select COM2. When no argument is given or

an illegal value is used, the result will be the same as

entering '1'. If the specified COM port is not present (or

not responding), RS will notify you with a 'not installed!'

message. The command syntax is:

[d:][pathspec]RS [1 | 2]

What it all means.

The report is divided into five sections: A. Protocol,

B. Handshake Status, C. Line Status, D. Error Status and E.

Interrupt Status.

A. Protocol

Fred E. Davis 26 June 1986

An RS-232 Port Status Utility 2

Protocol lists six items: Data Bits, Stop Bits,

Parity, Rate, Stick and Break. The first four items are

those values set by the DOS 'mode COMx:' command.

1. Data Bits refers to the number of binary bits used

to send data. The choices are 5, 6, 7 and 8. Five and

six are rarely used. Most text can be communicated with

7 bits. An exception is a Wordstar formatted text file

that uses the eighth bit. Most binary files and

programs are transmitted with 8 data bits.

2. Stop Bits are used to identify the end of

transmission of one character. The possibilities are 1,

1.5 and 2 stop bits. Most protocols request one stop

bit; some older (and slower) protocols required 1.5 or

2 stop bits.

3. Parity is used in an error detection function to

identify a character distorted during transmission. The

choices are none, even and odd. All of these are likely

to be encountered. None is most often used with eight

data bits; odd and even with seven data bits.

Practically any combination is possible and you should

refer to the specific protocol requested by an

application to determine which is right.

Fred E. Davis 26 June 1986

An RS-232 Port Status Utility 3

4. Rate refers to the timing of the bits being

transmitted. The choices are many, though the more

common ones are 1200, 2400, 4800 and 9600 baud, or bits

per second. If the rate isn't right you'll soon find

out! You'll receive either nothing or garbage.

5. Stick refers to making the parity bit (if used) to

"stick" at logical 1 or 0. If 'stick' is 'normal',

the parity bit function will follow the message in item

3. If 'stick' is 'set' and 'parity' is 'even', the

parity bit will be forced to a logical zero. If 'stick'

is 'set' and 'parity' is 'odd', the parity bit will be

forced to logical one.

6. Break forces the transmitted data output to stay on.

It is used mostly in computer terminal communications

to grab the attention of a computer. If set, any data

to be transmitted is ignored.

B. Handshake Status

There are six handshake lines: DTR, RTS, CTS, DSR, CD

and RI. These handshake lines are often used to control the

transfer of information between the communicating systems,

but not always. They are more frequently used between

computers and modems, especially CD and RI. The directions

'In' and 'Out' used here are relative to the COM port. Some

Fred E. Davis 26 June 1986

An RS-232 Port Status Utility 4

communications rely on software handshake protocols such as

XON/XOFF, ETX/ACK and XMODEM (which goes beyond

handshaking). If hardware handshaking is used, DTR and/or

RTS must be high to enable the external device to receive.

Likewise CTS and DSR should be high to enable the COM port

to transmit.

1. DTR Out is often used in hardware handshake

protocols to indicate Data Terminal Ready. Data

Terminal is an old term referring in this case to the

computer (PC).

2. RTS Out notifies the external device that the COM

port is Ready To Send.

3. CTS In is the Clear To Send line. It is used often

in hardware handshake protocols with the DTR line.

4. DSR In refers to Data Set Ready. It is often used to

inform a Data Terminal (or computer) that a Data Set

(such as a modem) is ready to communicate.

5. CD In is the Carrier Detect input from a modem. It

is asserted when a communications link is established

with another modem.

Fred E. Davis 26 June 1986

An RS-232 Port Status Utility 5

6. RI In refers to Ring Indicate from a modem. It is

used primarily for auto-answer operations so the

computer can accept incoming telephone calls (even on a

specific number of rings by counting RI transitions).

C. Line Status

The four Line Status bits, Receive Buffer, Transmit

Buffer, Break Status and Loop Back, refer to the state of

internal registers and a test function.

1. Receive Buffer is the register that holds incoming

data. When holding data that hasn't been read, a 'full'

message will be displayed, otherwise it will be


2. Transmit Buffer holds data to be sent. When not

currently holding information waiting to be sent it

will indicate 'empty'; if data is waiting to be sent it

will show 'full'.

3. Break Status indicates the presence of a 'Break'

signal from the sender. This often initiates some form

of interrupt to normal communications. (See A.6.)

4. Loop Back is a special state for internal testing

and verification of hardware and register function.

Fred E. Davis 26 June 1986

An RS-232 Port Status Utility 6

When 'set', the internal output registers are connected

to the input registers (and vice versa) such that

transmitted data is immediately received. It must

indicate 'normal' if communications are to take place.

D. Error Status

The three error status lines, Overrun, Parity and

Frame, are set by the COM ports receiver to indicate a

communications problem.

1. Overrun 'set' means that another character has been

received before the first one has been read by the PC.

A possible cause for this is a baud rate too high.

2. Parity 'set' means that the last character

transmission was corrupted somehow. It obviously is

significant only when parity checking has been enabled

(See A.3.). Possible causes can be noise in the

communications lines or improper parity polarity (odd

or even).

3. Frame errors occur when a character was received

without a valid stop bit. Possible causes include

improper communications protocol (See A.).

E. Interrupt Status

Fred E. Davis 26 June 1986

An RS-232 Port Status Utility 7

Several conditions in the COM port cause cause

interrupts to the PCs Microprocessor to demand some service.

The four conditions are: Received Data Ready (See C.1.),

Transmit Buffer Empty (See C.2.), Line Status (See D.) and

Modem Status (See B.).

1. Output refers to an interrupt control signal that

can enable or disable all interrupt requests from the

COM port. If interrupts are to be used, it must show


2. Data Ready, if enabled, causes an interrupt when the

Received Data Buffer is full (See C.1.).

3. Xmit Empty, if enabled, causes an interrupt when the

Transmit Data Buffer is empty and another character can

be sent.

4. Line Status would cause an interrupt, when enabled,

if C.1., C.2., C.3., D.1., D.2. or D.3. are asserted.

5. Modem Status, like Line Status, causes an interrupt

if B.3., B.4., B.5. or B.6 are asserted.

How RS works.

Fred E. Davis 26 June 1986

An RS-232 Port Status Utility 8

RS is written in assembly language, which explains its

small size. The speed limitation on its execution is imposed

by the BIOS and DOS display routines. RS is not a memory

resident program; it does not trap any interrupts; it uses

only BIOS and DOS display interfaces; it does not alter the

port configuration.

After displaying the title message, RS checks the

'command tail' (any characters entered after the 'RS'

command) to see if any arguments are being passed. If a '2'

is present, RS will access COM2: starting at port 2F8h. If a

'1', no argument or an illegal value is passed, RS will use

COM1: starting at port 3F8h.

RS then reads all of the port registers and buffers

into temporary RAM buffers used by RS. The Line Control

Register is read, altered, and restored. RS checks to see if

a port really exists there by verifying the read/write

operation. Once all the registers are read, RS then scans

the values in the RAM buffers to generate the messages to

the display. This minimizes interruption of port activity.

In the case of the baud rate, RS first compares the rate

divisor to a table of standard values. If the port's rate is

not found, the actual baud rate is calculated and displayed.

RS terminates with a type 4Ch function call to DOS Int

21h. If the program executed normally a value 00h is

returned. If the COM port is not installed or functional, a

value of 01h is returned.

Fred E. Davis 26 June 1986

 December 27, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>