How can i send 8-bit data or binary data with pyserial?

Richard Brodie R.Brodie at rl.ac.uk
Mon Dec 13 08:50:01 EST 2004


"ouz as" <oguz_aylanc at hotmail.com> wrote in message
news:mailman.7604.1102942867.5135.python-list at python.org...

> I want to transfer 0 bit and 1 bit in order  with pyserial.But pyserial only
> send string data.

string _is_ the type one would normally use in Python for 8-bit
encoded data. If you are a Unicode purist, that's perhaps
all you would use it for.

If you have a list [11, 22, 33] of bytes to send,  you can write:
buffer = [chr(i) for i in [11, 22, 33]]

Or possibly, use the struct or array module. Either way, the
problem you have to solve is converting the format you have
to/from an appropriate string. We lack the detail to suggest the
best solution to that.





More information about the Python-list mailing list