Skip to content

enable interrupt handling for received packets #19

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

Merged
merged 2 commits into from
Dec 18, 2019
Merged

enable interrupt handling for received packets #19

merged 2 commits into from
Dec 18, 2019

Conversation

jerryneedell
Copy link
Contributor

Change send/receive functions to allow for the use of interrupts in the user code.
the changes are invoked if receive is called with timeout=None
in this case the initial call to listen is skipped assuming a packet has already been received
the user code must call listen.
send was modified to accept a kwarg keep_listenting -- if set to True then listen is call after the packet is sent.

add example for interrupt usage for Raspberry Pi
add example that transmits periodically.

Tested on Raspberry Pi Zero-W
and on feather_m0 (tested transmit example and that existing code still runs)

These changes should not impact any existing code.

@jerryneedell jerryneedell requested review from brentru and a team December 12, 2019 19:54
Copy link
Member

@brentru brentru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - requesting identical changes on the RFM9x PR for this issue: adafruit/Adafruit_CircuitPython_RFM9x#33 (review)

Thanks!

@jerryneedell
Copy link
Contributor Author

requested changes implemented - thanks

@jerryneedell
Copy link
Contributor Author

@brentru are there any other changes you want made. Do you want any other reviews?

@Pythonaire
Copy link

hi @jerryneedell
seeing some mysterious gpio edge detection while testing. I think, the detection has to set with PUD_UP, not PUD_DOWN, because we awaiting rising signal from 0 to 1.

@jerryneedell
Copy link
Contributor Author

I’ll try that. Can you describe the problems you are having?

@jerryneedell
Copy link
Contributor Author

jerryneedell commented Dec 16, 2019

@Pythonaire this discussion suggests that a PULLUP is not desirable. matthijskooijman/arduino-lmic#46

Perhaps we should not be setting it at all. I will ask around for some guidance on this.

@Pythonaire
Copy link

Pythonaire commented Dec 16, 2019

@Pythonaire this discussion suggests that a PULLUP is not desirable. matthijskooijman/arduino-lmic#46

Perhaps we should not be setting it at all. I will ask around for some guidance on this.

image
Hm, interesting. I saw sometimes gpio events, but no data coming in (see time stamp 07:06:26) Thought, this is because the event is triggered by fallen signal flank. Now, i test it with PUD UP, lets see, whats happend.

@jerryneedell
Copy link
Contributor Author

@Pythonaire this discussion suggests that a PULLUP is not desirable. matthijskooijman/arduino-lmic#46
Perhaps we should not be setting it at all. I will ask around for some guidance on this.

image
Hm, interesting. I saw sometimes gpio events, but no data coming in (see time stamp 07:06:26) Thought, this is because the event is triggered by fallen signal flank. Now, i test it with PUD UP, lets see, whats happend.

It may just be a bad packet being received. Using the interrupt will not really help with issues of corrupted packets or missed packets. It may be useful to think about implementing something like the "reliable-datagram" that is used by the RadioHead library but that requires acknowledgement and retries.

@Pythonaire
Copy link

@Pythonaire this discussion suggests that a PULLUP is not desirable. matthijskooijman/arduino-lmic#46
Perhaps we should not be setting it at all. I will ask around for some guidance on this.

image
Hm, interesting. I saw sometimes gpio events, but no data coming in (see time stamp 07:06:26) Thought, this is because the event is triggered by fallen signal flank. Now, i test it with PUD UP, lets see, whats happend.

It may just be a bad packet being received. Using the interrupt will not really help with issues of corrupted packets or missed packets. It may be useful to think about implementing something like the "reliable-datagram" that is used by the RadioHead library but that requires acknowledgement and retries.

My fault, the pull_up_down stands for the initial(!) resistor state not the behavior, so PUD_DOWN is right. And yes, you are right, to reduce power consumption, I decided to take the "middle way". I use RH Datagram on client side, to have the chance to wait until all data are send properly. But not waiting for server acknowledgments. After the interrupt, I insert a if condition to see the received packets are not None. So , it seems in this special case the received packet was "corrupt". Fortunately, I didn't seen that before, so must be accidentally.

@jerryneedell
Copy link
Contributor Author

@brentru Are you satisfied with the updates I made and OK to merge this or do you want more changes? I am going to start working on another PR soon so it would be good to get this one out of the way -- same for the RFM9x PR

I'm happy to make any other changes you want if there is something else you would like to see.

@brentru
Copy link
Member

brentru commented Dec 18, 2019

@jerryneedell yep, I'm going to merge in both and release. was afk for a few days but I'm back now.

@brentru brentru merged commit c316502 into adafruit:master Dec 18, 2019
@jerryneedell jerryneedell deleted the jerryn_interrupt branch December 18, 2019 19:01
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Dec 19, 2019
Updating https://www.github.com/adafruit/Adafruit_CircuitPython_MCP4728 to 1.0.1 from 1.0.0:
  > Merge remote-tracking branch 'adafruit/master'
  > Fixing CP-isnt-CPython bug

Updating https://github.com/adafruit/Adafruit_CircuitPython_RFM69 to 1.3.0 from 1.2.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_RFM69#19 from jerryneedell/jerryn_interrupt
  > Merge pull request adafruit/Adafruit_CircuitPython_RFM69#17 from adafruit/dherrada-patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_RFM9x to 1.2.0 from 1.1.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_RFM9x#33 from jerryneedell/jerryn_interrupt
  > Merge pull request adafruit/Adafruit_CircuitPython_RFM9x#30 from adafruit/dherrada-patch-1

Updating https://github.com/adafruit/Adafruit_CircuitPython_BusDevice to 4.1.0 from 4.0.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_BusDevice#36 from adafruit/dherrada-patch-1
  > Merge pull request adafruit/Adafruit_CircuitPython_BusDevice#35 from CapableRobot/skip-init-write

Updating https://github.com/adafruit/Adafruit_CircuitPython_Bundle/circuitpython_library_list.md to NA from NA:
  > Added the following libraries: Adafruit_CircuitPython_BLE_Apple_Notification_Center, Adafruit_CircuitPython_BLE_Magic_Light, Adafruit_CircuitPython_Display_Notification
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants