Category : Batch File Utilities - mostly for DOS
Archive   : UART12.ZIP
Filename : UART.TXT

 
Output of file : UART.TXT contained in archive : UART12.ZIP

UART.TXT last updated by Roedy Green 1993 June 11

UART C:
Detect UART type of serial port
UART COM1:
If Errorlevel 5 GoTo SyntaxError
If Errorlevel 4 GoTo PS2TYPE3
If ErrorLevel 3 GoTo AT16550FIFO
If ErrorLevel 2 GoTo AT16450
If ErrorLevel 1 GoTo XT8250
If ErrorLevel 0 GoTo NoSuchPort

UART by itself is considered a syntax error and generates a
usage message.

Sets errorlevel to type of UART detected.

This code is based on the MASM routines on page 364 Of PC
Magazine May 26, 1992.

In DESQview often ports COM1: and COM2: are not accessible. You
must have access priviledge in your PIF. If UART says there are
no ports, the simplest thing to do is run without DESQview.

Under OS/2 virtualization makes all com ports look like 8250s.

Supports only COM1: .. COM4:. Looks in BIOS Table to find the
corresponding physical addresses.

It expects this pattern COM1: COM2: COM3: COM4:
port: 378 2f8 3e8 2e8
irq: 4 3 4 3
int: C B C B

If for example COM1: has port 2f8, then irq 3 would be
anticipated and its interrupts would be fielded on int vector B.

Port has precedence over com port number in determining irq. So
for example, if someone removed your modem on COM2: without
reconfiguring your machine, DOS would slide COM3: down to COM2:
and COM4: down to COM3:. This is just asking for trouble, since
then you have a pattern COM2: = 3e8 = irq 4. UART treats this
as an error, even though some programs will survive it.

How UART Works
**************

If you are very curious, your best bet is to read the comments
in the source code UART.ASM. Even if you don't understand
assembler, you might be able to learn a fair bit.

The code to discriminate chip types depends on detecting the
presence of the scratch register, added after the 8250. Then we
check for FIFO buffers, added with the 16550AF. Then we check
for the enhanced register and DMA added with the IBM type 3.


To check the IRQ we simple send a NULL character to the port,
then wait on the CORRECT IRQ for an interrupt. If we get
exactly one, we are golden.

Five things can then happen:

1. device accepts the char, and we get a Xmit buffer empty interrupt.
This is the "nice" case. A loopback plug will also simulate this case.

2. device keeps CTS low, so char never goes out. We never get an int.
This is the case for example if a serial mouse is attached that
has not been activated. This is a "nasty" case.

3. device is powered off or missing. Then we get a line status
interrupt instead. This is the normal case when nothing at all
is connected to the port. We can still tell that the irq is correct.

4. IRQ not set properly. We see no interrupt. This is the error UART
was designed to detect.

5. Some other device is also using same IRQ. Then we may see spurious
extra interrupts from that device. Again we can report the problem
to the user.

-30-