-
-
Notifications
You must be signed in to change notification settings - Fork 641
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
Updated examples for callback receive mode #55
base: master
Are you sure you want to change the base?
Updated examples for callback receive mode #55
Conversation
Hi, I tried the DzikuVx's version and it appear I need to add a "pinMode(LORA_IRQ, INPUT);" for the interrupt to work.. Even with that, the interrupt is called with the good number of characters to read but when I read those, the data seems to be the previous (sometimes) or a shifted version of the previous.. Also, DzikuVx, why do you put 'recipient' in a 'int' instead of a 'byte' ? Regards, |
@NK36 I did not changed the logic, only moved code from left to right. But you are correct, byte can be used over there. I did not had to define DIO1 pin as input to make it work. |
Maybe because I have not the same board as you.. I have this one : With this pinout : Don't you think ? But I can't see why it behave different :/ |
If I want to use the interrupt, I need to read the data into the interrupt.. |
In pull request #50 there is a reworked interrupt handling with changes separated into atomic commits. |
Hi, Thanks szotsaki, I spent a lot of time on my problem and find out that it was due to PlatformIO which don't use the very last version of Arduino for ESP32... I was willing to use SPIFFS and it was not in my directories.. so I have to trick PlatformIO and then I retried to use LoRa with interrupt. Then it was successful! Still, I had to put the IRQ pin to INPUT in my setup()... Thank you both of you for your help ;) |
Hi @DzikuVx, Thanks for submitting this!
Interesting, maybe a better solution is to change the library. Do you think moving the clearing of the IRQ flags line ( https://github.com/sandeepmistry/arduino-LoRa/blob/master/src/LoRa.cpp#L471 |
Hi @sandeepmistry I do not think this really solves the problem. It only masks it for some cases. |
Right, but that's different from the example right?
This was based on the Wire libraries API's, which also calls the user callback in an interrupt context. https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/libraries/Wire/examples/slave_receiver/slave_receiver.ino |
@sandeepmistry I've lost track where this conversation is going. This is your project, your repo, you decide if current examples are fine or if they could be improved to lower possibility of future problems for new users. |
This has come up a couple times now and I agree the examples are problematic. There is only a minor conflict to be resolved so accepting this shouldn't be a big deal. I'll see about testing this and getting some version of it implemented. |
Current examples for callback receive suggests that it is OK to to heavy processing inside ISR.
This is not true and can lead to multiple problems, including SPI locking, race conditions and other hard to debug side effects.
Proposed examples sets flag in ISR but actual reading from SPI and processing is done inside mal loop