/dev/ttymxc2 serial port name not supported?

I'm using torizon imx7 som module with docker and Noder-Red: I can use gpio but if use serial port, node-red crash. With nxp serial port are named /dev/ttymxc* :do you know if node’s serialport module not supporting the naming scheme NXP uses for their serial/UART devices?
I went through the serialport utilities in node and found this:

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.
thanks

Welcome to the forum @GGG.

Please start node-red in a command window, and post the startup log here, up to the error you see. When posting use the </> button at the top of the forum entry window to stop the forum interpretting it as markdown.

It looks like it does not accept mxc pattern. Have you tried to manually add it? Is there a reason why you are not using node-red-node-serialport?

I think they are - the Node-RED node just pulls in the underlying serial port library from npm - so if they don't support it then neither will we.

Well node-red-node-serialport connects ok to device addresses such as /dev/serial/by-id/usb-1a86_USB_Serial-if00-port0 so that suggests that it is not applying any particular tests to the validity.

1 Like

Yes, I can confirm this. The marked function in the OP is most likely regarding list(). So if you use list, it won't list ttymxc* devices. However, you can still connect. I tried this with a symlink.

If this is docker, then you should be able to rename it to anything you want when you mount it into the container. e.g. -v /dev/ttymxc2:/dev/ttyUSB0 which should be picked up.

thanks to all for the support, I add some information:
I'm using Node-red 3.02 and node-red-node-serialport 1.03 with docher.
this is my docker command:

docker run -d --privileged --group-add dialout --user=root -it -p 1880:1880 -v node_red_data:/data --name mynodered2  --volume /sys:/sys  --device /dev/ttymxc2:/dev/ttymxc2  --device /dev/gpiochip0:/dev/gpiochip0 --device /dev/gpiochip1:/dev/gpiochip1 --device /dev/gpiochip2:/dev/gpiochip2 --device /dev/gpiochip3:/dev/gpiochip3 --device /dev/gpiochip4:/dev/gpiochip4 --device /dev/gpiochip5:/dev/gpiochip5 --device /dev/gpiochip6:/dev/gpiochip6 nodered/node-red:latest

if I insert a serial port that doesn't exist rightly I have the message in the debug window "/dev/ttymxc9" which doesn't exist I have on debug windows the message "[serialconfig:50974d4a50d9d1ef] serial port /dev/ttymxc9 error: Error: Error: No such file or directory, cannot open /dev/ttymxc9"
But if I set "\dev\ttymxc2" I have no message in debug window so I think it find it but then node-red crash, this is the log file

10 Apr 10:30:46 - [info] 

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

10 Apr 10:30:47 - [info] Node-RED version: v3.0.2
10 Apr 10:30:47 - [info] Node.js  version: v16.16.0
10 Apr 10:30:47 - [info] Linux 5.4.193-5.7.0+git.f5d73fd6e9f8 arm LE
10 Apr 10:30:54 - [info] Loading palette nodes
10 Apr 10:31:14 - [info] Settings file  : /data/settings.js
10 Apr 10:31:14 - [info] Context store  : 'default' [module=memory]
10 Apr 10:31:14 - [info] User directory : /data
10 Apr 10:31:14 - [warn] Projects disabled : editorTheme.projects.enabled=false
10 Apr 10:31:14 - [info] Flows file     : /data/flows.json
10 Apr 10:31:15 - [info] Server now running at http://127.0.0.1:1880/
10 Apr 10:31:15 - [warn] 

---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.

If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.

You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------

10 Apr 10:31:15 - [info] Starting flows
./entrypoint.sh: line 14:     6 Segmentation fault      /usr/local/bin/node $NODEOPTIONS node_modules/node-red/red.js --userDir /data $FLOWS

thanks

I am really no docker expert. Can you confirm that the error is caused by the serial port?
Have you tried to access the port outside of the docker, for example with a simple:

const { SerialPort } = require('serialport')
const port = new SerialPort({path: '/dev/ttymxc2', baudRate: 9600})
console.log(port)

I tried to acces the port from console, outside docker, with:

stty -F /dev/ttymxc2 9600
echo Test > /dev/ttymxc2

and serial port work fine.

inside docker, from container console I tried to put you code inside the file test.js

const { SerialPort } = require('serialport')
const port = new SerialPort({path: '/dev/ttymxc2', baudRate: 9600})
console.log(port)

but I have also segmentation fault:

bash-5.1# node test.js
Segmentation fault

thanks

I suggest you run the test.js outside of your docker first. Maybe something went wrong during cross-compiling? You are running this on a freescale CPU?

Ahh, just noticed this is 32bit ARM, the pre-compiled binaries shipped by the serial-port node (not the Node-RED one, the underlying npm module), you need to manually rebuild them to get them to work.

We have asked the project to delete the broken binaries so they get built on install (which does work) but they have never answered.

The work around is to run npm rebuild --build-from-source in the /data directory inside the container.

You can use -e NODE_RED_SAFE_MODE=true to get Node-RED to start up in safe mode, it will then not start the flows until the "Deploy" button is clicked. This should give you enough time to run docker exec -it [container name] /bin/sh to get a shell in the container.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.