Node-red and serial ports

I have installed Torizon Core (minimal with docker support) and I install node-red for docker, all works fine, but when I use modbus contrib and configure serials instead TCP, serial doesn’t output data.
I have used /dev/ttyLP0
I’m using Col evaluation board and IMX8. I have used also serial contrib sending data on the serial port directely but nothing.

ttyLP0 works properly if i send following command from terminal:
echo -ne ‘Hello World’ > /dev/ttyLP0

Do you have any suggestion?

Greetings @fabrizio.camagna,

Just for our additional information could you answer the following questions:

  • What version of TorizonCore are you running?
  • What is the docker run command you used to launch the node-red container?
  • Other than failing to output data on ttyLP0, are there any other errors or messages that come up? Does dmesg indicate any errors?

Best Regards,
Jeremias

Did you solve the problem yet? I’m facing the same issue on a verdin imx8 mini.

Running node-red via docker-compose with the following config:

node-red:
    image: nodered/node-red:latest
    container_name: node-red
    restart: always
    environment:
      - TZ=Europe/Vienna
    volumes:
      - "node-red-data:/data"
    ports:
      - "1880:1880"
    devices:
      - "/dev/gpiochip0:/dev/gpiochip0"
      - "/dev/gpiochip1:/dev/gpiochip1"
      - "/dev/gpiochip2:/dev/gpiochip2"
      - "/dev/gpiochip3:/dev/gpiochip3"
      - "/dev/gpiochip4:/dev/gpiochip4"
      - "/dev/ttymxc0:/dev/ttymxc0"
      - "/dev/ttymxc1:/dev/ttymxc1"
      - "/dev/ttymxc2:/dev/ttymxc2"

Best regards,
Martin

Hi @rubmay07,

As you can see the original user never replied back to this post, so it never got looked at. Given that, I have some questions before we look into this.

  • What version of TorizonCore are you running here?
  • Are you experiencing the exact same issue as the original user? (i.e. serial ports not working with node-red)
  • Are there any other issues you’ve noticed?

Best Regards,
Jeremias

Hi @jeremias.tx,
thank you for your quick response.
To answer your questions:
I’m running the following version of TorizonCore:

$ uname -a
Linux verdin-imx8mm-06895363 5.4.77-5.1.0+git.afc2df4893e6 #1-TorizonCore SMP PREEMPT Wed Dec 30 18:41:13 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux

As mentioned, I’m running node-red in a docker container and installed node-red-contrib-modbus to use Modbus communication via the UARTs. As stated in the docs, I also tried listing the available UARTs from inside the node-red container using npx @serialport/list which gives me

bash-5.0$ npx @serialport/list
/dev/ttyS0		
/dev/ttyS1		
/dev/ttyS2		
/dev/ttyS3

although I’ve mapped the correct UARTs into the container (see configuration from my first post).

Communication works well when I use a python container and implement Modbus communication using pymodbus for example. Seems that there is a problem with the UARTs mapping…?
Everything else, such as using GPIOs works well from node-red.

Regards,
Martin

Alright after digging around for a bit, I think I have a educated guess about the issue here. So I think the issue is with node itself. As you noticed NXP i.MX devices use ttymxc* for their serial/UART devices. I went through the serialport utilities in node and found this: bindings-cpp/linux-list.ts at main · serialport/bindings-cpp · GitHub

In the typescript source I listed it seems ttymxc* isn’t a valid serial port name in this node utility. Which is why it’s never detected or picked up as you noticed. My typescript and node knowledge isn’t the best so I may also be interpreting this wrong. But it leads me to believe node may not have support for ttymxc* devices. Not sure if there is a way around this, other than asking the maintainers to add support.

Best Regards,
Jeremias

Who knows what else will break, but how about some symlinks to ttyS0/etc to fool the detection?

@DaveM

That’s possibly an idea, assuming the detection doesn’t ignore symlinks or it evaluates the symlink to the absolute path. But yeah as you said there may be other factors that could make or break this. Which is why I’m tentatively judging that node does not support i.MX serial ports.

Best Regards,
Jeremias