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/32

    Would 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

  • 6
  • 6
  • 12
  • 13
  • 4
  • 6

7
Online

11.4k
Users

11.1k
Topics

112.7k
Posts