Answer the question
In order to leave comments, you need to log in
How to correctly convert a string to bytes?
All the best!
I want to use Python (2.7) to send commands to a device connected via COM port (serialport, linux) using the serial library .
The description for the device says that you need to send commands in the form of bytes, but I don’t quite understand how to do this, that is, how can I convert the data to bytes?
Here is what I am trying to do :
reset = [ 0x02, 0x03, 0x06, 0x30, 0x41, 0xB3 ] # байты которые нужно отправить вместе
connection = serial.Serial(port='/dev/ttyS0',baudrate=9600)
connection.write(reset)
connection.close()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question