I have a correctly working python program on my rpi4 cm. The program controls and reads multiple gpios. Since I don’t know in the future whether the computing module will be different, I tried to use Linux-based commands and not RPI-specific commands or packages, so I decided to use gpiod.
To install gpiod I do:
apt-get update && apt-get install -y gpiod
And then my python code executes various subsystem commands like:
gpioset gpiochip0 7=1
gpioget gpiochip0 12
This works correctly on my rpi4 cm, but when I integrate my code into BalenaOS it seems that it cannot handle these commands. My Dokefile.template already includes the following line:
command = f"gpioget gpiochip0 {self.state_pin}"
result = subprocess.run(command, shell=True, capture_output=True, text=True)
#get the result from the subprocess
pin_state = int(result.stdout.strip())
if pin_state:
#something here
else:
#something here
However, it seems that gpiod is not installed even when I have the following in the Dockerfile.template file:
RUN apt update -y && apt upgrade -y
RUN apt -y install build-essential
RUN apt-get update && apt-get install -y \
i2c-tools \
alsa-utils \
gpiod