1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

Pi no longer needs root workaround to access gpio

(stops PAM logging in Node-RED log under systemd)
This commit is contained in:
Dave Conway-Jones 2015-12-12 15:13:15 +00:00
parent f93179d946
commit a074bcfd56
3 changed files with 17 additions and 6 deletions

View File

@ -325,6 +325,7 @@
<option value="7" data-i18n="rpi-gpio.any"></option>
</select>
</div>
<br/>
<div class="form-row">
<label for="node-input-name"><i class="fa fa-tag"></i> <span data-i18n="common.label.name"></span></label>
<input type="text" id="node-input-name" data-i18n="[placeholder]common.label.name">

View File

@ -1,5 +1,5 @@
/**
* Copyright 2013,2014 IBM Corp.
* Copyright 2013,2015 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -19,8 +19,8 @@ module.exports = function(RED) {
var exec = require('child_process').exec;
var spawn = require('child_process').spawn;
var fs = require('fs');
var gpioCommand = __dirname+'/nrgpio';
s
var gpioCommand = __dirname+'/nrgpio.py';
if (!fs.existsSync("/dev/ttyAMA0")) { // unlikely if not on a Pi
//RED.log.info(RED._("rpi-gpio.errors.ignorenode"));
@ -231,7 +231,7 @@ module.exports = function(RED) {
this.butt = n.butt || 7;
var node = this;
node.child = spawn(gpioCommand+".py", ["mouse",node.butt]);
node.child = spawn(gpioCommand, ["mouse",node.butt]);
node.status({fill:"green",shape:"dot",text:"common.status.ok"});
node.child.stdout.on('data', function (data) {

View File

@ -23,7 +23,7 @@ if sys.version_info >= (3,0):
print("Sorry - currently only configured to work with python 2.x")
sys.exit(1)
if len(sys.argv) > 1:
if len(sys.argv) > 2:
cmd = sys.argv[1].lower()
pin = int(sys.argv[2])
GPIO.setmode(GPIO.BOARD)
@ -193,5 +193,15 @@ if len(sys.argv) > 1:
file.close()
sys.exit(0)
elif len(sys.argv) > 1:
cmd = sys.argv[1].lower()
if cmd == "rev":
print GPIO.RPI_REVISION
elif cmd == "ver":
print GPIO.VERSION
else:
print "Bad parameters - {in|out|pwm} {pin} {value|up|down}"
print "Bad parameters - in|out|pwm|buzz|byte|borg|mouse|ver {pin} {value|up|down}"
print " only ver (gpio version) and rev (board revision) accept no pin parameter."
else:
print "Bad parameters - in|out|pwm|buzz|byte|borg|mouse|ver {pin} {value|up|down}"