Re: [NTLK] Shop is open.

From: Peter H. Coffin (hellsop_at_ninehells.com)
Date: Fri Jan 23 2004 - 09:11:13 PST


On Fri, Jan 23, 2004 at 02:04:06AM -0500, Len Cole wrote:
>
> I always wondered why the neessity of a program to slow down a
> computer so it could communicate with a serial device! Sheesh!

Warning to PCBMan, et al.: I know this is a gross oversimplification.

Some things that are clever efficiencies at one speed may not be safe
at faster speeds. If for example, a programmer "knows" that assembling
a packet takes 1 millisecond, and it takes 20 microseconds for a serial
port to show as "busy sending data" from when you fill a buffer, it's
okay to write a program to

    assemble first data packet;

    while not out_of_data {
        send a packet to serial buffer;
        assemble a new packet;
        if no more data after this
            set out_of_data;
        wait for "busy sending" flag to go off;
        }

    send a packet to serial buffer;

    report result to user;

If a faster CPU can now start building packets at 100 times the speed of
the old machine, it only 10 microseconds to build a packet, then the
"busy sending" indicator hasn't had a chance to turn on yet, and the
the loop then stuffs the send buffer with new data even though the old
data hasn't been sent yet.

If you've got access to the actual program code, you can make a change
like

    while not out_of_data {
        send a packet to serial buffer;
        wait for "busy sending" flag to come on; /* new line */
        assemble a new packet;
        if no more data after this
            set out_of_data;
        wait for "busy sending" flag to go off;
        }

to fix the problem. If you don't have the source code, your only
solution is to bog down the computer running the program enough that
assembling the packet takes at least 20 microseconds, and probably a
little more for reliability. (You also get to do it without knowing how
long all of these times are, with occasional exceptions. You might know
how long the "time until 'busy sending' turns on" for a paricular serial
port chipset, and which chipset is in what machine, but that information
gets unreliable over time.)

-- 
82. I will not shoot at any of my enemies if they are standing in front of 
    the crucial support beam to a heavy, dangerous, unbalanced structure.
                --Peter Anspach's list of things to do as an Evil Overlord
-- 
This is the NewtonTalk list - http://www.newtontalk.net/ for all inquiries
List FAQ/Etiquette/Terms: http://www.newtontalk.net/faq.html
Official Newton FAQ: http://www.chuma.org/newton/faq/


This archive was generated by hypermail 2.1.5 : Fri Jan 23 2004 - 09:30:01 PST