pyserial with binary data

Grant Edwards grante at visi.com
Tue Nov 30 11:44:16 EST 2004


On 2004-11-26, alastair <ally_burnett at yahoo.co.uk> 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/loader.py", line 155,
> in serialWrite
> ser.write(buffer)
> File "/usr/lib/python2.3/site-packages/serial/serialposix.py", 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:
  http://sourceforge.net/tracker/index.php?func=detail&aid=1043420&group_id=46487&atid=446302
Here's the patch:  
  http://sourceforge.net/tracker/index.php?func=detail&aid=1043436&group_id=46487&atid=446304

-- 
Grant Edwards                   grante             Yow!  TATTOOED MIDGETS
                                  at               are using ALFREDO in their
                               visi.com            SALAMI FACTORY!



More information about the Python-list mailing list