I'm trying to test the data received from a serial port and can't seem to get it right. I need to check if the first byte received in a packet is 0xBE thus:
#ser is instance of pyserial serial object
data=ser.read(5)
print "serial RX: " + binascii.b2a_hex(data)
if data[0] != 0xBE:
print"wrong value"
always prints:
serial RX: beef000008
wrong value
Even though the binary to ascii print shows that the correct value has been received.
Where am i going wrong in this really basic task?
Thanks, Robin.