Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How can i send 8-bit data or binary data with pyserial?

Reply
Thread Tools

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

 
 
ouz as
Guest
Posts: n/a
 
      12-13-2004
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

 
Reply With Quote
 
 
 
 
Michel Claveau - abstraction méta-galactique non triviale en fuite perpétuelle.
Guest
Posts: n/a
 
      12-13-2004
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
--
Michel Claveau




 
Reply With Quote
 
 
 
 
Richard Brodie
Guest
Posts: n/a
 
      12-13-2004

"ouz as" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

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


 
Reply With Quote
 
Diez B. Roggisch
Guest
Posts: n/a
 
      12-13-2004
> 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.
--
Regards,

Diez B. Roggisch
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Beginner question: binary data and socket.send Boris Epel Python 1 12-21-2009 11:49 PM
Re: How can i send 8-bit data or binary data with pyserial? Fredrik Lundh Python 1 12-15-2004 10:24 PM
How can i send 8-bit data or binary data with pyserial? ouz as Python 1 12-14-2004 12:31 PM
How to send a form with binary data to another server? ij ASP General 1 11-26-2003 11:28 AM



Advertisments