gcgarner / IOTstack

docker stack for getting started on IOT on the Raspberry PI
GNU General Public License v3.0
1.5k stars 578 forks source link

Cannot start service nodered /dev/ttyAMA0 #248

Open tester277 opened 1 year ago

tester277 commented 1 year ago

I would like run the IOTstack on alternative hardware (instead raspi on a futro 740). After Build a new stack nodered can not be started: ERROR: for nodered Cannot start service nodered: error gathering device information while adding custom device "/dev/ttyAMA0". The error message appears regardless of which nodered modules have been installed. Is there a way around the error? Thanks Holger

Paraphraser commented 1 year ago

Yes, there is a way around this.

Please read these links:

  1. This project is dormant - which will explain why you should be starting at SensorsIot/IOTstack.
  2. The assumptions IOTstack makes so you understand that this is a "your mileage may vary" situation.

The ttyAMA0 device is the Raspberry Pi serial port. Apparently, "AMA" is the name of the bus on the Raspberry Pi SOC that connects to the UART.

Because /dev/ttyAMA0 is pretty much guaranteed to exist on a Raspberry Pi, it is used fairly often in IOTstack service definitions, both "for real" and as a placeholder.

Node-RED is an example of a "for real" mapping:

- /dev/ttyAMA0:/dev/ttyAMA0

With that in place a flow using the node-red-node-serialport add-on node can access the serial port on the Raspberry Pi (left hand side of the above mapping) by communicating with the container's serial port (right hand side of the above mapping).

It doesn't matter whether any node or flow is or isn't using /dev/ttyAMA0. The mapping makes the serial port available inside the container in case a node or flow wants to use it. It's a subtle difference.

Octoprint and Zigbee2MQTT are examples of "placeholder" usage. Until you connect your 3D printer or Zigbee adapter, you don't know how it is going to show up in /dev. Each of those service definitions maps:

- /dev/ttyAMA0:/dev/ttyACM0

Because Docker-Compose can find the left hand side of the mapping, it will at least start both the stack as a whole and any containers using that mapping.

The process running inside the container may well get upset and go into a restart loop (Zigbee2MQTT does) but that's a separate matter.

Anyway, in the case of Node-RED, you can solve this problem by doing one of the following:

  1. Delete or comment-out the line containing /dev/ttyAMA0; or
  2. For your particular hardware, figure out which device connects to your serial port and substitute it. For example, if /dev/ttyS0 leads to your UART, change the line to be:

    - /dev/ttyS0:/dev/ttyAMA0

The approach you take depends on whether you have plans to communicate with the serial port - assuming that exists on your hardware.

I hope this makes sense?

tester277 commented 1 year ago

Phill Thanks for the detailed explanation. With this it makes sense.