Serial Com
Shawn Masters
smasters at gmuvax2.gmu.edu
Sun Nov 19 02:44:20 AEST 1989
Since I assume your using a PC, I'll relay what I found with using the
IBM BIOS serial port routines.
The IBM BIOS only reads one character at a time, only when it's
asked for, and only the one in the serial ports send recieve buffer.
This causes lose of data in a few instances:
1)When the data rate is fast enough that the next character is
already started before your program asks for the last one. The BIOS
will return the character, but if you look at the high 8-bits, it also
returns an error.
2)When you write to the buffer, when data is in there. I've
never had this happen as to the nature of those past programs that used
the BIOS call.
On a fast machine with nothing else to do, you might get away
with a few errors at the low speeds, and a number of errors in the
higher speeds(normally at the begining of lines, why I don't know,
that's just what seems to happen). If you know what the input and
output is going to be like, then you can grab it with little or no
problem. This though is rarely true, and a bad way of doing things.
The way to go, is to intercept the COM interrupt, with a
function that stores the data in a buffer. When the buffer is near
full, you send a flow control(XOFF or EIA). Then when the buffer is
near empty(your program has read the values at it's leisure), you send
another flow control to start it back up again. This is how 9600 is
done reliably on old PC's even with disk transfers and all sorts of
other stuff going on.
One last thing, to make this work you must ineable the interrupt
on the UART in your PC. If this isn't done, nothing will be read into
the buffer, or atleast until it checks. Much like a baby that doesn't
cry(how many new parents are interrupt driven?).
Shawn C. Masters
George Mason University
smasters at gmuvax2.gmu.edu
More information about the Comp.lang.c
mailing list