I communicate over UART with an other Komponent to get commands.
At first I check,if there is a message
Code: Select all
uart2.any()
Code: Select all
command = self.__uart2.read(9)
print('INFO-YB: read:',command)
b'\x01\x88\x00\x00\x00\x00\x00\x00\x89'
This is coded in Hex.
Now I want to dismantle this in individuals:
01 => irrelevant
88 => 136 (command)
00 => 0 (type)
00 => irrelevant
00 => irrelevant
00 => irrelevant
00 => irrelevant
00 => value with the MSB first, here I need the decimal value to use it.
89 => Checksum(Summe of all)
I do not need the Dec value, but I must calc the Checksum and read some of the values?
Whitch is the best way to dismantle this?
Should I use this?
Code: Select all
uart.readinto(buf, 9)
Which, do you think, is the easiest solution?
Thank you very much!