Serial Com

Mike Macgirvin mike at relgyro.stanford.edu
Thu Nov 16 07:37:03 AEST 1989


In article <89111504064675 at masnet.uucp> mark.longo at canremote.uucp (MARK LONGO) writes:
>
>  I am writing a small terminal program with quick`c'.  I am using the
>libraries supplied by microsoft (bios_serialcom).  I do NOT WISH TO USE
>A FOSSIL as this is a project , that forbids the use of one.
>
>  My `SEND' routine works fine , but I am having trouble with the
>receive part.  Basically what happens is that characters are not `all'
>being read from the com port.
>
[other text deleted]
	This is a major headache, I agree. It boils down to the fact that
the BIOS serial port functions do NOT work in interrupt mode. That is,
if you fail to read the port quick enough, another incoming character will
write over the top of it. Usually, the CPU can keep up with 300 baud if
you are sending to the screen, and considerably faster if you aren't (the
BIOS scroll window function takes a considerable amount of time). That's
why the first characters of the line are lost, you received two characters
while the screen was scrolling.
	The painful solution is to write (or purchase) an interrupt handler
for the serial port. There is a wealth of literature available on the
subject (everybody and their uncle has had to do this...). I don't have any
titles at my fingertips, sorry. I once wrote a memory resident utility to
set an interrupt handler that used the BIOS interface calls, but it broke
whenever any other modem program exited and turned the handler back off.
There was no way to trap this. Then I bit the bullet, and did what every
body else does... install your own for every program you use which uses
the com ports. 
	Check your local DOS bookstore, and flip through some 'C' books
looking for serial communciations. It's there. There are also third-party
libraries available which have fully operational and debugged interrupt
handler support. (Can someone supply a vendor?)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+  Mike Macgirvin              Relativity Gyroscope Experiment (GP-B)    +
+  mike at relgyro.stanford.edu   (36.64.0.50)                              +
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



More information about the Comp.lang.c mailing list