node-red-node-pi-gpio 2.0.0-beta2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/36-rpi-gpio.js +3 -3
- package/locales/de/36-rpi-gpio.json +74 -72
- package/nrgpio +5 -14
- package/nrgpio.py +9 -28
- package/package.json +3 -2
- package/testgpio +8 -0
- package/testgpio.py +0 -1
- package/node-red-node-pi-gpio-2.0.0.tgz +0 -0
package/36-rpi-gpio.js
CHANGED
|
@@ -5,7 +5,7 @@ module.exports = function(RED) {
|
|
|
5
5
|
var exec = require('child_process').exec;
|
|
6
6
|
var spawn = require('child_process').spawn;
|
|
7
7
|
|
|
8
|
-
var testCommand = __dirname+'/testgpio
|
|
8
|
+
var testCommand = __dirname+'/testgpio'
|
|
9
9
|
var gpioCommand = __dirname+'/nrgpio';
|
|
10
10
|
var allOK = true;
|
|
11
11
|
|
|
@@ -225,7 +225,7 @@ module.exports = function(RED) {
|
|
|
225
225
|
var node = this;
|
|
226
226
|
|
|
227
227
|
if (allOK === true) {
|
|
228
|
-
node.child = spawn(gpioCommand
|
|
228
|
+
node.child = spawn(gpioCommand, ["mouse",node.butt]);
|
|
229
229
|
node.status({fill:"green",shape:"dot",text:"rpi-gpio.status.ok"});
|
|
230
230
|
|
|
231
231
|
node.child.stdout.on('data', function (data) {
|
|
@@ -276,7 +276,7 @@ module.exports = function(RED) {
|
|
|
276
276
|
var node = this;
|
|
277
277
|
|
|
278
278
|
var doConnect = function() {
|
|
279
|
-
node.child = spawn(gpioCommand
|
|
279
|
+
node.child = spawn(gpioCommand, ["kbd","0"]);
|
|
280
280
|
node.status({fill:"green",shape:"dot",text:"rpi-gpio.status.ok"});
|
|
281
281
|
|
|
282
282
|
node.child.stdout.on('data', function (data) {
|
|
@@ -1,73 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
"
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
{
|
|
2
|
+
"rpi-gpio": {
|
|
3
|
+
"label": {
|
|
4
|
+
"gpiopin": "GPIO",
|
|
5
|
+
"selectpin": "Pinauswahl",
|
|
6
|
+
"resistor": "Widerstand",
|
|
7
|
+
"readinitial": "Initalzustand des Pins bei Übernahme/Neustart lesen",
|
|
8
|
+
"type": "Typ",
|
|
9
|
+
"initpin": "Pin-Zustand initialisieren",
|
|
10
|
+
"debounce": "Entprellung",
|
|
11
|
+
"freq": "Frequenz",
|
|
12
|
+
"button": "Taste",
|
|
13
|
+
"pimouse": "Pi-Maus",
|
|
14
|
+
"pikeyboard": "Pi-Tastatur",
|
|
15
|
+
"left": "Links",
|
|
16
|
+
"right": "Rechts",
|
|
17
|
+
"middle": "Mitte"
|
|
18
|
+
},
|
|
19
|
+
"resistor": {
|
|
20
|
+
"none": "Kein",
|
|
21
|
+
"pullup": "Pull-Up",
|
|
22
|
+
"pulldown": "Pull-Down"
|
|
23
|
+
},
|
|
24
|
+
"digout": "Digitaler Ausgang",
|
|
25
|
+
"pwmout": "PWM-Ausgang",
|
|
26
|
+
"servo": "Servo-Ausgang",
|
|
27
|
+
"initpin0": "Pin-Initalzustand low (0)",
|
|
28
|
+
"initpin1": "Pin-Initalzustand high (1)",
|
|
29
|
+
"left": "Links",
|
|
30
|
+
"right": "Rechts",
|
|
31
|
+
"middle": "Mitte",
|
|
32
|
+
"any": "Beliebig",
|
|
33
|
+
"pinname": "Pin",
|
|
34
|
+
"alreadyuse": "bereits im Gebrauch",
|
|
35
|
+
"alreadyset": "bereits festgelegt als",
|
|
36
|
+
"tip": {
|
|
37
|
+
"pin": "<b>Verwendete Pins:</b> ",
|
|
38
|
+
"in": "<b>Tipp:</b> Es werden nur die digitale Eingänge unterstützt. Der Eingang muss 0 oder 1 sein",
|
|
39
|
+
"dig": "<b>Tipp:</b> Für den digitalen Ausgang muss der Node-Eingangswert 0 oder 1 sein",
|
|
40
|
+
"pwm": "<b>Tipp:</b> Für die PWM-Ausgabe muss der Node-Eingangswert zwischen 0 und 100 liegen. Hohen Frequenzen können die CPU mehr beanspruchen als erwartet.",
|
|
41
|
+
"ser": "<b>Tipp:</b> Für die Servo-Ausgabe muss der Node-Eingangswert zwischen 0 und 100 eingegeben werden. 50 ist die Mitte."
|
|
42
|
+
},
|
|
43
|
+
"types": {
|
|
44
|
+
"digout": "Digitaler Ausgang",
|
|
45
|
+
"input": "Eingang",
|
|
46
|
+
"pullup": "Eingang mit Pull-Up",
|
|
47
|
+
"pulldown": "Eingabe mit Pull-Down",
|
|
48
|
+
"pwmout": "PWM-Ausgang",
|
|
49
|
+
"servo": "Servo-Ausgang"
|
|
50
|
+
},
|
|
51
|
+
"status": {
|
|
52
|
+
"stopped": "Gestoppt",
|
|
53
|
+
"closed": "Geschlossen",
|
|
54
|
+
"not-running": "Nicht aktiv",
|
|
55
|
+
"not-available": "Nicht verfügbar",
|
|
56
|
+
"na": "Nicht anwendbar: __Wert__",
|
|
57
|
+
"ok": "OK"
|
|
58
|
+
},
|
|
59
|
+
"errors": {
|
|
60
|
+
"ignorenode": "Raspberry-Pi-spezifische Nodes inaktiv gesetzt",
|
|
61
|
+
"version": "Abrufen der Version vom Pi fehlgeschlagen",
|
|
62
|
+
"sawpitype": "Saw-Pi-Typ",
|
|
63
|
+
"libnotfound": "RPi.GPIO-Python-Bibliothek nicht gefunden",
|
|
64
|
+
"alreadyset": "GPIO-Pin __pin__ ist bereits festgelegt als Typ: __type__",
|
|
65
|
+
"invalidpin": "Ungültiger GPIO-Pin",
|
|
66
|
+
"invalidinput": "Ungültige Eingabe",
|
|
67
|
+
"needtobeexecutable": "__command__ muss ausführbar sein",
|
|
68
|
+
"mustbeexecutable": "nrgpio muss ausführbar sein",
|
|
69
|
+
"commandnotfound": "nrgpio-Befehl nicht gefunden",
|
|
70
|
+
"commandnotexecutable": "nrgpio-Befehl nicht ausführbar",
|
|
71
|
+
"error": "Fehler: __error__",
|
|
72
|
+
"pythoncommandnotfound": "nrgpio-Python-Befehl nicht aktiv"
|
|
73
|
+
}
|
|
72
74
|
}
|
|
73
|
-
|
|
75
|
+
}
|
package/nrgpio
CHANGED
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
#
|
|
2
|
+
|
|
3
|
+
python_cmd='python3'
|
|
4
|
+
# Fallback to Python 2, if Python 3 is not available
|
|
5
|
+
command -v python3 > /dev/null || python_cmd=`python`
|
|
15
6
|
|
|
16
7
|
BASEDIR=$(dirname $0)
|
|
17
|
-
|
|
8
|
+
$python_cmd -u $BASEDIR/nrgpio.py $@
|
package/nrgpio.py
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/python
|
|
2
|
-
#
|
|
3
|
-
# Copyright JS Foundation and other contributors, http://js.foundation
|
|
4
|
-
#
|
|
5
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
-
# you may not use this file except in compliance with the License.
|
|
7
|
-
# You may obtain a copy of the License at
|
|
8
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
-
# See the License for the specific language governing permissions and
|
|
13
|
-
# limitations under the License.
|
|
14
|
-
#
|
|
15
1
|
|
|
16
2
|
# Import library functions we need
|
|
17
3
|
import RPi.GPIO as GPIO
|
|
@@ -185,24 +171,19 @@ if len(sys.argv) > 2:
|
|
|
185
171
|
data = 0
|
|
186
172
|
|
|
187
173
|
elif cmd == "mouse": # catch mice button events
|
|
188
|
-
|
|
174
|
+
f = open( "/dev/input/mice", "rb" )
|
|
189
175
|
oldbutt = 0
|
|
190
176
|
|
|
191
|
-
def getMouseEvent():
|
|
192
|
-
global oldbutt
|
|
193
|
-
global pin
|
|
194
|
-
buf = file.read(3)
|
|
195
|
-
pin = pin & 0x07
|
|
196
|
-
button = ord( buf[0] ) & pin # mask out just the required button(s)
|
|
197
|
-
if button != oldbutt: # only send if changed
|
|
198
|
-
oldbutt = button
|
|
199
|
-
print(button)
|
|
200
|
-
|
|
201
177
|
while True:
|
|
202
178
|
try:
|
|
203
|
-
|
|
179
|
+
buf = f.read(3)
|
|
180
|
+
pin = pin & 0x07
|
|
181
|
+
button = struct.unpack('3b',buf)[0] & pin # mask out just the required button(s)
|
|
182
|
+
if button != oldbutt: # only send if changed
|
|
183
|
+
oldbutt = button
|
|
184
|
+
print(button)
|
|
204
185
|
except:
|
|
205
|
-
|
|
186
|
+
f.close()
|
|
206
187
|
sys.exit(0)
|
|
207
188
|
|
|
208
189
|
elif cmd == "kbd": # catch keyboard button events
|
|
@@ -210,7 +191,7 @@ if len(sys.argv) > 2:
|
|
|
210
191
|
while not os.path.isdir("/dev/input/by-path"):
|
|
211
192
|
sleep(10)
|
|
212
193
|
infile = subprocess.check_output("ls /dev/input/by-path/ | grep -m 1 'kbd'", shell=True).strip()
|
|
213
|
-
infile_path = "/dev/input/by-path/" + infile
|
|
194
|
+
infile_path = "/dev/input/by-path/" + infile.decode("utf-8")
|
|
214
195
|
EVENT_SIZE = struct.calcsize('llHHI')
|
|
215
196
|
file = open(infile_path, "rb")
|
|
216
197
|
event = file.read(EVENT_SIZE)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-red-node-pi-gpio",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "The basic Node-RED node for Pi GPIO",
|
|
5
5
|
"dependencies" : {
|
|
6
6
|
},
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
12
|
-
"url": "https://github.com/node-red/node-red-nodes
|
|
12
|
+
"url": "https://github.com/node-red/node-red-nodes.git",
|
|
13
|
+
"directory": "tree/master/hardware/PiGpio"
|
|
13
14
|
},
|
|
14
15
|
"keywords": [
|
|
15
16
|
"node-red", "Pi", "GPIO", "PiGpio"
|
package/testgpio
ADDED
package/testgpio.py
CHANGED
|
Binary file
|