On 3/9/17 7:34 AM, [email protected]
wrote:
Hi,
I would like to know if exist any other module
to communicate via serial in python, instead of
PySerial.
I want to know this because, PySerial only
communicate with "string", and i have a
microcontroller that will receive data from a
BeagleBone Black, and i shouldnt do an algoritm
on this microcontroller to change strings to int
or bytes, because will spend a lot of
processing, and every character on a string uses
one byte, and that will occupate a lot on this
micro.
Saying this, i want to send data in int/hex or
binary format instead of string from the
BeagleBone side, other solution can be change
the PySerial module to do this.
Any help will be aprecciated.
Best Regards,
David
--
For more options, visit
http://beagleboard.org/discuss
---
You received this message because you are
subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop
receiving emails from it, send an email to
[email protected]
<mailto:[email protected]>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/beagleboard/d5ed90c0-4e92-4aaa-8fa5-51ebc4f6329b%40googlegroups.com
<https://groups.google.com/d/msgid/beagleboard/d5ed90c0-4e92-4aaa-8fa5-51ebc4f6329b%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit
https://groups.google.com/d/optout.
Hi David,
PySerial is the way to go. Python has several ways
to do the conversion for you. Google around a bit
and you will find several examples.
Use the array module if you want to send several
bytes using PySerial. Here is an example of
sending a list of data. msgList is a list of
integer data to send. For example msgList =
[1,2,3,4,5] and serialObj is the opened serial stream.
import array
binMessage = array.array('B') <-- creates
an empty binary array
binMessage.extend(msgList) <-- converts
and copies the list to the array
serialObj.write(binMessage.tostring())
<-- Send it out. Notice the tostring function
serialObj.flush()
Mark
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/beagleboard/58C15E9F.5060803%40comcast.net.
For more options, visit https://groups.google.com/d/optout.