PiGatewaySerial using interrupts
-
Hi All,
I have the following set-up:
-
A couple of SenseBender Micro's
-
A Raspberry Pi 2 with the NRF24 connected to the GPIO pins
-
The RPi runs the PiGatewaySerial
-
The RPi also runs the pimatic(.org) controller, using the mysensor plugin.
In this set-up I noticed that the RPI misses some messages send by the SenseBender Micro's, especially when messages are send in rapid succession, e.g. when "presenting" the sensors.
I modified the PiGatewaySerial.cpp by using the interrupt generated by the NRF24 (see https://www.raspberrypi.org/forums/viewtopic.php?t=17061&p=290453) and have the interrupt routine run "gw->processRadioMessage();". (And remove this call from the main loop of PiGatewaySerial.cpp). I also use a semaphore to ensure that the NRF24 connected to the RPi is either used by the interrupt routine or by "gw->parseAndSend(buff);", which is the other major item in the main loop.
The result is that no messages are lost anymore.I can share the code if requested.
In the main loop there remains only one polling item "ret = poll(&fds, 1, 500);". I searched quite a bit, but am not able to find a way to make also this call interrupt based. This call waits for about half a second if there is a message that can be read from, in loose terms, "/dev/ttyMySensorsGateway". This waiting for half a second is what makes the RPi miss send messages and which is resolved using the interrupt from the NRF24.
Does anybody know how to make this call "ret = poll(&fds, 1, 500);" using interrupts? I do not like polling!
Ben
-
-
I have performance problem with the standard PiGatewaySerial (100% CPU). Could you post your modify version of the gateway ?
Solved : I had to modify source code of PiGatewaySerial.ccp and Makefile of librf24-bcm, and then if the controller establishes a connection with the gateway, the CPU is quite low (see this post)
-
@Bens, You should find that once you run a script, or controller of some kind that connects to the virtual serial port that PiGatewaySerial provides, CPU usage (as reported in top) will drop way down. What you're seeing, in my experience, isn't an actual problem, just an apparent one!
Cheers
Richard
-
@Bens did you resolved your issue with poll call?
-
@Bens i'm very interested in your code.
We code the same Problem over here: http://forum.mysensors.org/topic/2437/step-by-step-procedure-to-connect-the-nrf24l01-to-the-gpio-pins-and-use-the-raspberry-as-a-serial-gateway/32Would be nice if you could share your code.
-
Bens doesn't seem to come back that fast..
I opened a ticket to the rf24 library owner:
https://github.com/TMRh20/RF24/issues/172#issuecomment-163117684
Suggested Topics
-
Raspberry Pi is frustrating and I wanted to vent
General Discussion • 6 Apr 2016, 18:16 • micah 8 Apr 2016, 16:10 -
RFM69HW Raspberry Pi 2 Gateway
Troubleshooting • 2 Aug 2017, 12:39 • NickB149 2 Aug 2017, 14:30 -
Gateways
Development • 6 Feb 2024, 01:16 • OldSurferDude 6 Feb 2024, 14:22 -
Serial Baud Rate for Adapter
Mozilla WebThings Gateway • 29 Sept 2020, 11:38 • Westie 5 Jan 2021, 11:50 -
Multiple virtual nodes on a gateway
Troubleshooting • 7 Feb 2019, 16:00 • pvoj 12 Feb 2019, 23:14 -
Adding sensors and relays to serial gateway
Development • 8 Dec 2015, 16:09 • Tino 9 Dec 2015, 16:19 -
Changing MyConfig.h in codebender ide - compiling error
Troubleshooting • 2 Jan 2016, 21:02 • StefanG 4 Jan 2016, 22:36 -
How to check if serial gateway is operational ?
Development • 7 Jun 2015, 13:07 • joshmosh 8 Jun 2015, 18:31