From d52f9dcd30f1fa8724773cead3b629574550497c Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 2 Nov 2016 10:02:07 +0000 Subject: [PATCH] detect Pi updates for LEDborg, mcp3008 and neopixel --- hardware/LEDborg/78-ledborg.js | 8 +++++--- hardware/LEDborg/package.json | 2 +- hardware/mcp3008/package.json | 2 +- hardware/mcp3008/pimcp3008.js | 8 ++++++-- hardware/neopixel/neopixel.js | 6 ++++-- hardware/neopixel/package.json | 2 +- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/hardware/LEDborg/78-ledborg.js b/hardware/LEDborg/78-ledborg.js index e1e50245..8bcf7d66 100644 --- a/hardware/LEDborg/78-ledborg.js +++ b/hardware/LEDborg/78-ledborg.js @@ -24,9 +24,11 @@ module.exports = function(RED) { var gpioCommand = __dirname+'/nrgpio'; - if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi - //util.log("Info : Ignoring Raspberry LEDborg specific node."); - throw "Info : Ignoring Raspberry LEDborg specific node."; + try { + var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString(); + if (cpuinfo.indexOf(": BCM") === -1) { throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); } + } catch(err) { + throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); } if (!fs.existsSync("/usr/share/doc/python-rpi.gpio")) { diff --git a/hardware/LEDborg/package.json b/hardware/LEDborg/package.json index 1569bf4a..cfa155eb 100644 --- a/hardware/LEDborg/package.json +++ b/hardware/LEDborg/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-ledborg", - "version" : "0.0.15", + "version" : "0.0.16", "description" : "A Node-RED node to control a PiBorg LedBorg board for a Raspberry Pi.", "dependencies" : { }, diff --git a/hardware/mcp3008/package.json b/hardware/mcp3008/package.json index 722daf57..d7678b0b 100644 --- a/hardware/mcp3008/package.json +++ b/hardware/mcp3008/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pi-mcp3008", - "version" : "0.0.2", + "version" : "0.0.3", "description" : "A Node-RED node to read from the MCP3008 Analogue to Digital Converter", "dependencies" : { "mcp-spi-adc": "^0.0.1" diff --git a/hardware/mcp3008/pimcp3008.js b/hardware/mcp3008/pimcp3008.js index 6cc34591..017f418a 100644 --- a/hardware/mcp3008/pimcp3008.js +++ b/hardware/mcp3008/pimcp3008.js @@ -18,8 +18,12 @@ module.exports = function(RED) { "use strict"; var fs = require('fs'); // unlikely if not on a Pi - try { fs.statSync("/dev/ttyAMA0"); } - catch(err) { throw "Info : Ignoring Raspberry Pi specific node"; } + try { + var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString(); + if (cpuinfo.indexOf(": BCM") === -1) { throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); } + } catch(err) { + throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); + } var mcpadc = require('mcp-spi-adc'); var mcp3008 = []; diff --git a/hardware/neopixel/neopixel.js b/hardware/neopixel/neopixel.js index 1d590de2..5c8d5e88 100644 --- a/hardware/neopixel/neopixel.js +++ b/hardware/neopixel/neopixel.js @@ -22,8 +22,10 @@ module.exports = function(RED) { var piCommand = __dirname+'/neopix'; - if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi - //RED.log.info(RED._("rpi-gpio.errors.ignorenode")); + try { + var cpuinfo = fs.readFileSync("/proc/cpuinfo").toString(); + if (cpuinfo.indexOf(": BCM") === -1) { throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); } + } catch(err) { throw "Info : "+RED._("rpi-gpio.errors.ignorenode"); } diff --git a/hardware/neopixel/package.json b/hardware/neopixel/package.json index 27444e86..cfd122b4 100644 --- a/hardware/neopixel/package.json +++ b/hardware/neopixel/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-pi-neopixel", - "version" : "0.0.12", + "version" : "0.0.13", "description" : "A Node-RED node to output to a neopixel (ws2812) string of LEDS from a Raspberry Pi.", "dependencies" : { },