gpiod in BalenaOS using rpi4 cm with IO Board

Hi

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:

RUN apt-get update && apt-get install -y gpiod

But it can’t seem to find the gpiod package.

Any ideas on how to solve this?

Best regards.

@embedded could you please share the logs of the error?

or you are running the gpioset instructions on a bash script?

Thanks!

Hi

My python program executes several commands as a subprocess to interact with the GPIOs like the example bellow:

To set a value:

  command = f"gpioset gpiochip0 {self.trigger_pin}=1"
  result = subprocess.run(command, shell=True, capture_output=True, text=True)

Or to get a value:

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