Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. PiGatewaySerial using interrupts

PiGatewaySerial using interrupts

Scheduled Pinned Locked Moved Development
raspberry pi 2pimaticinterruptsserial gateway
6 Posts 5 Posters 4.0k Views 5 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Bens
    wrote on last edited by
    #1

    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. :smiley: 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

    Never stop trying
    -Ben

    1 Reply Last reply
    3
    • M Offline
      M Offline
      minscof
      wrote on last edited by minscof
      #2

      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)

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hawk_2050
        wrote on last edited by
        #3

        @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

        1 Reply Last reply
        0
        • R Offline
          R Offline
          robosensor
          wrote on last edited by
          #4

          @Bens did you resolved your issue with poll call?

          1 Reply Last reply
          0
          • OitzuO Offline
            OitzuO Offline
            Oitzu
            wrote on last edited by
            #5

            @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. :+1:

            1 Reply Last reply
            0
            • OitzuO Offline
              OitzuO Offline
              Oitzu
              wrote on last edited by
              #6

              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

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              14

              Online

              11.7k

              Users

              11.2k

              Topics

              113.0k

              Posts


              Copyright 2019 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • MySensors
              • OpenHardware.io
              • Categories
              • Recent
              • Tags
              • Popular