Serial port will not work with cable already plugged in

I am using NR on a Raspberry Pi B3+ to display the status of my smart electricity meter (Dutch: "slimme meter") using some form of serial to USB cable (this one: https://www.sossolutions.nl/slimme-meter-kabel). This device sends out serial data (approx. one message of a few hundred bytes every second) at a 115200 baud rate.
Everything works fine, but only if I start NR first and then plugin the cable. If I power up or reboot the Pi and start NR with the cable already attached, NR receives nothing on the serial port. I must then unplug the cable and plug it back in before NR will receive anything on the serial port.
Is there a way to get this working without needing to unplug the cable every time?

When it boots with it plugged in is it coming back as the same serial port number as when plugged in later ? Can you check /dev/tty* to see what is appearing

These are the tty devices:

pi@pimeterkast:~ $ ls -al /dev/tty*
crw-rw-rw- 1 root tty       5,  0 Jul 13 12:17 /dev/tty
crw--w---- 1 root tty       4,  0 Jul 13 12:17 /dev/tty0
crw--w---- 1 root tty       4,  1 Jul 13 12:17 /dev/tty1
crw--w---- 1 root tty       4, 10 Jul 13 12:17 /dev/tty10
crw--w---- 1 root tty       4, 11 Jul 13 12:17 /dev/tty11
crw--w---- 1 root tty       4, 12 Jul 13 12:17 /dev/tty12
crw--w---- 1 root tty       4, 13 Jul 13 12:17 /dev/tty13
crw--w---- 1 root tty       4, 14 Jul 13 12:17 /dev/tty14
crw--w---- 1 root tty       4, 15 Jul 13 12:17 /dev/tty15
crw--w---- 1 root tty       4, 16 Jul 13 12:17 /dev/tty16
crw--w---- 1 root tty       4, 17 Jul 13 12:17 /dev/tty17
crw--w---- 1 root tty       4, 18 Jul 13 12:17 /dev/tty18
crw--w---- 1 root tty       4, 19 Jul 13 12:17 /dev/tty19
crw--w---- 1 root tty       4,  2 Jul 13 12:17 /dev/tty2
crw--w---- 1 root tty       4, 20 Jul 13 12:17 /dev/tty20
crw--w---- 1 root tty       4, 21 Jul 13 12:17 /dev/tty21
crw--w---- 1 root tty       4, 22 Jul 13 12:17 /dev/tty22
crw--w---- 1 root tty       4, 23 Jul 13 12:17 /dev/tty23
crw--w---- 1 root tty       4, 24 Jul 13 12:17 /dev/tty24
crw--w---- 1 root tty       4, 25 Jul 13 12:17 /dev/tty25
crw--w---- 1 root tty       4, 26 Jul 13 12:17 /dev/tty26
crw--w---- 1 root tty       4, 27 Jul 13 12:17 /dev/tty27
crw--w---- 1 root tty       4, 28 Jul 13 12:17 /dev/tty28
crw--w---- 1 root tty       4, 29 Jul 13 12:17 /dev/tty29
crw--w---- 1 root tty       4,  3 Jul 13 12:17 /dev/tty3
crw--w---- 1 root tty       4, 30 Jul 13 12:17 /dev/tty30
crw--w---- 1 root tty       4, 31 Jul 13 12:17 /dev/tty31
crw--w---- 1 root tty       4, 32 Jul 13 12:17 /dev/tty32
crw--w---- 1 root tty       4, 33 Jul 13 12:17 /dev/tty33
crw--w---- 1 root tty       4, 34 Jul 13 12:17 /dev/tty34
crw--w---- 1 root tty       4, 35 Jul 13 12:17 /dev/tty35
crw--w---- 1 root tty       4, 36 Jul 13 12:17 /dev/tty36
crw--w---- 1 root tty       4, 37 Jul 13 12:17 /dev/tty37
crw--w---- 1 root tty       4, 38 Jul 13 12:17 /dev/tty38
crw--w---- 1 root tty       4, 39 Jul 13 12:17 /dev/tty39
crw--w---- 1 root tty       4,  4 Jul 13 12:17 /dev/tty4
crw--w---- 1 root tty       4, 40 Jul 13 12:17 /dev/tty40
crw--w---- 1 root tty       4, 41 Jul 13 12:17 /dev/tty41
crw--w---- 1 root tty       4, 42 Jul 13 12:17 /dev/tty42
crw--w---- 1 root tty       4, 43 Jul 13 12:17 /dev/tty43
crw--w---- 1 root tty       4, 44 Jul 13 12:17 /dev/tty44
crw--w---- 1 root tty       4, 45 Jul 13 12:17 /dev/tty45
crw--w---- 1 root tty       4, 46 Jul 13 12:17 /dev/tty46
crw--w---- 1 root tty       4, 47 Jul 13 12:17 /dev/tty47
crw--w---- 1 root tty       4, 48 Jul 13 12:17 /dev/tty48
crw--w---- 1 root tty       4, 49 Jul 13 12:17 /dev/tty49
crw--w---- 1 root tty       4,  5 Jul 13 12:17 /dev/tty5
crw--w---- 1 root tty       4, 50 Jul 13 12:17 /dev/tty50
crw--w---- 1 root tty       4, 51 Jul 13 12:17 /dev/tty51
crw--w---- 1 root tty       4, 52 Jul 13 12:17 /dev/tty52
crw--w---- 1 root tty       4, 53 Jul 13 12:17 /dev/tty53
crw--w---- 1 root tty       4, 54 Jul 13 12:17 /dev/tty54
crw--w---- 1 root tty       4, 55 Jul 13 12:17 /dev/tty55
crw--w---- 1 root tty       4, 56 Jul 13 12:17 /dev/tty56
crw--w---- 1 root tty       4, 57 Jul 13 12:17 /dev/tty57
crw--w---- 1 root tty       4, 58 Jul 13 12:17 /dev/tty58
crw--w---- 1 root tty       4, 59 Jul 13 12:17 /dev/tty59
crw--w---- 1 root tty       4,  6 Jul 13 12:17 /dev/tty6
crw--w---- 1 root tty       4, 60 Jul 13 12:17 /dev/tty60
crw--w---- 1 root tty       4, 61 Jul 13 12:17 /dev/tty61
crw--w---- 1 root tty       4, 62 Jul 13 12:17 /dev/tty62
crw--w---- 1 root tty       4, 63 Jul 13 12:17 /dev/tty63
crw--w---- 1 root tty       4,  7 Jul 13 12:17 /dev/tty7
crw--w---- 1 root tty       4,  8 Jul 13 12:17 /dev/tty8
crw--w---- 1 root tty       4,  9 Jul 13 12:17 /dev/tty9
crw-rw---- 1 root dialout 204, 64 Jul 13 12:17 /dev/ttyAMA0
crw-rw---- 1 root dialout 188,  0 Jul 13 12:21 /dev/ttyUSB0
crw------- 1 root root      5,  3 Jul 13 12:17 /dev/ttyprintk

This list remains the same after a reboot.
The serial node is configured as /dev/ttyUSB0:115200-8N1 which is also the same after a reboot.

Same as my Pi2 settings except for tty1 which I don't think I use:

crw------- 1 pi   tty       4,  1 Jun 29 23:25 /dev/tty1
...
crw-rw---- 1 root dialout 204, 64 Jun 29 23:25 /dev/ttyAMA0
crw------- 1 root root      5,  3 Jun 29 23:25 /dev/ttyprintk
crw-rw---- 1 root dialout 188,  0 Jul 14 08:00 /dev/ttyUSB0

I was going to say that I don't have any issues like yours but then I realised I do have an issue but it isn't the same. If I have a power brownout (when my UPS switches from mains to battery then back again), the network doesn't reconnect. Don't have that issue on my Pi3 which I will switch to eventually. Not the same problem as I say.

What OS version are you using? And was it a clean install or an upgrade?

It was a clean install:

pi@pimeterkast:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

What does lsusb show?

If it shows nothing about a serial device, unplug and replug the device.

If it then shows FTDI, then there's a problem with some of those not being recognised on boot (typically clone Ardinuios).

when running ok:

pi@pimeterkast:~ $ lsusb
Bus 001 Device 007: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 001 Device 005: ID 2357:0601  
Bus 001 Device 006: ID 0424:7800 Standard Microsystems Corp. 
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

after reboot (not running anymore):

pi@pimeterkast:~ $ lsusb
Bus 001 Device 004: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 001 Device 005: ID 2357:0601  
Bus 001 Device 006: ID 0424:7800 Standard Microsystems Corp. 
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

after unplugging and plugging in (running ok again):

pi@pimeterkast:~ $ lsusb
Bus 001 Device 007: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC
Bus 001 Device 005: ID 2357:0601  
Bus 001 Device 006: ID 0424:7800 Standard Microsystems Corp. 
Bus 001 Device 003: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Reboot and in a terminal run
tail -f -n 1000 /var/log/syslog|grep usb
which will show you all the recent usb related messages in syslog and will sit there waiting for more entries, towards the end you should see a line saying that the device has been attached to ttyUSB0 or something similar. Then unplug it, wait a few secs and then plug it in again, I suspect you will then see that it has been attached as something different, possibly ttyUSB1. If this is the case then you need to specify a udev rule to get it to always connect as the same device. Using udev rules is the only reliable way of making sure a usb interface always connects as the same device. But confirm that is actually what is happening first.

this is what I see after a reboot:

Jul 15 19:39:25 pimeterkast mtp-probe: checking bus 1, device 5: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.3"
Jul 15 19:39:25 pimeterkast mtp-probe: checking bus 1, device 6: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.1"
Jul 15 19:39:25 pimeterkast mtp-probe: checking bus 1, device 4: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3"
Jul 15 19:39:25 pimeterkast mtp-probe: checking bus 1, device 6: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.1"
Jul 15 19:39:25 pimeterkast mtp-probe: checking bus 1, device 5: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1.3"
Jul 15 19:39:25 pimeterkast kernel: [    0.061322] usbcore: registered new interface driver usbfs
Jul 15 19:39:25 pimeterkast kernel: [    0.061373] usbcore: registered new interface driver hub
Jul 15 19:39:25 pimeterkast kernel: [    0.061457] usbcore: registered new device driver usb
Jul 15 19:39:25 pimeterkast kernel: [    0.211071] usbcore: registered new interface driver lan78xx
Jul 15 19:39:25 pimeterkast kernel: [    0.211125] usbcore: registered new interface driver smsc95xx
Jul 15 19:39:25 pimeterkast kernel: [    0.640076] dwc_otg 3f980000.usb: DWC OTG Controller
Jul 15 19:39:25 pimeterkast kernel: [    0.640106] dwc_otg 3f980000.usb: new USB bus registered, assigned bus number 1
Jul 15 19:39:25 pimeterkast kernel: [    0.640138] dwc_otg 3f980000.usb: irq 62, io mem 0x00000000
Jul 15 19:39:25 pimeterkast kernel: [    0.640389] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
Jul 15 19:39:25 pimeterkast kernel: [    0.640399] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
Jul 15 19:39:25 pimeterkast kernel: [    0.640407] usb usb1: Product: DWC OTG Controller
Jul 15 19:39:25 pimeterkast kernel: [    0.640415] usb usb1: Manufacturer: Linux 4.14.50-v7+ dwc_otg_hcd
Jul 15 19:39:25 pimeterkast kernel: [    0.640423] usb usb1: SerialNumber: 3f980000.usb
Jul 15 19:39:25 pimeterkast kernel: [    0.641801] usbcore: registered new interface driver usb-storage
Jul 15 19:39:25 pimeterkast kernel: [    0.646427] usbcore: registered new interface driver usbhid
Jul 15 19:39:25 pimeterkast kernel: [    0.646432] usbhid: USB HID core driver
Jul 15 19:39:25 pimeterkast kernel: [    1.061540] usb 1-1: new high-speed USB device number 2 using dwc_otg
Jul 15 19:39:25 pimeterkast kernel: [    1.311826] usb 1-1: New USB device found, idVendor=0424, idProduct=2514
Jul 15 19:39:25 pimeterkast kernel: [    1.311841] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Jul 15 19:39:25 pimeterkast kernel: [    1.631596] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
Jul 15 19:39:25 pimeterkast kernel: [    1.781914] usb 1-1.1: New USB device found, idVendor=0424, idProduct=2514
Jul 15 19:39:25 pimeterkast kernel: [    1.781930] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Jul 15 19:39:25 pimeterkast kernel: [    1.881552] usb 1-1.3: new full-speed USB device number 4 using dwc_otg
Jul 15 19:39:25 pimeterkast kernel: [    2.039123] usb 1-1.3: New USB device found, idVendor=0403, idProduct=6001
Jul 15 19:39:25 pimeterkast kernel: [    2.039138] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jul 15 19:39:25 pimeterkast kernel: [    2.039146] usb 1-1.3: Product: FT232R USB UART
Jul 15 19:39:25 pimeterkast kernel: [    2.039154] usb 1-1.3: Manufacturer: FTDI
Jul 15 19:39:25 pimeterkast kernel: [    2.039162] usb 1-1.3: SerialNumber: AI1X30AW
Jul 15 19:39:25 pimeterkast kernel: [    2.111641] usb 1-1.1.3: new high-speed USB device number 5 using dwc_otg
Jul 15 19:39:25 pimeterkast kernel: [    2.243126] usb 1-1.1.3: New USB device found, idVendor=2357, idProduct=0601
Jul 15 19:39:25 pimeterkast kernel: [    2.243146] usb 1-1.1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=6
Jul 15 19:39:25 pimeterkast kernel: [    2.243155] usb 1-1.1.3: Product: USB 10/100/1000 LAN
Jul 15 19:39:25 pimeterkast kernel: [    2.243163] usb 1-1.1.3: Manufacturer: TP-LINK
Jul 15 19:39:25 pimeterkast kernel: [    2.243171] usb 1-1.1.3: SerialNumber: 000001000000
Jul 15 19:39:25 pimeterkast kernel: [    2.541610] usb 1-1.1.1: new high-speed USB device number 6 using dwc_otg
Jul 15 19:39:25 pimeterkast kernel: [    2.672290] usb 1-1.1.1: New USB device found, idVendor=0424, idProduct=7800
Jul 15 19:39:25 pimeterkast kernel: [    2.672307] usb 1-1.1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
Jul 15 19:39:25 pimeterkast kernel: [    3.019314] usbcore: registered new interface driver r8152
Jul 15 19:39:25 pimeterkast kernel: [    3.029063] usbcore: registered new interface driver cdc_ether
Jul 15 19:39:25 pimeterkast kernel: [    3.111618] usb 1-1.1.3: reset high-speed USB device number 5 using dwc_otg
Jul 15 19:39:25 pimeterkast kernel: [    3.469157] usbcore: registered new interface driver brcmfmac
Jul 15 19:39:25 pimeterkast kernel: [    3.518737] usbcore: registered new interface driver usbserial
Jul 15 19:39:25 pimeterkast kernel: [    3.518805] usbcore: registered new interface driver usbserial_generic
Jul 15 19:39:25 pimeterkast kernel: [    3.518872] usbserial: USB Serial support registered for generic
Jul 15 19:39:25 pimeterkast kernel: [    3.531302] usbcore: registered new interface driver ftdi_sio
Jul 15 19:39:25 pimeterkast kernel: [    3.531389] usbserial: USB Serial support registered for FTDI USB Serial Device
Jul 15 19:39:25 pimeterkast kernel: [    3.532085] usb 1-1.3: Detected FT232RL
Jul 15 19:39:25 pimeterkast kernel: [    3.533632] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB0

The USB interface is attached as ttyUSB0 (but not working in NR)

after unplugging and replugging, these lines are added to syslog:

Jul 15 19:42:49 pimeterkast kernel: [  201.792246] ftdi_sio ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32
Jul 15 19:42:49 pimeterkast kernel: [  201.792359] ftdi_sio ttyUSB0: usb_serial_generic_read_bulk_callback - urb stopped: -32
Jul 15 19:42:49 pimeterkast kernel: [  201.981394] usb 1-1.3: USB disconnect, device number 4
Jul 15 19:42:58 pimeterkast kernel: [  211.234131] usb 1-1.3: new full-speed USB device number 7 using dwc_otg
Jul 15 19:42:58 pimeterkast kernel: [  211.391637] usb 1-1.3: New USB device found, idVendor=0403, idProduct=6001
Jul 15 19:42:58 pimeterkast kernel: [  211.391655] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jul 15 19:42:58 pimeterkast kernel: [  211.391663] usb 1-1.3: Product: FT232R USB UART
Jul 15 19:42:58 pimeterkast kernel: [  211.391671] usb 1-1.3: Manufacturer: FTDI
Jul 15 19:42:58 pimeterkast kernel: [  211.391679] usb 1-1.3: SerialNumber: AI1X30AW
Jul 15 19:42:58 pimeterkast kernel: [  211.400237] usb 1-1.3: Detected FT232RL
Jul 15 19:42:58 pimeterkast kernel: [  211.401133] usb 1-1.3: FTDI USB Serial Device converter now attached to ttyUSB0
Jul 15 19:42:58 pimeterkast mtp-probe: checking bus 1, device 7: "/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.3"

The USB interface is again attached as ttyUSB0 (and is now working in NR)
It has now device number 7 instead of 4.
So, this is not the cause of the problem ?

Looks like it. I imagine that means that the original is not actually being released.

I suggest that you look up how to give the device a fixed name. I had to do that with one of my devices.

Apparently not.
Don't know what else to suggest.

Something like this maybe?

http://hintshop.ludvig.co.nz/show/persistent-names-usb-serial-devices/

It has got a persistent name, it started life as ttyUSB0 and was the same after re-connect.

@willemx what do you see in the node-red log on startup after boot.

This is in the journal:

pi@pimeterkast:~ $ journalctl -u nodered -o cat
Started Node-RED graphical event wiring tool.
15 Jul 19:39:33 - [info]
Welcome to Node-RED
===================
15 Jul 19:39:33 - [info] Node-RED version: v0.18.7
15 Jul 19:39:33 - [info] Node.js  version: v8.11.3
15 Jul 19:39:33 - [info] Linux 4.14.50-v7+ arm LE
15 Jul 19:39:35 - [info] Loading palette nodes
15 Jul 19:39:40 - [info] Dashboard version 2.8.2 started at /ui
15 Jul 19:39:42 - [info] Settings file  : /home/pi/.node-red/settings.js
15 Jul 19:39:42 - [info] User directory : /home/pi/.node-red
15 Jul 19:39:42 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
15 Jul 19:39:42 - [info] Flows file     : /home/pi/.node-red/flows_pimeterkast.json
15 Jul 19:39:42 - [info] Server now running at http://127.0.0.1:1880/
15 Jul 19:39:42 - [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.
---------------------------------------------------------------------
15 Jul 19:39:42 - [info] Starting flows
15 Jul 19:39:42 - [info] Started flows
15 Jul 19:39:43 - [info] serial port /dev/ttyUSB0 opened at 115200 baud 8N1
15 Jul 19:39:43 - [info] [mqtt-broker:localhost] Connected to broker: mqtt://localhost:1883
15 Jul 19:42:49 - [error] serial port /dev/ttyUSB0 closed unexpectedly
15 Jul 19:43:04 - [info] serial port /dev/ttyUSB0 opened at 115200 baud 8N1

The serial port was opened first at 19:39:43, but did not receive data.
The cable was unplugged at 19:42:49 and plugged back in and then data was received.

Are you definite that it is not the device at the other end that is causing the problem?

Hi Mate.

Read this. this solved all my serial RS485 issues.
It may help you.

@Colin
I don't think the other end is the problem, because when I do

cu -l /dev/ttyUSB0 -s 115200 --parity=none

after a reboot, the serial port starts spitting out data right away:


pi@pimeterkast:~ $ cu -l /dev/ttyUSB0 -s 115200 --parity=none
Connected.
/Ene5\T210-D ESMR5.0

1-3:0.2.8(50)
0-0:1.0.0(180717170525S)
0-0:96.1.1(4530303438303030303131353534373138)
1-0:1.8.1(002351.055*kWh)
1-0:1.8.2(001640.822*kWh)
1-0:2.8.1(000577.631*kWh)
1-0:2.8.2(001294.589*kWh)
0-0:96.14.0(0002)
1-0:1.7.0(00.000*kW)
1-0:2.7.0(07.518*kW)
0-0:96.7.21(00047)
0-0:96.7.9(00003)
1-0:99.97.0(0)(0-0:96.7.19)
1-0:32.32.0(00003)
1-0:52.32.0(00003)
1-0:72.32.0(00002)
1-0:32.36.0(00000)
1-0:52.36.0(00000)
1-0:72.36.0(00000)
0-0:96.13.0()
1-0:32.7.0(235.0*V)
1-0:52.7.0(234.0*V)
1-0:72.7.0(235.0*V)
1-0:31.7.0(011*A)
1-0:51.7.0(011*A)
1-0:71.7.0(008*A)
1-0:21.7.0(00.000*kW)
1-0:41.7.0(00.000*kW)
1-0:61.7.0(00.000*kW)
1-0:22.7.0(02.709*kW)
1-0:42.7.0(02.733*kW)
1-0:62.7.0(02.075*kW)
!B641
/Ene5\T210-D ESMR5.0

etc, etc, ...

Does it do that even with node-red running? I would have expected it to fail because node-red would be using the port.
Does that work after you unplug and replug and node-red the port is working in node-red?

Yes, cu works even when node-red is running.
If node-red is running and I have unplugged and replugged the cable (so node-red is receiving data) and then I start cu, node-red will stop receiving data.
And then, if I stop cu, node-red will "take back" the serial port and will receive data again.

How have you got the serial port configured in node-red?