Oct-28-2019, 03:40 PM
Dear Mr. DeaD_EyE,
Thanks for the reply but I am facing another problem. The first two bytes are always the same which are 'a' and 'b' but the rest of the two bytes are user input integers. So each time I would have a different set of integers ranging from 0 to 127. I am really confused on how to combine the first 2 bytes with the rest of the two bytes and send via serial.
I have tried the following ways but it did not help.
1. thirdByte = 100
fourthByte = 120
my_bytestring3 = bytes([hex(ord('a')), hex(ord('b')), hex(thirdByte), hex(fourthByte)])
serial.write(my_bytestring3)
2. thirdByte = 100
fourthByte = 120
my_bytestring2 = bytes([int(a), int(b), thirdByte, fourthByte])
serial.write(my_bytestring2)
Kindly help me in this regard.
Thanks,
gratna
Thanks for the reply but I am facing another problem. The first two bytes are always the same which are 'a' and 'b' but the rest of the two bytes are user input integers. So each time I would have a different set of integers ranging from 0 to 127. I am really confused on how to combine the first 2 bytes with the rest of the two bytes and send via serial.
I have tried the following ways but it did not help.
1. thirdByte = 100
fourthByte = 120
my_bytestring3 = bytes([hex(ord('a')), hex(ord('b')), hex(thirdByte), hex(fourthByte)])
serial.write(my_bytestring3)
2. thirdByte = 100
fourthByte = 120
my_bytestring2 = bytes([int(a), int(b), thirdByte, fourthByte])
serial.write(my_bytestring2)
Kindly help me in this regard.
Thanks,
gratna