pyserial with binary data

Grant Edwards grante at
Tue Nov 30 17:44:16 CET 2004

On 2004-11-26, alastair <ally_burnett at> wrote:

> When I send the data on windows everything is ok - on Linux I get the
> following traceback:
> Traceback (most recent call last):
> ...
> File "/home/pythonCode/", line 155,
> in serialWrite
> ser.write(buffer)
> File "/usr/lib/python2.3/site-packages/serial/", line
> 288, in write
> n = os.write(self.fd, d)
> OSError: [Errno 11] Resource temporarily unavailable

A patch that fixes this is available from the pyserial SF site.

> Can anyone offer any pointers as to why this should happen ?

It happens because the serial device driver returns -11.  The
Regular serial (16x50) driver doesn't do this and will buffer
up to 4K, then block.  For reasons known only to their authors,
some serial drivers don't behave like that.  If you try to
write more than they can immediately send to the HW (a dozen or
two bytes in the case I ran across with a Prolific USB->serial
widget), they take as much as they can send and return
immediately.  If you then try to write more data, you get a
return of -11.

> I first thought that it might be because I was using binary
> data, but the same happens when I tried a large ASCII data
> file. Any ideas for a workaround appreciated :)

Here's the bug:
Here's the patch:

Grant Edwards                   grante             Yow!  TATTOOED MIDGETS
                                  at               are using ALFREDO in their
                                 SALAMI FACTORY!

More information about the Python-list mailing list