Hi
Apologies if this isn't the right forum for this query.
I wrote some C++ code 7 years ago under Raspbian Jessie to control and display a kitchen timer/clock using a headless RPi Zero W. The 16x2 LCD display is driven by I2C via a daughter board and control buttons are read by I2C using a PCF8574.
Ignoring the old adage 'if it ain't broke don't fix it' I decided a few days ago to bring the underlying OS up to the newest - bookworm. The transfer of my code and its attendant libraries went well but I found that, whereas I had been able to start the app in /etc/rc.local, this no longer worked. In fact adding anything to rc.local was completely ignored despite the permissions apparently being correct. So I cobbled together a systemd entry /etc/systemd/system/timer.service as follows:
[Unit]
Description=Kitchen timer server
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/timer
[Install]
WantedBy=multi-user.target
The next problem was that the timer was getting started up so early in the boot process that when the app tried to access /dev/i2c-1 it didn't yet exist and the app crashed. I did a quick and dirty fix for this by delaying the first access to /dev/i2c-1 by 10 seconds and all worked.
So, my question:
Is there anything I can add to the timer.service script to make it wait for /dev/i2c-1 to be available, either as an After in [Unit] or WantedBy in [Install] or anywhere at all?
TIA
Apologies if this isn't the right forum for this query.
I wrote some C++ code 7 years ago under Raspbian Jessie to control and display a kitchen timer/clock using a headless RPi Zero W. The 16x2 LCD display is driven by I2C via a daughter board and control buttons are read by I2C using a PCF8574.
Ignoring the old adage 'if it ain't broke don't fix it' I decided a few days ago to bring the underlying OS up to the newest - bookworm. The transfer of my code and its attendant libraries went well but I found that, whereas I had been able to start the app in /etc/rc.local, this no longer worked. In fact adding anything to rc.local was completely ignored despite the permissions apparently being correct. So I cobbled together a systemd entry /etc/systemd/system/timer.service as follows:
[Unit]
Description=Kitchen timer server
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/timer
[Install]
WantedBy=multi-user.target
The next problem was that the timer was getting started up so early in the boot process that when the app tried to access /dev/i2c-1 it didn't yet exist and the app crashed. I did a quick and dirty fix for this by delaying the first access to /dev/i2c-1 by 10 seconds and all worked.
So, my question:
Is there anything I can add to the timer.service script to make it wait for /dev/i2c-1 to be available, either as an After in [Unit] or WantedBy in [Install] or anywhere at all?
TIA
Statistics: Posted by Smudged — Wed Feb 28, 2024 11:59 am