Good afternoon, I encountered the following problem: when receiving several consecutive messages on CAN, some of them are lost. The idea of ​​the system: there is some kind of head unit, in this case, the RPi 3 connected to CAN via the MCP2515 module. There are also actuators, in this case, STM32F767ZIT, also connected to CAN. To poll actuators, the head unit sends a general command to CAN, and actuators immediately respond to it. The conditional number of the actuator is “sewn” into the response message indicator, due to which the response messages are sent over the bus in turn according to the CAN protocol. I use the analyzer to check the tire, everything is as it was intended. But here the head unit does not have time, it seems that to receive all response messages. Because instead of the response signals from, say, the first, fifth and seventh devices, it receives only from the first and seventh. And during the next test cycle from the fifth and seventh. So what's the deal? Is the MCP2515 buffer full? Or a CAN library for RPi curve? In this case, I would like to know your opinion about the most suitable CAN library for RPi on c ++ or si. This problem does not depend on the speed of transmission over CAN, I observed it both at 125 kb / s and at 500 kb / s. I thought to put a delay in the actuators when sending a response signal, but this is meaningless, because it is possible that they have to send "non-responding" signals and again create a queue of several messages. Thank you in advance.

    1 answer 1

    MCP2515 is a buffer for two messages. Accordingly, if the RPi does not have time to read them, everything else is lost.

    A fluent Google program shows that we need some kind of magic with the parameters of the kernel to make quick interrupts and fast SPI ("fast" - in the sense of "short response time"). I didn’t find any sane studies, how much it eventually turned out.

    Findings:

    • Option 1: Configure drivers for this MCP2515. To understand the reaction time, I highly recommend watching what is happening through Saleae (the cheapest clone is enough).

    • Option 2: make a more intelligent adapter on any STM with CAN, since you can do these STMs :) A simple STM32F105 transmits the 500th bus without straining, there were no losses.