CANopenNode / CanOpenSTM32

CANopenNode on STM32 microcontrollers.
Other
275 stars 110 forks source link

fixed bug not sending all pending messages #44

Open dirkmb opened 11 months ago

dirkmb commented 11 months ago

In my application I always flag (setting sendRequest to true) 8 PDOs for sending at the same time and I was wondering why only the first 3 - 4 PDOs are transmitted.

If the CO_CANinterrupt_TX is not able to send out all pending messages (e.g. if there are more pending messages than there are free CAN tx mailboxes) the CANtxCount is set to 0, which prohibits the sending of theses pending messages in the next interrupt.

I also stop the iteration if sending of one pending message fails, because following messages can also not be send if the buffers are already full.

I could not find an issue for this bug, if you like I can open one.

Florioo commented 5 months ago

This has solved most of my issues in a project im working on (using STM32G473).

I was having similar issues where the sdo client / sdo_server got locked up because the TX buffer was full. More specifically the bufferFull was was not cleared because the packet was never sent, this causes the entire module to lock up.

Since implementing this patch the canopen stack is quite stable.

CANopenNode commented 5 months ago

I'm not sure about this solution. Stack must be fully stable, no messages lost, nothing. Here is similar code for PIC32, which makes no problems: https://github.com/CANopenNode/CANopenPIC/blob/master/PIC32/CO_driver.c#L771