[comp.sys.mac] need serial driver help

seubank@im4u.UUCP (Stephen Eubank) (06/19/87)

I'm working on (yet another!) communication protocol between a Mac and a 
mainframe and have run into a curious bug. I could use some help from 
anyone who knows more about the serial drivers than I do. This means you! 

For speed, I'm developing both sides on Macs (:-)), using MPW C (mostly) and 
Pascal. I've found this bug using both RAM and ROM serial drivers at 9600 
and 1200 baud on a Mac II, a plus and a 512K with new and old systems, so 
I assume the problem is in my code -- I just don't know where to begin 
looking. Suppose I start passing messages between two machines. Then, after 
some number (which seems to depend on the pair of machines in use) from 
3 to 30 or so messages have been exchanged, a single byte gets dropped. 
Now, that's a little surprising, but no cause for alarm in an 
error free protocol -- just resend the message.  
However, every time I resend the message, the 
same byte gets dropped! This byte can be in the middle of a long message or 
even a single CRC byte sent separately from the body of the message. 
    I've examined things at as low a level as I know how, using TMON on both 
sides. I use an FSWrite to transmit the data, but trap the _Write call with 
TMON. Examining the parameter block (PB) that A0 points to and the buffer 
whose address is in the PB, I can see the guilty byte as plain as day. 
After the _Write returns, I look at the PB and find that 1 byte has indeed 
been written and the result code is 0. Thus I'm pretty convinced that the 
problem is on the receiving side. I look at the input buffer I'm using on the 
receiving  side, and, although I can watch other bytes coming in one at a 
time, the missing byte just never shows up. Help!
    My only thought is that I'm abusing the input buffer somehow. I'm using 
my own 4K buffer and it's nowhere near filled up when the problem 
occurs. Could the Mac be busy doing something else when that byte shows 
up? If so, why is it always busy at the same place? I'm not doing anything 
else that I know of -- no mouse movement, no drawing. Have you ever seen 
a problem like this? Is there a Tech Note that will make it all clear? Am I 
being punished for past programming sins? Any advice you might have will 
be greatly appreciated.
    Thanks.

-- 
"Wake up to find out                Stephen Eubank
That you are                        Physics Dept.
The eyes of the world"              UT Austin