pierremolinaro / acan-esp32

An ESP32 CAN 2.0B library
MIT License
40 stars 16 forks source link

Bug in can::tryToSend() #2

Closed DirkMeintjies closed 2 years ago

DirkMeintjies commented 3 years ago

In your function can::tryToSend() you check the mDriverIsSending variable, and if it is true (implying that a previous TX is still in progress) you add the new message to the queue. However, it is possible to get a TX interrupt after this check, but before putting the message in the queue. Then the message ends up in the queue and is never transmitted. The solution is prevent TX interrupt from occuring (disable ints) before checking mDriverIsSending, and re-enable after placing message in queue.

pierremolinaro commented 3 years ago

Yes, you are right, this is a mistake. I'm correcting it and updating the library.

Best Regards,

Pierre

Le 25 juin 2021 à 15:35, DirkMeintjies @.***> a écrit :

In your function can::tryToSend() you check the mDriverIsSending variable, and if it is true (implying that a previous TX is still in progress) you add the new message to the queue. However, it is possible to get a TX interrupt after this check, but before putting the message in the queue. Then the message ends up in the queue and is never transmitted. The solution is prevent TX interrupt from occuring (disable ints) before checking mDriverIsSending, and re-enable after placing message in queue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pierremolinaro/acan-esp32/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEWKZVBGNY5UPBDTL4HSBGDTUSAYXANCNFSM47J4VMGA.