MySensors icon indicating copy to clipboard operation
MySensors copied to clipboard

Raspberry Gateway : Add variable in conf to modify service name

Open 3daerovision opened this issue 5 years ago • 15 comments

Hi, Would it be possible to add a parameter in the configuration to change the name of the generated binairy / service ? Thanks :)

3daerovision avatar Apr 19 '20 09:04 3daerovision

Thanks for suggesting this.

Could you share the main reason for wanting to rename the binary and service? Understanding the main reason can be good so we don't miss some small but important aspect related to the rename.

mfalkvidd avatar Apr 21 '20 20:04 mfalkvidd

I run 2 instances of the service on my Raspberry, for 2 transport mode. Changing the name in the config would make this easier. But it could be usefull if someone wan't to test different setting without replacing his working instance of the service.

3daerovision avatar Apr 22 '20 06:04 3daerovision

I have started work on this. Service naming works, but to make it possible to run more than 1 instance we need to separate the configuration file, eeprom file, log file, log pipe and maybe more.

mfalkvidd avatar May 08 '20 21:05 mfalkvidd

I'm worried that people will be confused when they compile and run two gateways with different service names, but same config file, log file, etc. I have not found a good way to handle this. Suggestions are welcome.

mfalkvidd avatar May 13 '20 20:05 mfalkvidd

I understand. I was not thinking of having multiple gateways on one config file, but more like multiple directories, with as many config and log files. For my tests, I have 2 separate MYS directories, have build both with different config, and then I had to rename the executable file and in services. I can run both without problem. So, maybe just add the name for service in config file is enough ?

3daerovision avatar May 13 '20 21:05 3daerovision

For brand new installations, we could add the name of the service as a setting in the config file, and let the gateway check the name at startup and refuse to start if the name doesn't match. But then we'd need a safe way to handle modification of the config file when people upgrade.

mfalkvidd avatar May 14 '20 06:05 mfalkvidd

Here is what I'm thinking so far:

  • [x] Add the service name to each log message. That would make it possible to read the log file even if multiple instances use the same log file/pipe.
  • [x] At startup, log the full file name and path for eeprom file and config file
  • [ ] Create a file lock on the eeprom file, and fail startup if the gateway cannot get the lock.

I'm not sure these are the best options, or if they will be sufficient to keep most people out of trouble.

mfalkvidd avatar May 14 '20 07:05 mfalkvidd

New updates in https://github.com/mfalkvidd/MySensors/tree/rpi-servicename

Unfortunately, I am not skilled enough to figure out how to lock the eeprom file.

mfalkvidd avatar May 14 '20 13:05 mfalkvidd

@3daerovision when you have time, could you please test https://github.com/mysensors/MySensors/pull/1421 ?

mfalkvidd avatar May 16 '20 09:05 mfalkvidd

I did some work trying to lock the eeprom file last weekend, thanks to hints from Yveaux. Judging by the progress so far, I'll need multiple more weekends to figure out how to do it.

mfalkvidd avatar May 18 '20 09:05 mfalkvidd

@3daerovision have you had any opportunity to test #1421 ?

mfalkvidd avatar Jun 24 '20 20:06 mfalkvidd

Hi mfalkvidd,

Is your work in the master or the development branch? I want to do the same on a raspberry with wireless and rs484 gateway. Can i also test for you. Do you think it is possible to use two wireless by using the second spi bus on the raspberry?

MySensors-MJChrist avatar Aug 04 '20 14:08 MySensors-MJChrist

The work is on the development branch.

There are now two ways to use a radio and rs485.

  1. Use the new support for multiple transports in a single gateway. See https://forum.mysensors.org/topic/11135/something-s-cooking-in-the-mysensors-labs
  2. Use two instances of the raspberry pi gateway (on the same raspberry pi), with or without https://github.com/mysensors/MySensors/pull/1421 See https://forum.mysensors.org/topic/7702/double-spi-radio-raspberry-pi

mfalkvidd avatar Aug 04 '20 15:08 mfalkvidd

If i want to make two instance of the gateway on the Raspberry i get te following: [WARNING] Unknown option detected:--service-name=mys1gw, ignored

This is the configure command: ./configure --service-name=mys1gw --my-transport=rf24 --my-rf24-channel=83 --my-rf24-pa-level=RF24_PA_HIGH --my-rf24-ce-pin=22 --my-rf24-cs-pin=24 --my-transport=rf24 --my-rf24-irq-pin=15 --my-gateway=ethernet --my-port=5003 --my-leds-err-pin=12 --my-leds-rx-pin=16 --my-leds-tx-pin=18

Its not very clear how to make the two instance of the gateway.

For cloning i used: git clone https://github.com/mysensors/MySensors.git --branch development

MySensors-MJChrist avatar Aug 04 '20 17:08 MySensors-MJChrist

https://github.com/mysensors/MySensors/pull/1421 has not been merged yet, so the service name feature is not available in the MySensors development branch.

mfalkvidd avatar Aug 04 '20 18:08 mfalkvidd