mirror of
https://github.com/node-red/node-red-nodes.git
synced 2023-10-10 13:36:58 +02:00
Tweaks to hardware nodes to throw not laoded exceptions correctly.
This commit is contained in:
parent
36bbddffe5
commit
5a9cfb3425
@ -18,13 +18,6 @@
|
|||||||
var RED = require(process.env.NODE_RED_HOME + "/red/red");
|
var RED = require(process.env.NODE_RED_HOME + "/red/red");
|
||||||
var bonescript = require("bonescript");
|
var bonescript = require("bonescript");
|
||||||
|
|
||||||
// Require bonescript
|
|
||||||
//try {
|
|
||||||
// var bonescript = require("bonescript");
|
|
||||||
//} catch (err) {
|
|
||||||
// require("util").log("[145-BBB-hardware] Error: cannot find module 'bonescript'");
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Node constructor for bbb-analogue-in
|
// Node constructor for bbb-analogue-in
|
||||||
function AnalogueInputNode(n) {
|
function AnalogueInputNode(n) {
|
||||||
// Create a RED node
|
// Create a RED node
|
||||||
|
@ -19,14 +19,12 @@ var util = require("util");
|
|||||||
var exec = require('child_process').exec;
|
var exec = require('child_process').exec;
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
if (!fs.existsSync("/usr/local/bin/gpio")) {
|
if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi
|
||||||
exec("cat /proc/cpuinfo | grep BCM27",function(err,stdout,stderr) {
|
throw "Info : Ignoring Raspberry Pi specific node.";
|
||||||
if (stdout.indexOf('BCM27') > -1) {
|
}
|
||||||
util.log('[36-rpi-gpio.js] Error: Cannot find Wiring-Pi "gpio" command. http://wiringpi.com/download-and-install/');
|
|
||||||
}
|
if (!fs.existsSync("/usr/local/bin/gpio")) { // gpio command not installed
|
||||||
// else not on a Pi so don't worry anyone with needless messages.
|
throw "Info : Can't find Raspberry Pi wiringPi gpio command.";
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Map physical P1 pins to Gordon's Wiring-Pi Pins (as they should be V1/V2 tolerant)
|
// Map physical P1 pins to Gordon's Wiring-Pi Pins (as they should be V1/V2 tolerant)
|
||||||
@ -94,6 +92,10 @@ function PibrellaIn(n) {
|
|||||||
else {
|
else {
|
||||||
this.error("Invalid GPIO pin: "+this.pin);
|
this.error("Invalid GPIO pin: "+this.pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.on("close", function() {
|
||||||
|
clearInterval(this._interval);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function PibrellaOut(n) {
|
function PibrellaOut(n) {
|
||||||
@ -142,6 +144,10 @@ function PibrellaOut(n) {
|
|||||||
else {
|
else {
|
||||||
this.error("Invalid GPIO pin: "+this.pin);
|
this.error("Invalid GPIO pin: "+this.pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.on("close", function() {
|
||||||
|
exec("gpio mode "+this.pin+" in");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
exec("gpio mode 0 out",function(err,stdout,stderr) {
|
exec("gpio mode 0 out",function(err,stdout,stderr) {
|
||||||
@ -159,17 +165,8 @@ exec("gpio mode 0 out",function(err,stdout,stderr) {
|
|||||||
exec("gpio mode 11 in");
|
exec("gpio mode 11 in");
|
||||||
exec("gpio mode 12 in");
|
exec("gpio mode 12 in");
|
||||||
exec("gpio mode 13 in");
|
exec("gpio mode 13 in");
|
||||||
exec("gpio mode 14 in",function(err,stdout,stderr) {
|
exec("gpio mode 14 in");
|
||||||
RED.nodes.registerType("rpi-pibrella in",PibrellaIn);
|
|
||||||
RED.nodes.registerType("rpi-pibrella out",PibrellaOut);
|
|
||||||
|
|
||||||
PibrellaIn.prototype.close = function() {
|
|
||||||
clearInterval(this._interval);
|
|
||||||
}
|
|
||||||
|
|
||||||
PibrellaOut.prototype.close = function() {
|
|
||||||
exec("gpio mode "+this.pin+" in");
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RED.nodes.registerType("rpi-pibrella in",PibrellaIn);
|
||||||
|
RED.nodes.registerType("rpi-pibrella out",PibrellaOut);
|
||||||
|
@ -20,8 +20,7 @@ var fs = require('fs');
|
|||||||
|
|
||||||
// check if /dev/ledborg exists - if not then don't even show the node.
|
// check if /dev/ledborg exists - if not then don't even show the node.
|
||||||
if (!fs.existsSync("/dev/ledborg")) {
|
if (!fs.existsSync("/dev/ledborg")) {
|
||||||
//util.log("[78-ledborg.js] Warning: PiBorg hardware : LedBorg not found");
|
throw "Info : PiBorg hardware : LedBorg not found";
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function LedBorgNode(n) {
|
function LedBorgNode(n) {
|
||||||
|
Loading…
Reference in New Issue
Block a user