I have the following data
a1 = 0x5A -- hex
a2 = 0x01 -- hex
a3 = 12 -- decimal
a4 = 28 -- decimal
a5 = sum of (a1 to a4)
I should be able to send all this information in a byte array and send using ser.write command in one go.
Currently I am manually converting a3 and a4 to hex and I am using something like this ser.write('\x5A\x01\x...\x...\x...)
I would like a way, I could pack all the variables into a single byte array and say ser.write(bytearray)
ser --- is my serial.Serial('COM1')
Same with ser.read - the information I get is in byte array - How can I decode to decimals and hexdecimals
Looking for the use of binascii function for both converting to byte array and converting back from byte array