node-red / node-red-docker

Repository for all things Node-RED and Docker related
Apache License 2.0
485 stars 384 forks source link

docker serial #462

Open zhushaoan opened 2 hours ago

zhushaoan commented 2 hours ago
version: '3.8'

services:
  nodered:
    image: registry.xiangyuniot.com/edge/nodered:4.0.3-arm
    container_name: nodered
    user: root
    network_mode: host
    cap_add:
      - NET_ADMIN
    volumes:
      - node-red-data:/data
      - /sys/class/leds:/sys/class/leds
      - /sys/devices/platform/leds:/sys/devices/platform/leds
      - /dev/ttyS3:/dev/ttyS3_4851
      - /dev/ttyS4:/dev/ttyS4_485422
      - /dev/ttyS9:/dev/ttyS9_232
    tty: true
    stdin_open: true

volumes:
  node-red-data:
 docker logs f99e0dd2bad3
10 Oct 07:11:40 - [info]

Welcome to Node-RED
===================

10 Oct 07:11:40 - [info] Node-RED version: v4.0.3
10 Oct 07:11:40 - [info] Node.js  version: v20.17.0
10 Oct 07:11:40 - [info] Linux 5.10.110-rockchip-rk3588 arm64 LE
10 Oct 07:11:40 - [info] Loading palette nodes
10 Oct 07:11:41 - [info] Settings file  : /data/settings.js
10 Oct 07:11:41 - [info] Context store  : 'default' [module=memory]
10 Oct 07:11:41 - [info] User directory : /data
10 Oct 07:11:41 - [warn] Projects disabled : editorTheme.projects.enabled=false
10 Oct 07:11:41 - [info] Flows file     : /data/flows.json
10 Oct 07:11:41 - [warn]

root@hanweiai200:/home/hanweiai# ls /dev/ttyS* /dev/ttyUSB*
/dev/ttyS0  /dev/ttyS3  /dev/ttyS4  /dev/ttyS9  /dev/ttyUSB0  /dev/ttyUSB1  /dev/ttyUSB2  /dev/ttyUSB3
root@hanweiai200:/home/hanweiai# docker exec -it f99e0dd2bad3 /bin/bash
hanweiai200:/usr/src/node-red# ls /dev/ttyS* /dev/ttyUSB*
ls: /dev/ttyUSB*: No such file or directory
/dev/ttyS3_4851    /dev/ttyS4_485422  /dev/ttyS9_232
hanweiai200:/usr/src/node-red# ls -l /dev/ttyS3
ls: /dev/ttyS3: No such file or directory
hanweiai200:/usr/src/node-red# ls -l /dev/ttyS3_4851
crw-rw----    1 root     dialout     4,  67 Oct 10 08:28 /dev/ttyS3_4851

image Why is the serial port list displayed the serial port list of the host machine instead of the docker container?

hardillb commented 2 hours ago

That is probably a question for the node-serial developers.

zhushaoan commented 2 hours ago

这可能是节点序列开发人员的一个问题。

image The two different nodes encountered the same situation

hardillb commented 2 hours ago

What I meant was both those nodes make use of node-serial (https://www.npmjs.com/package/node-serial) to list the available serial ports.

hardillb commented 1 hour ago

The list of available ports is generated by this code:

https://github.com/node-red/node-red-nodes/blob/442576e838a267cde7ee3dd2fad634ea39eb5b0d/io/serialport/25-serial.js#L580-L590

Which just asks the node-serial code to list the available ports.