Search code examples
pythonlinuxraspberry-piraspbiancanopen

CANopen Device Updates too slowly


Using CANopen on a Revolution Pi I have data coming from an MLS (Magnetic Line Sensor), however the data being received is far too slow for the needs as the updates need to be instant. What do I need to do to make the data update much faster?

The CAN is setup using:

sudo ip link set can0 type can bitrate 125000
sudo ip link set can0 up
candump can0 -td

I have used the Python-can library to create a basic program to investigate whether it would poll faster:

import can

can_interface = 'can0'
bus = can.interface.Bus(can_interface, bustype='socketcan')

while 1 < 2:
    bus.flush_tx_buffer()
    message = bus.recv()
    print(message)

The data printed message data (similar to that of the candump) should be posting in a new message many times within a second, however I'm waiting from between <1sec to >10mins between the messages coming from the sensor


Solution

  • After trying a different MLS sensor the data was being posted every 0.01 seconds which is at the ideal speed. So there must be an unknown error with the original sensor however, this did work with a CANET-2 (CAN to Ethernet) device