samsta / BatteryController

GNU General Public License v3.0
0 stars 0 forks source link

Automatically start software on Pi Powerup #13

Open NiallDarwin opened 2 years ago

NiallDarwin commented 2 years ago

Not really an issue with the software but seems like this is a good place to pin the desire and keep track of progress.

NiallDarwin commented 2 years ago

Also doing this may help close off issue 10.

NiallDarwin commented 2 years ago

I think the best way to approach this is to:

1/ put the LBC power line back on a Pi controlled relay 2/ write a quick and dirty python program which gets called as part of the pi startup. The python program should startup the can networks then the battery controller program then switch the LBC on.

Feedback on this idea please :)

JimsterCoder commented 2 years ago

I have some experience trying to auto-start programs on Pi. Starting something which runs and quits is fine but starting something that will run continuously is dodgy, or was 3 or 4 years ago when I looked into it. The problem is you can 'hang' the Pi and not be able to login to it, 'brick' it, essentially. For this reason I don't do it with my home automation system. I can review this again and see if anything has changed.

I suggest modifying BC so that it starts the CAN connections and the LBC then commences its usual workings.

NiallDarwin commented 2 years ago

I suggest modifying BC so that it starts the CAN connections and the LBC then commences its usual workings.

I was trying to avoid this complication given that the Pi is a temporary solution. If you think it can be done in reasonable time then yes, feel free :)

samsta commented 2 years ago

To autostart programs, Linux uses things like systemd which is available on the Pi. It runs programs as daemonized services, meaning they run in the background. As a consequence, you'll lose the ability to directly interact with them, for instance the curses-based interface won't work. Logs (anything written to standard output) go to a well defined location, though.

Have a look at https://www.thedigitalpictureframe.com/ultimate-guide-systemd-autostart-scripts-raspberry-pi/

Ultimately, we'll want to be able to run this as a background process and have other means to monitor it. It is a good solution.

JimsterCoder commented 2 years ago

"other means to monitor it. It is a good solution." Yes, I would like a web server interface.

I may be being optimistic but I think, for the short term, I can make the changes I mentioned above in a 'reasonable time'. I'll look into it.

samsta commented 2 years ago

Yes, I would like a web server interface.

100% agree