On 01/02/2015 14:28, Alan Gauld wrote:
This was the problematic serial question.
*From:*Doug Basberg [mailto:dbasb...@comcast.net]
*Sent:* Friday, January 30, 2015 5:29 PM
*To:* 'tu...@python.org'
*Subject:* doing rs232 serial with binary data ?? with pyserial??
Hello group;
I am new to python and worked mostly in C & C++ (and assembly). I do
embedded controls and usually use the internet or LAN to log data and do
controls.
So, in Python I found pyserial and wish to use it to send binary to
controlled devices (in this case to a Modbus protocol solar charge
controller (TriStar TS-60).
In C++ I would setup ‘structs’ or class attributes to hold the byte
oriented commands and controller responses and then send them to rs232
as binary. I do not see how to do that with pyserial.
What I need is to send and receive binary (not strings) over rs232. In
this case from/to a Raspberry Pi (RPI) controller to/from the solar
charge controller. The RPI runs apache server to handle the network.
Any suggestions will be greatly appreciated. I have been using
Python2.7 so far.
Thanks
Doug
I'm no expert but I think you need the struct module from the standard
library https://docs.python.org/2/library/struct.html#module-struct
This list is geared towards beginners to Python and/or programming. If
you try the struct module and run into problems please ask further
questions on the main Python mailing list available at
https://mail.python.org/mailman/listinfo/python-list, as
gmane.comp.python.general or news:comp.lang.python
--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.
Mark Lawrence
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor