RPI Serial hangups

#1

I have an intelligent home security system connected to my Raspberry Pi via rs232 to /dev/tty/AMA0 using serial in and out nodes within Node-Red. Communication is fine for about a week and then either the in or out node stops communicating. Each time I resolve it by stopping and restarting Node-Red.
I cannot find any logs and have have no idea how to diagnose what is causing this. Buffer overflow?
Can anyone help me.
thanks.

#2

You can't find any logs? Or you can't find a log that helps to suggest what is happening?
If it's the former and you have installed node-RED following the suggested method on https://nodered.org/docs/hardware/raspberrypi then the script will have installed the command node-red-log

#3

Also, when you say you restart node-red, is that exactly what you do or are you rebooting or what? How are you restarting node red?
It might also be useful if, in a terminal you run

node-red-stop
node-red-start

and copy/paste the result here. You can copy from the terminal using Ctrl-Shift-C

#4

node-red-log produces "command not found"
I installed all Node red via Pete Scargill's script.
Colin I have tried all measures including a full reboot and have found that stop- and restart of node red is enough to sort it for a few days. The terminal during restart all looks normal.
edit *** the last few lines are new. I will sort that. I don't think it is relevant.

Start Node-RED

Once Node-RED has started, point a browser at http://10.0.0.50:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot

To find more nodes and example flows - go to http://flows.nodered.org

Starting as a systemd service.
Started Node-RED graphical event wiring tool.
30 Jan 17:49:37 - [info]
Welcome to Node-RED

30 Jan 17:49:37 - [info] Node-RED version: v0.19.4
30 Jan 17:49:37 - [info] Node.js version: v8.11.1
30 Jan 17:49:37 - [info] Linux 4.14.71-v7+ arm LE
30 Jan 17:49:43 - [info] Loading palette nodes
30 Jan 17:49:51 - [info] Dashboard version 2.13.0 started at /ui
30 Jan 17:49:52 - [info] Settings file : /home/pi/.node-red/settings.js
30 Jan 17:49:52 - [info] HTTP Static : /home/pi/.node-red/public
30 Jan 17:49:52 - [info] Context store : 'default' [module=memory]
30 Jan 17:49:52 - [info] User directory : /home/pi/.node-red
30 Jan 17:49:52 - [warn] Projects disabled : editorTheme.projects.enabled=false
30 Jan 17:49:52 - [info] Flows file : /home/pi/.node-red/flows.json
30 Jan 17:49:53 - [info] Server now running at http://127.0.0.1:1880/
30 Jan 17:49:53 - [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.

30 Jan 17:49:53 - [info] Starting flows
30 Jan 17:49:54 - [info] [tcp out:telnet] connecting to localhost:7072
30 Jan 17:49:59 - [info] [tcp out:telnet] connecting to localhost:7072
30 Jan 17:50:13 - [info] Started flows
30 Jan 17:50:13 - [info] [sqlitedb:c37d97a8.1b07c8] opened /home/pi/dbs/iot.db ok
30 Jan 17:50:13 - [info] [sqlitedb:c37d97a8.1b07c8] opened /home/pi/dbs/iot.db ok
30 Jan 17:50:13 - [info] [sqlitedb:c37d97a8.1b07c8] opened /home/pi/dbs/iot.db ok
30 Jan 17:50:13 - [info] [sqlitedb:c37d97a8.1b07c8] opened /home/pi/dbs/iot.db ok
30 Jan 17:50:13 - [info] serial port /dev/ttyAMA0 opened at 9600 baud 8N1
30 Jan 17:50:13 - [info] [mqtt-broker:fc8b5c33.494e8] Connected to broker: mqtt://127.0.0.1:1883
30 Jan 17:50:13 - [info] [tcp out:telnet] connected to localhost:7072
30 Jan 17:50:13 - [info] [tcp out:telnet] connected to localhost:7072
30 Jan 17:50:13 - [info] [mqtt-broker:7326ac84.630d14] Connection failed to broker: mqtt://localhost:1883
30 Jan 17:50:28 - [info] [mqtt-broker:7326ac84.630d14] Connection failed to broker: mqtt://localhost:1883
30 Jan 17:50:43 - [info] [mqtt-broker:7326ac84.630d14] Connection failed to broker: mqtt://localhost:1883
30 Jan 17:50:58 - [info] [mqtt-broker:7326ac84.630d14] Connection failed to broker: mqtt://localhost:1883

#5

Are you sure that node-red-log is not found? If so then that must be a difference between Pete Scargill's script and the official one from https://nodered.org/docs/hardware/raspberrypi
Instead you should be able to use
sudo journalctl -f -n 100 -u nodered -o cat
Assuming that works then maybe the best thing is to wait till it fails again and see what is in the log, if anything.

#6

Colin thanks, that command does provide some info. Next time it hangs I'll try it.

#7

Iā€™d also suggest asking Pete to update his script to include the node-red-log command

#8

i'm "responsible" of newer additions to Peter's script, and from last december going on we moved to official nodered install script for that part... Peter's one will just be suspended while the official one is run, then after completing will just continue installing Peter's usual collection of nodes... nothing more, take a look at line 797: https://bitbucket.org/snippets/scargill/qexexb/the-script-2019#script.sh-797

1 Like
#9

@muggins Are you using node-red-stop and node-red-start to stop and start node-red?

What does the command
ls /usr/bin/node-red*
show?

#10

pi@atticPI:~ $ ls /usr/bin/node-red*
/usr/bin/node-red /usr/bin/node-red-start
/usr/bin/node-red-pi /usr/bin/node-red-stop

#11

Well that's very odd. What does
cat /lib/systemd/system/nodered.service
give. In case you don't know you can copy out of the terminal window using Ctrl-Shift-C.

#12

pi@atticPI:~ $ cat /lib/systemd/system/nodered.service

systemd service file to start Node-RED

[Unit]
Description=Node-RED graphical event wiring tool
Wants=network.target
Documentation=http://nodered.org/docs/hardware/raspberrypi.html

[Service]
Type=simple

Run as normal pi user - change to the user name you wish to run Node-RED as

User=pi
Group=pi
WorkingDirectory=/home/pi

Nice=5
Environment="NODE_OPTIONS=--max_old_space_size=256"

uncomment and edit next line if you need an http proxy

#Environment="HTTP_PROXY=my.httpproxy.server.address"

uncomment the next line for a more verbose log output

#Environment="NODE_RED_OPTIONS=-v"
#ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS
ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS

Use SIGINT to stop

KillSignal=SIGINT

Auto restart on crash

Restart=on-failure

Tag things in the log

SyslogIdentifier=Node-RED
#StandardOutput=syslog

[Install]
WantedBy=multi-user.target
pi@atticPI:~ $

#13

Well everything looks ok except that you are missing node-red-log. I have no idea how that might come about.