Check for valid bytes
Posted: Tue Apr 07, 2020 8:53 am
Hi, I've got a general question. I'm reading a serial sensor which is suppose to produce a data frame of 4 bytes(always starting with 0xff and the last 4th byte being the checksum). I've got problems with detecting a valid data frame because some of the bytes are just garbage. My question is how do I check for valid bytes?
Here's an example of the output:
Here's an example of the output:
Code: Select all
b'\xff\x08\x9e\xa5'
b'\xff\x08\xc1\xc8'
b'\xff\x08\xb0\xb7'
b'\xff\x08\x9e\xa5'
b'\xff\x08\xc1\xc8'
b'\xff\x08|\x83'
b'\xff\x08kr'
b'\xff\x08\xc1\xc8'
b'\xff\x08kr'
b'\xff\x08\x9e\xa5'
b'\xff\x04\xfb\xfe'
b'\xff\x06\x0f\x14'
b'\xff\x07\xd0\xd6'