Raspberry Pi 4 - Serial Communication in Single Container Device

Hello,

I’ve got a Nodejs server running on a Raspberry Pi 4 and I’m wanting it to serial communicate with an Arduino device for a Proof of Concept (using npm serialport). How do I get connection to the serial port inside the container? When I run ls /dev/* in the host-os I can see /dev/serial1 and /dev/AMA0 which I think might be symlinked. When I run the same command in the container I can’t see /dev/serial1 nor /dev/ttyS0 which I was also expecting, but can see /dev/AMA0. How would I allow connection to the mini serial port? I need WiFi so I know I can’t use the PL011 UART as that’s used by the Bluetooth/wireless module.

Any assistance is greatly appreciated.

Cheers,
Spen

Hello @SpencerWFSharkNinja first of all welcome to the balena community!

Could you please share your docker-compose or Dockerfile? did you try to run the container privileged?

1 Like

Hello mpous,

How do I run the container privileged?

My Dockerfile is:


LABEL maintainer="Spencer Walker-Fooks <swalkerfooks@sharkninja.com>"

RUN install_packages dnsmasq wireless-tools wget network-manager

WORKDIR /usr/src/app

ARG VERSION="4.4.0"
RUN curl -Ls "https://github.com/balena-io/wifi-connect/releases/download/v$VERSION/wifi-connect-v$VERSION-linux-%%BALENA_ARCH%%.tar.gz" \
  | tar -xvz -C /usr/src/app/

# /usr/src/app/
COPY scripts/* ./
COPY ./sleepi-mimic ./project/
COPY package.json .
COPY app.js .

RUN JOBS=MAX cd project/ && npm install && npm cache verify && npm install -g @angular/cli && ng build && mv ./dist/* ../
CMD ["bash", "start.sh"]

Any advice you can provide is greatly appreciated.

Single container fleets run in privileged mode by default, so if you just have this Dockerfile (and no docker-compose file) then it should already be privileged. What base image are you using? (I don’t see a FROM in your Dockerfile) Also, are you using a production or development version of balenaOS? I believe the “mini” UART is disabled by default on production versions and enabled by default on development. Please see this for enabling the mini UART: I2C and Other Interfaces - Balena Documentation

1 Like