-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
raspberry nodered Cannot read property 'type' of null at Function.Pins.normalize (/root/.node-red/node_modules/johnny-five/lib/board.pins.js:91:24) #1396
Comments
I believe you're using the wrong pin names? According to this: https://github.com/nebrius/raspi-io/wiki/Pin-Information:
|
Thanks for your answer, Apparently not of that, the output of "gpio readall" gives the following: anyway following your link and leaving my code like this: const Raspi = context.global.raspiio; board.on("ready", function() { if (reles.rele1) {reles.rele1.toggle()} return msg; we obtain: 5 Oct 10:27:47 - [red] Uncaught Exception: Dive into board.pins.js and board.js (at Board.<anonymous>), I do not see any reference to a raspberrypi board. |
Raspi-io would provide its own pin name mappings ... There are some issues with this code: const Raspi = context.global.raspiio;
const five = context.global.johnnyfive;
const board = new five.Board({io: new context.global.raspiio()});
var reles = {};
board.on("ready", function() {
reles.rele1 = new five.Relay('GPIO17');
});
if (reles.rele1) {reles.rele1.toggle()}
return msg; Specifically that board.on("ready", function() {
reles.rele1 = new five.Relay('GPIO17');
}); Which means that this: if (reles.rele1) {reles.rele1.toggle()} ...is executed before "ready" is fired, so But none of that is related to your actual issue. Instead of using the Also, let's summon @nebrius |
Thank you const Raspi = context.global.raspiio;
const five = context.global.johnnyfive;
const board = new five.Board({io: new context.global.raspiio()});
var reles = {};
board.on("ready", function() {
reles.rele1 = new five.Relay("P1-11");
});
if (reles.rele1) {reles.rele1.toggle()}
return msg; But the issue is not solved.
|
Looking at #1396 (comment), I suspect this is a pin naming issue. I'm not really familiar with Node Red, other than users having issues with it, so this is just a guess. You have the pin set to Which Raspberry Pi are you running on? |
Raspberry Pi 3 Model B Board 1GB |
This is a proof of concept GPIO´s configuration with wPi pins: Flow:
It works perfectly. |
Hmm. The RPi 3 definitely supports that pin. @rwaldron, looking at the stack trace, it's crashing at https://github.com/rwaldron/johnny-five/blob/master/lib/board.pins.js#L91 because |
Hello nebrius: |
@Waterbrain sorry, it seems I wasn't clear. I had something for @rwaldron to check. |
Just to be clear, even if changing the pin name fixed the thrown exception, this line:
Would never actually execute. @nebrius I see what you're seeing now, and to answer your question:
Yes, absolutely—this is critical to the IO-Plugin architecture. Walking through this step-by-step:
@Waterbrain I need you run the following program and report the output: const Raspi = context.global.raspiio;
const five = context.global.johnnyfive;
const io = new Raspi();
console.log(io.pins);
const board = new five.Board({ io });
board.on("ready", function() {
console.log(board.pins);
}); |
Sorry I'm late. here it is:
and nodered is completely hung. |
I also noticed this at the end of the console output a few posts above:
I suspect that is why nodered hung. Now, why did it do this though? I'm not sure. With the repl enabled, I would expect it to run forever, and I didn't see an exception which is the normal cause for exiting. |
Hey everyone, sorry took so long to chime in. node-red-contrib-gpio is my doing :) Some background: Node-red by default is kinda bad at running johnny-five. Every time a flow is deployed in node-red a board instance is created. In a single node vm, this is problematic because of leaks like event listeners or timers in components sticking around. All that said, I'd start to debug this problem by removing node-red from the picture and just trying to use j5 and raspi-io directly together in node to see if things are cool. If that works, the culprit is either node-red or node-red-contrib-gpio and we could open an issue over here: https://github.com/monteslu/node-red-contrib-gpio |
That's how I've been working on this, and I'm not able to reproduce the problem. |
I'm out of my house for a trip. Also my mac has broken. |
Im experiencing the same/similar issue with Node-red restarting randomly from time to time due to an uncaught error: TypeError: Cannot read property 'pinMode' of null. @monteslu: I have opened issue #17 to describe the case but only just now noticed this issue that seems to be related. I have noticed that the uncaught exception only seems to happen after a while (a couple of minutes to many hours) if I leave the Node-red Dashboard open (where I'm monitoring a couple of the Arduino pins). But due to the random nature of when the reset is happening and the lack of log information, I haven't identified the root cause yet. And I'm still on an older version of Node-red that doesn't show the variable values (I haven't dared upgrading Node-red due to the complexity of my setup). @Waterbrain: do you also use the Dashboard node? Please let me know if I can be of any assistance and if anyone have any pointers on how to solve this. |
Hello @kjetilei: |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Hello:
Here is the content of /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 - feel free to change...
User=root
Group=root
WorkingDirectory=/root
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
The modules installed
[email protected] /root/.node-red
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]
Here is settings.js in the part of definition global:
Here is my code:
const Raspi = context.global.raspiio;
const five = context.global.johnnyfive;
const board = new five.Board({io: new context.global.raspiio()});
var reles = {};
var servos = {};
board.on("ready", function() {
reles.rele1 = new five.Relay('GPIO1');
reles.rele2 = new five.Relay('GPIO2');
reles.rele3 = new five.Relay('GPIO3');
reles.rele4 = new five.Relay('GPIO4');
reles.rele5 = new five.Relay('GPIO5');
reles.rele6 = new five.Relay('GPIO6');
reles.rele7 = new five.Relay('GPIO7');
reles.rele8 = new five.Relay('GPIO8');
servos.camServo = new five.Servo('GPIO0');
});
if (reles.rele1) {reles.rele1.toggle()}
return msg;
And the error:
Welcome to Node-RED
===================
3 Oct 11:25:24 - [info] Node-RED version: v0.17.5
3 Oct 11:25:24 - [info] Node.js version: v6.11.3
3 Oct 11:25:24 - [info] Linux 4.9.40-v7+ arm LE
3 Oct 11:25:26 - [info] Loading palette nodes
3 Oct 11:25:38 - [info] Settings file : /root/.node-red/settings.js
3 Oct 11:25:38 - [info] User directory : /root/.node-red
3 Oct 11:25:38 - [info] Flows file : /root/.node-red/flows_plantilla.json
3 Oct 11:25:38 - [info] Server now running at http://127.0.0.1:1880/
3 Oct 11:25:38 - [info] Starting flows
1507029938971 Available RaspberryPi-IO
3 Oct 11:25:39 - [info] Started flows
1507029939370 Connected RaspberryPi-IO
3 Oct 11:25:39 - [info] [nodebot:RaspberryPi-IO] io ready
3 Oct 12:37:35 - [info] Stopping flows
3 Oct 12:37:35 - [info] [nodebot:RaspberryPi-IO] closing nodebot
3 Oct 12:37:35 - [info] [nodebot:RaspberryPi-IO] port closed
3 Oct 12:37:35 - [info] Stopped flows
3 Oct 12:37:35 - [info] Starting flows
1507034255700 Available RaspberryPi-IO
3 Oct 12:37:35 - [info] Started flows
1507034255854 Connected RaspberryPi-IO
3 Oct 12:37:35 - [info] [nodebot:RaspberryPi-IO] io ready
1507034260172 Available RaspberryPi-IO
1507034260200 Connected RaspberryPi-IO
1507034260211 Repl Initialized
3 Oct 12:37:40 - [red] Uncaught Exception:
3 Oct 12:37:40 - TypeError: Cannot read property 'type' of null
at Function.Pins.normalize (/root/.node-red/node_modules/johnny-five/lib/board.pins.js:91:24)
at Relay.Board.Component (/root/.node-red/node_modules/johnny-five/lib/board.js:855:23)
at new Relay (/root/.node-red/node_modules/johnny-five/lib/relay.js:14:19)
at Board.<anonymous> (evalmachine.<anonymous>:9:17)
at emitNone (events.js:91:20)
at Board.emit (events.js:185:7)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickDomainCallback (internal/process/next_tick.js:128:9)
nodered.service: main process exited, code=exited, status=1/FAILURE
Unit nodered.service entered failed state.
nodered.service holdoff time over, scheduling restart.
Stopping Node-RED graphical event wiring tool....
Can you help my?
The text was updated successfully, but these errors were encountered: