read 9 bytes

Grant Edwards grante at visi.com
Mon Jun 11 18:21:05 CEST 2007


On 2007-06-11, nik <nikbaer at gmail.com> wrote:

> I need to read a 9 byte response from a device on the serial
> port. From reading the pySerial documentation it appears that
> I can only read in characters at a time.

bytes are the same thing as characters.

> If I do: serialport.read(4)
> I would get 8 bytes,

No, you'd get 4.  Just try it and see.  That would be way
faster and easier than waiting for answers from Usenet.

> and if I did serialport.read(5) I think the port will block
> until a time out,

It would read 5 bytes if available, otherwise it would block
until a timeout.

> since there
>
> Is there a trick to read 9 bytes off of a serial port?

Please tell us what happened when you tried the obvious:

  serialport.read(9)

-- 
Grant Edwards                   grante             Yow! Do I have a lifestyle
                                  at               yet?
                               visi.com            



More information about the Python-list mailing list