Unexpected long pyserial read delay on Windows


John Nagle

I've been using PySerial on Windows (Win2000, amusingly) to drive
a Baudot teletype at 45.45 baud. Input and output work, but there's
a delay of about 1 second (!) on the input side between receiving a
character and reporting it to the program.

I'm using the latest "supports 1.5 stop bits" version of PySerial
(as noted previously, this is necessary for the old mechanical Teletypes),
and opening as follows:

ser = serial.Serial(port, baudrate=baud,

I've tried omitting the timeout parameter, "timeout=0", and "timeout=0.1",
none of which seem to change the behavior. The code doing the
reading is simply

while True :
s = ser.read() # get some input
for ch in s:
ser.write(ch) # write to tty

This correctly types back what's typed in, but with a delay of about 10
character times, over 1 second. (Remember, this is a VERY slow serial
device.) There's nothing else running; CPU load is under 1%.

I've tried "ser.read(1)"; makes no difference.

The delay is on the read side; if I put in a "print", the delay occurs
before the computer prints the received character.

Is this some Windows thing? I've looked at serialwin32.py around line 88,
and don't see any nonzero timeout parameters being fed to Windows
when "timeout=None". Checking the Microsoft documentation, at


feeding all zeroes into the COMMTIMEOUT structure should result in no
additional delays.

John Nagle

John Nagle

Grant said:
The UART you're using almost certainly has a receive FIFO.
Normally, the UART doesn't interrupt the CPU to tell it there's
receeve data ready until the FIFO is almost full (eg 12 bytes
present in a 16 byte FIFO).

If the UART has an empty receive FIFO, and it receives a single
character that character goes into the receive FIFO. If data
stops coming in before the rx FIFO threshold is reached, the
UART will wait 40 bit-times...

Ah, 40 bit times. That's the default. And that's the problem.
I thought the accumulation timer was a fixed timer of a few milliseconds.

There is a "disable FIFO" checkbox in Windows 2000. It's hard to

- Log off as user.
- Log on as "administrator"
- Open Control Panel -> System
- Go to "Devices" tab and select "Device manager".
- Open "Ports" in the tree and click on desired COM1 port.
- Click "Advanced" button.
- Set "Receive buffer size" slider to 1.
- Click "Disable FIFO" checkbox.
- Close all the dialogs.
- Reboot. (Yes, it doesn't take effect until the next reboot.)

That fixed the problem. Thanks.

John Nagle

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Latest member

Latest Threads