[comp.sys.ibm.pc] reliable asynch driver code

mp1w+@andrew.cmu.edu (Marc Russell Pawliger) (12/13/88)

[I do not read this group normally, so pardon if this has been covered]

For the longest time, I have been trying to construct, using assembler and c, a
reliable package for initializing and reading from the com port.  This means:
setting baud, stop bits, etc. and reading and writing at speeds up to 9600 baud.


I have looked at kermit source, which bypasses BIOS completely and does in and
out calls to the UART, and uses its own timing routines for baud rate, and have
been thoroughly confused.

The latest version I have installs an interrupt handler for input that triggers
on the receive buffer full of the UART.  It then grabs the character and stuffs
it into a circular buffer for later reading.  That *seems* to work OK, though
sometimes characters with the high bit set seem to come in as two characters,
not one.  The output routine is a busy-wait on the UART transmit buffer register
empty.  This is checked using BIOS calls.  It seems that even if I wait until
both the xmit buffer and the xmit register are empty (both bits off in the
return value), I still tromp on characters going out the UART - data gets
garbled, etc.  I then checked to see if the bits were always 0, but the loop did
cycle a few times, waiting for the bits to clear.  What am I doing wrong?
Should I also poll the UART for the xmit buffer and xmit register lines and
bypass BIOS altogether?

If someone can point me at source code, or a good reference or someone to talk
to, I'd be much obliged.

Thanks.

        Marc Pawliger
        mp1w@andrew.cmu.edu
        mp1w@cmuccvma.bitnet