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 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.py'
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+".py", ["mouse",node.butt]);
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+".py", ["kbd","0"]);
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
- "rpi-gpio" : {
2
- "label" : {
3
- "gpiopin" : "GPIO",
4
- "selectpin" : "Auswahlstift",
5
- "resistor" : "Widerstand?",
6
- "readinitial" : "Anfangsstatus des Pins bei Implementierung/Neustart lesen?",
7
- "type" : "Typ",
8
- "initpin" : "Pin-Status initialisieren?",
9
- "debounce" : "Debounce",
10
- "freq" : "Frequenz",
11
- "button" : "Knopf",
12
- "pimouse" : "Pi-Maus",
13
- "pikeyboard" : "Pi-Tastatur",
14
- "left" : "Links",
15
- "right" : "Rechts",
16
- "middle" : "Mitte"
17
- },
18
- "resistor" : {
19
- "none" : "keine",
20
- "pullup" : "pullup",
21
- "pulldown" : "Pulldown"
22
- },
23
- "digout" : "Digitale Ausgabe",
24
- "pwmout" : "PWM-Ausgabe",
25
- "servo" : "Servo-Ausgabe",
26
- "initpin0" : "Anfangsstand des Pin-Niedrig (0)",
27
- "initpin1" : "Anfangsebene von Pin-High (1)",
28
- "left" : "links",
29
- "right" : "rechts",
30
- "middle" : "Mitte",
31
- "any" : "beliebig",
32
- "pinname" : "Pin",
33
- "alreadyuse" : "bereits im Gebrauch",
34
- "alreadyset" : "bereits festgelegt als",
35
- "tip" : {
36
- "pin" : "<b> Verwender Pins </b>: ",
37
- "in" : "Tipp: Es wird nur die digitale Eingabe unterstützt. Die Eingabe muss 0 oder 1 sein.",
38
- "dig" : "Tipp: Für die digitale Ausgabe muss der Wert 0 oder 1 sein.",
39
- "pwm" : "Tipp: Für die PWM-Ausgabe muss der Wert zwischen 0 und 100 liegen; die Einstellung der Hochfrequenz kann mehr CPU beanspruchen als erwartet.",
40
- "ser" : "<b> Tipp </b>: Für die Servo-Ausgabe muss ein Wert zwischen 0 und 100 eingegeben werden. 50 ist das Zentrum."
41
- },
42
- "types" : {
43
- "digout" : "digitale Ausgabe",
44
- "input" : "Eingabe",
45
- "pullup" : "Eingabe mit Pull-up",
46
- "pulldown" : "Eingabe mit Pull-down",
47
- "pwmout" : "PWM-Ausgabe",
48
- "servo" : "Servo-Ausgabe"
49
- },
50
- "status" : {
51
- "stopped" : "Gestoppt",
52
- "closed" : "geschlossen",
53
- "not-running" : "nicht aktiv",
54
- "not-available" : "nicht verfügbar",
55
- "na" : "N/A: __Wert__",
56
- "ok": "OK"
57
- },
58
- "errors" : {
59
- "ignorenode" : "Raspberry Pi-spezifische Nodes inaktiv",
60
- "version" : "Abrufen der Version von Pi fehlgeschlagen",
61
- "sawpitype" : "Saw-Pi-Typ",
62
- "libnotfound" : "Pi RPi.GPIO-Python-Bibliothek nicht gefunden",
63
- "alreadyset" : "GPIO-Stift __pin__ ist bereits als Typ festgelegt: __type__",
64
- "invalidpin" : "Ungültiger GPIO-Pin",
65
- "invalidinput" : "Ungültige Eingabe",
66
- "needtobeexecutable" : "__command__ muss ausführbar sein",
67
- "mustbeexecutable" : "nrgpio muss ausführbar sein",
68
- "commandnotfound" : "Befehl 'nrgpio' nicht gefunden",
69
- "commandnotexecutable" : "nrgpio-Befehl nicht ausführbar",
70
- "error" : "Fehler: __error__",
71
- "pythoncommandnotfound" : "Befehl 'nrgpio python' nicht aktiv"
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
- # 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
- #
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
- python -u $BASEDIR/nrgpio.py $@
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
- file = open( "/dev/input/mice", "rb" )
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
- getMouseEvent()
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
- file.close()
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.0-beta2",
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/tree/master/hardware/PiGpio"
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
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
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`
6
+
7
+ BASEDIR=$(dirname $0)
8
+ $python_cmd -u $BASEDIR/testgpio.py $@
package/testgpio.py CHANGED
@@ -1,4 +1,3 @@
1
- #!/usr/bin/python
2
1
  import sys
3
2
  try:
4
3
  import RPi.GPIO as GPIO
Binary file