pySerial: write in a blocking mode

Grant Edwards grante at visi.com
Wed Mar 29 10:06:41 EST 2006


On 2006-03-29, pdalet <philippe.dalet at voila.fr> wrote:

> The best solution is to send the last character with
> interrupt. when the TDR is empty an interrupt is generated. An
> interrupt program is executed to change the state of dtr.

No. That doesn't work.  You have to wait until the transmit
_shift_register_ is empty, not the transmit data register.  If
you shut off DTR as soon as the transmit data register is
empty, you'll cut off the last character.  The transmit data
register will go empty as soon as the last byte has been loaded
into the shift register.  At that point the last byte hasn't
been sent yet.

And on the 16450 and 16550 UARTS there _is_no_interrupt_ for
transmit shift register empty.

Even if you poll for the shift register empty status bit, some
implimentations set that bit too early and you'll cut off part
or all of the last stop bit.

Trust me. I've fought with this issue on PCs for 15 years.

-- 
Grant Edwards                   grante             Yow!  But was he mature
                                  at               enough last night at the
                               visi.com            lesbian masquerade?



More information about the Python-list mailing list