Devices based on architecture/machine name

Hi all,

I didn’t know for sure where to put this.

I have a container (non-privileged, and I’d like to keep it that way :slight_smile:), which needs a device. So I’ve added the following to my docker-compose.yml file:

      - "/dev/ttyS0:/dev/ttyAMA0"

For the Raspberry Pi, this works fine. But when I’m building it for the up-board, it has to be:

      - "/dev/ttyS1:/dev/ttyAMA0"

Is there any way this could be changed based on the device architecture / machine name, just like the Dockerfiles with %%BALENA_MACHINE_NAME%%. Because now I’ve to change it based on the device I’m pushing it to, but it’d be better if I can just push to any device without thinking about it :slight_smile:.

Thanks in advance!

Hey @bversluijs

This situation can be solved with udev rules, documented here:

Basically, you want to write a rule that looks for you specific device, and mounts it at a standard location, let’s say /dev/my-serial and then in your app you reference only that path.

Let me know if you’d like some further information. I will add that at the moment it’s not possible to change these udev rules via the dashboard, but that feature is in the pipeline (but without an expected implementation date just yet).

Hi @CameronDiver,

Thanks for the information. I forgot about the udev rules. But I’ve to configure them in the config.json, although the devices are already running in the field. We’re testing the performance of the RPI 4 with our current software for replacing the UP Squared.

I thought there’d be a more simple / elegant solution for this. I’ll investigate the use of udev rules and if I can come up with other solutions.

FYI, the container needing this device is a scratch container running an executable, so I can’t create udev rules inside the container.

Thanks for the suggestion!