Closed kentindell closed 1 year ago
Upcoming release of firmware now has a receive callback function. Function is associated when the CAN controller class is created. It is passed a CANFrame instance, which it can act on.
Caveats:
Remember that the callback is running from inside the ISR and if it executes for too long then this will disrupt CAN frame reception.
@kentindell That's a great news!
This will be a amazing new feature for this project :)
Thank you!
New firmware released (including new source).
The CAN ISR could call a standard MicroPython interrupt function (which is not permitted to use the heap, directly or indirectly).
The function is called with attributes of the incoming CAN frame (or possibly can make a call to read the front of the FIFO and obtain the CAN ID and payload directly: cannot create a CANFrame because cannot trigger garbage collection).
See here for MicroPythpn interrupts: https://docs.micropython.org/en/latest/reference/isr_rules.html