-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling radio.available() after failed transmission when using writeFast or startWrite causes interrupt loop #929
Comments
I'm not exactly sure, I kind of think this is 'undefined' behaviour, because you are using ack payloads, but not keeping the chip in the right mode. Technically, you should be calling radio.txStandBy() at some point, if using these methods of writing with ack-payloads.
Does adjusting this code resolve the issue? |
I don't see how calling I would suggest using volatile bool states and handling their changes in the main
Calling Due to the
The pingpair_irq example is a relic example from back when maniacbug was still involved in this library (10+ years ago). I haven't actually ran tests on those examples (now located in our examples/old_backups folder) since v1.3.11 when I rewrote the examples for simplicity (among other reasons). |
|
Thank you, this actually solves the problem of the interrupt loop but as @2bndy5 pointed out this might be problematic, too. EDIT: actually adding more code brought back the problem. Still, I think your answer goes in the right direction, since disabling |
I also have no clue, why exactly the EDIT: Actually you are right. It seems that it was just a coincidence. I tested again in a more elaborated example and leaving out |
I know, I will try your proposal. I used interrupts because from another application where I streamed audio, I remember this was the only way of detecting fast enough without calling |
I know, I only put it for demonstrating reasons, I don't use it in production code. During debugging on a teensy 4.0 it did not cause troubles so far (probably because of native USB support). |
It honestly sounds like you are causing undefined behavior by doing too much in the ISR. Trying to point blame at a specific function will be little more than guesses that yield nothing conclusive. It helps to know you're using a teensy board. According to their docs:
I strongly suggest you try the |
I did not want to blame any function, I just wanted to understand what's happening. Honestly, I never experienced an extra interrupt being triggered because I was doing a single
I get your point. I read your first answer as "use volatile bool instead of the ISR". After having a closer look at |
There is a good reason why ISRs should be fast and simple. Looking back on my Assembly language class, I suspect a complex ISR might cause stack overflows which would explain the undefined behavior. To fully understand what that means would take considerable knowledge about how the compiler allocates memory for functions and how functions (in binary) are executed at runtime (and that's just focused on global functions - methods scoped to a data structure have more implications). |
I don't know if this is an expected behaviour or a library bug. When calling
radio.available()
after a failed transmission a new interrupt is caused, thus ending up in a never ending interrupt loop. Took me quite some time to figure out, thatradio.available()
is causing the extra interrupt.This is a minimal example (based on the ping_par_irq example) which demonstrates the unexpected behaviour (using only a sender, assuming the receiver is down):
code
If you comment out
radio.available
, no interrupt loop is caused.The text was updated successfully, but these errors were encountered: