I'm trying to read a CAN_Bus and get on certain IDs a strange output with which I can not work further (B2).
Code: Select all
b'\xff\xf0<]\x00\x00'
what is this? <] they are always other characters.
I have checked the bus speed 500 kBaund is correct.
When I read the CAN_Bus with my oscilloscope I get correct data.
What is the problem? is something wrong with my code?
I am using a: Adafruit Feather M4 CAN Express with Adafruit CircuitPython 7.0.0
Code: Select all
import struct
import board
import canio
import digitalio
import time
if hasattr(board, 'CAN_STANDBY'):
standby = digitalio.DigitalInOut(board.CAN_STANDBY)
standby.switch_to_output(False)
if hasattr(board, 'BOOST_ENABLE'):
boost_enable = digitalio.DigitalInOut(board.BOOST_ENABLE)
boost_enable.switch_to_output(True)
can = canio.CAN(rx=board.CAN_RX, tx=board.CAN_TX, baudrate=500_000, auto_restart=True)
force_sensor = can.listen(matches=[canio.Match(0x48)], timeout=.9)
while True:
time.sleep(0.1)
message = force_sensor.receive()
if not message is None:
data = message.data
print(data)
"""
Output:
b'\xff\xf0r\xc6\x00\x00'
b'\xff\xf0s)\x00\x00'
b'\xff\xf0s\x8d\x00\x00'
b'\xff\xf0s\xf0\x00\x00'
b'\xff\xf0tU\x00\x00'
b'\xff\xf0%\n\x00\x00'
b'\xff\xf0(\xed\x00\x00'
b'\xff\xf0,\xce\x00\x00'
b'\xff\xf00\xb2\x00\x00'
b'\xff\xf04\x96\x00\x00'
b'\xff\xf08y\x00\x00'
b'\xff\xf0<]\x00\x00'
b'\xff\xf0@>\x00\x00'
b'\xff\xf0D"\x00\x00'
"""