RPI GW - Including build flags somewhere for future reference



  • Hi,

    During my intense troubleshooting with my RPI GW I had to recompile MySensors GW code dozens of times.
    There were some points where I didn't know what build options I had at that moment, so I had to rebuild again just to be sure.

    My suggestion for feature would be to include the build flags defined somewhere so the user could remember what was defined by the compilation time. This could be either pasted as a comment in the mysensors.conf file or a printout when a special flag is indicated.

    Something like:

    $sudo ./bin/mysgw
    Usage: mysgw [options]
    
    Options:
      -c, --config-file          Config file. [/etc/mysensors.conf]
      -h, --help                 Display a short summary of all program options.
      -q, --quiet                Quiet mode, disable log messages written to the terminal.
      --daemon                   Run as a daemon.
      --gen-soft-hmac-key        Generate and print a soft hmac key.
      --gen-soft-serial-key      Generate and print a soft serial key.
      --gen-aes-key              Generate and print an aes encryption key.
      --compiled-flags           Displays a short summary of the compiling flags when this binary was created
    $
    $sudo ./bin/mysgw --complied-options
    My Sensors GW for RPI compiled at 2020-12-02 with the following flags:
    --my-gateway=mqtt 
    --my-controller-ip-address=192.168.2.180 
    --my-mqtt-publish-topic-prefix=mysensors-out 
    --my-mqtt-subscribe-topic-prefix=mysensors-in 
    --my-mqtt-client-id=MySensorsGW 
    --my-transport=rfm69 
    --my-signing=software 
    --my-signing-request-signatures 
    --my-rfm69-frequency=433 
    --my-is-rfm69hw 
    --my-signing-debug 
    --my-rfm69-encryption-enabled 
    --my-mqtt-user=mysensorsuser 
    --my-mqtt-password=mysensorspassword
    (Other options were default. Consult documentation for further information)
    
    

    What do you think? Would it be useful? This could also be useful for OrangePI or any other *nix system.


  • Mod

    @joaoabs yes it would be very useful. I've wished this existed several times but haven't found the time to figure out how to implement it.

    Printing the configure line every time the gateway starts would be the best place in my opinion. If the configure line was present in the startup log, we wouldn't have to ask for it every time someone asks for help.



  • Even better way would be to use config file, instead of hardcoded definitions.


  • Mod

    @monte my guess is that using a config file would prevent the Pi gateway from sharing code with the rest of MySensors, essentially creating a fork.

    But if someone is able to to do the necessary code changes, using a config file for everyhing except the setting that configures the path of the config file would be nice.



  • @joaoabs said in RPI GW - Including build flags somewhere for future reference:

    suggestion for feature would be to include the build flags

    I think what joaoabs suggests is not too difficult:

    1. Introduce an additional CPPFLAG which contains the whole command line arguments in ./configure:
    ...
    params="SOC CFLAGS CXXFLAGS CPPFLAGS LDFLAGS PREFIX CC CXX ARDUINO_LIB_DIR BUILDDIR BINDIR GATEWAY_DIR INIT_SYSTEM SPI_DRIVER"
    ***CPPFLAGS="-DCONFIGURE_COMMANDLINE=\""$@"\""***
    for opt do
    ...
    
    1. Print this flag in the gateways's setup function (examples_linux/mysgw.cpp):
    void setup()
    {
            // Setup locally attached sensors
    #ifdef CONFIGURE_COMMANDLINE
            printf ( "%s\n", CONFIGURE_COMMANDLINE );
    #endif
    }
    

    Might not be perfect, but works:

    pi@zerogwtest:~/MySensors $ sudo bin/mysgw
    Dec 03 23:54:30 INFO  Starting gateway...
    Dec 03 23:54:30 INFO  Protocol version - 2.3.2
    Dec 03 23:54:30 DEBUG MCO:BGN:INIT GW,CP=RPNGLS--,FQ=NA,REL=255,VER=2.3.2
    Dec 03 23:54:30 DEBUG SGN:PER:OK
    Dec 03 23:54:30 DEBUG SGN:INI:BND OK
    Dec 03 23:54:30 DEBUG TSF:LRT:OK
    Dec 03 23:54:30 DEBUG TSM:INIT
    Dec 03 23:54:30 DEBUG TSF:WUR:MS=0
    Dec 03 23:54:30 DEBUG TSM:INIT:TSP OK
    Dec 03 23:54:30 DEBUG TSM:INIT:GW MODE
    Dec 03 23:54:30 DEBUG TSM:READY:ID=0,PAR=0,DIS=0
    Dec 03 23:54:30 DEBUG MCO:REG:NOT NEEDED
    Dec 03 23:54:30 DEBUG MCO:BGN:STP
    --spi-spidev-device=/dev/spidev1.0 --spi-driver=SPIDEV --my-transport=rfm69 --my-rfm69-frequency=868 --my-is-rfm69hw --my-rfm69-irq-pin=18 --my-rfm69-cs-pin=12 --my-gateway=mqtt --my-controller-ip-address=127.0.0.1 --my-mqtt-publish-topic-prefix=mysensors-out --my-mqtt-subscribe-topic-prefix=mysensors-in --my-mqtt-client-id=mygateway1 --my-signing=software --my-signing-debug --my-signing-request-signatures --my-cppflag=MY_RFM69_CSMA_LIMIT_DBM=-90 --my-cppflag=MY_RFM69_NETWORKID=200
    Dec 03 23:54:30 DEBUG MCO:BGN:INIT OK,TSP=1
    Dec 03 23:54:30 DEBUG GWT:RMQ:CONNECTING...
    Dec 03 23:54:30 DEBUG connected to 127.0.0.1
    Dec 03 23:54:30 DEBUG GWT:RMQ:OK
    Dec 03 23:54:30 DEBUG GWT:TPS:TOPIC=mysensors-out/0/255/0/0/18,MSG SENT
    Dec 03 23:54:30 DEBUG TSM:READY:NWD REQ
    Dec 03 23:54:30 DEBUG SGN:SGN:NREQ=255
    Dec 03 23:54:30 DEBUG ?TSF:MSG:SEND,0-0-255-255,s=255,c=3,t=20,pt=0,l=0,sg=0,ft=0,st=OK:
    

    Thank you, joaoabs, for a good idea!



  • @mfalkvidd not necessary. We already have #define MY_GATEWAY_LINUX, so just #ifdef MY_GATEWAY_LINUX to define those constants in runtime at the init stage.
    As I see it, only SPI driver needs to be defined at compilation, other options could easily be set via config.


Log in to reply
 

Suggested Topics

  • 90
  • 3
  • 2
  • 7
  • 13
  • 3

16
Online

11.4k
Users

11.1k
Topics

112.7k
Posts