[comp.os.msdos.programmer] Interrupt Driven Serial IO...

gnome@lemon.ucsb.edu (Andy Perrine;6512 Segovia #313;961-7466;968-0403) (02/06/91)

I've recently been playing with doing interrupt driven serial IO. I've
consulted several books, and actually after getting all sorts of
bizarre bugs, finally have something that resembles a plain run of the
mill terminal program. The odd thing is this: Somehow keystrokes seem
to be interfering with the receiving of data.  Is the keyboard
interrupt somehow interfering with my serial port interrupt? 

Here is an example:
Call local BBS. Ask for long menu of options. Displays perfectly.
Ask for menu again. This time hold down a key while menu is
displaying. This time, I'll notice that two or three characters have
been dropped from the menu.

Another example:
This one is much more annoying.  Call local BBS. Enter a message for
the sysop, typing quickly (not TOO fast, say 40wpm).  Look back at
message, and hmmm... one or two characters seemed to be missing,
almost as if I'd made a typo.  But upon having the BBS list the
message back to me, the characters are there. They just were dropped
by my program when they were echoed back. 

So is this bug related to keyboard interrupts? Do I need to do
anything special with keyboard interrupts to prevent this from
happening? Or has noone ever heard of this sort of thing, and I must
have a bug somewhere else? Whatcha think? -Andy

gnome@cs.ucsb.edu
6600andy@ucsbuxa.bitnet
6600andy@ucsbuxa.ucsb.edu
---

n8541751@unicorn.cc.wwu.edu (Where there is darkness, light) (02/06/91)

gnome@lemon.ucsb.edu (Andy Perrine;6512 Segovia #313;961-7466;968-0403) writes:

>I've recently been playing with doing interrupt driven serial IO. I've
>consulted several books, and actually after getting all sorts of
>bizarre bugs, finally have something that resembles a plain run of the
>mill terminal program. The odd thing is this: Somehow keystrokes seem
>to be interfering with the receiving of data.  Is the keyboard
>interrupt somehow interfering with my serial port interrupt? 

Get a copy of the book called Dos Programmer's Reference, by Microsoft Press.

There's a good example of an interrupt driven terminal program.

Interrupt driven means you _won't_ miss characters, as long as your program's
critical regions where interrupts are turned off are sufficiently short,
and your interrupt handler is also short and quick.

Kris Bruland.

-- 
Kriston M. Bruland          |    . .         . .      . . .      .       . .
n8541751@unicorn.cc.wwu.edu |    .   .     . .        .        . .       .   .
8541751@nessie.cc.wwu.edu   |    .             .         .     .   .     .

jerry@gumby.Altos.COM (Jerry Gardner) (02/08/91)

In article <8871@hub.ucsb.edu> gnome@cornu.ucsb.edu writes:
[ He wrote an interrupt-driven terminal program that loses characters ]

Are you buffering the serial data as it comes in?  If I remember correctly,
the PC UART chip has a two byte receive FIFO.  If you don't get around to
reading it quickly enough, characters will be lost as others come in.

The correct technique is to store the buffers in a ring buffer in the
interrupt handler and write them to the display later.  My program uses
a 512 byte receive ring buffer and I've never lost characters.  


-- 
Jerry Gardner, NJ6A					Altos Computer Systems
UUCP: {sun|pyramid|sco|amdahl|uunet}!altos!jerry	2641 Orchard Parkway
Internet: jerry@altos.com				San Jose, CA  95134
Guns don't kill people, bullets do.                     (408) 432-6200