Serial Port not open


I am getting the following error on a Raspberry pi 3 B+ when using the modbus node.

(node:747) UnhandledPromiseRejectionWarning: Error: Port is not open
at fs.write (/home/pi/.node-red/node_modules/@serialport/bindings/lib/unix-write.js:49:25)
at FSReqWrap.wrapper [as oncomplete] (fs.js:509:5)
(node:747) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:747) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
It is strange because this happens on a new Pi Zero W and an older Pi 3B+ but works fine on an older Pi Zero. I have tried older versions of Raspbian and NR, but cannot identfy why the one Zero works

Any help or advice appreciated

Does the user running Node-RED (pi I assume) belong to group "dialout" on the one that works and not the others? I doubt it though as I've just done a fresh install a week ago and my "pi" user is in the group without me adding it explicitly.

Thanks for the response, the pi user belongs to the "dialout" group on both

This is a longshot but as serialport uses native bindings, maybe it needs to be rebuilt (perhaps Node version has changed or something). You could try rebuilding it with:

cd .node-red
npm rebuild

Then restart NR.

Edit: also observe for possible build errors for the module

Thanks, tried that but error remains. I have gone through all my Pi's and now found another A+ that also works fine. The only common issue I can find is both have a similar version of node (10.16 and 10.17)
I have started again with a complete fresh install of Raspberry OS and NR but error the same

Sorry, I'm out of ideas. Hopefully someone else will have more things to try.

Thanks for your help, I am just cheating for now, I have taken the SD card out of the A+ and put it into the 3 B+ (where I need it) and it works, so I am just going to make a image of this SD and use that until I can find a solution.

Thanks again :wink:

Interesting but a working solution!

Which version of nodejs have you got on the new install?

I think I might have found the reason. It supports your findings:

NodeJS has dropped prebuilt binaries for NodeJS 10 and above for 32bit linux. As a result it's too difficult to maintain support. However if you build nodejs and serialport yourself it will probably work.

This might have a lot of implications...

Maybe it got something to do they changed by default the port names on pi3&4

Maybe you can try the chapter " Swapping the Serial Ports on Raspberry Pi 3 / 4" and see if it helps.

That would be a very good explanation. Have you checked this @mtoko?

Doesn't it compile it when you install the serial port anyway?

This reminded of me the fact I just ran across the fact that an USB serial interface might bind to either /dev/ttyAMA0 or /dev/ttyACM0 depending on the situation. I just tried the search icon on the serial in node and it offered me both options (I have a CC2531 zigbee2mqtt stick attached).

Yes but at least I've ran across a situation that I had to run npm rebuild after upgrading to a new major version of Node.

Edit: nevermind you were referring to the quote I sent. That is very true and it does compile fine on Node 14 on a 32-bit Raspbian for me.

I think the documentation I linked was actually referring to 32bit i386 builds of Node.js.

I don't think it applies to Raspbian (except possibly the Zero, where I think 10 is the last available).

You are all genius! @edje11 the document that you liked to solved the problem. I changed the config.txt and assigned the GPIO14 and 15 the "main" UART to AMA0 and that fixed the problem

Thank you to everyone :blush:


@colin luckily there are a good supply of unofficial builds still out there -

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