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

O

ouz as

hi,

I want to transfer 0 bit and 1 bit in order with pyserial.But pyserial only
send string data.
Can anyone help me?
Sorry about my english..

_________________________________________________________________
Depolama alani sikintisindan kurtulun - hemen Hotmail'e üye olun!
http://odeme.hotmail.com.tr
 
M

Michel Claveau - abstraction méta-galactique non t

Hi !

1 byte is 8 bits. If you want to manage bits, one by one, you can rewrite a
protocol, and replace pyserial.

Have a good day
 
R

Richard Brodie

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.
 
D

Diez B. Roggisch

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

Convert your data to numbers and use module struct to create strings out of
it.

Apart from that: You can only send chunks of bits as configured in your
serial settings - e.g. 8N1 means that you will have to send 8 Bits in a
row. I personally never used anything else, but it might be possible to
alter that setting to lets say 7N1 or even lower numeber - but I doubt that
this will work down to 1N1.

If you give us more details on your actual problem, we migh be able to give
better answers.
 

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

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,832
Latest member
UtaHetrick

Latest Threads

Top