@signalk/streams 4.2.0 → 4.3.0
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/gpiod-seatalk.js +21 -8
- package/package.json +1 -1
package/gpiod-seatalk.js
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
const Execute = require('./execute')
|
|
24
24
|
|
|
25
25
|
const cmd = `
|
|
26
|
-
import gpiod, sys, datetime
|
|
26
|
+
import gpiod, sys, datetime, glob
|
|
27
27
|
|
|
28
28
|
ST_PIN = 20
|
|
29
29
|
|
|
@@ -38,13 +38,26 @@ if gpiod_v != 1 and gpiod_v !=2:
|
|
|
38
38
|
print("Error: gpiod version {} is not supported".format(gpiod.__version__))
|
|
39
39
|
sys.exit()
|
|
40
40
|
|
|
41
|
-
# detect
|
|
41
|
+
# detect gpiochip, based on model of Raspberry Pi
|
|
42
42
|
with open("/proc/device-tree/model") as f:
|
|
43
43
|
model = f.read()
|
|
44
44
|
if "Pi 4" in model or "Pi 3" in model:
|
|
45
45
|
gpio_chip = "gpiochip0"
|
|
46
46
|
elif "Pi 5" in model:
|
|
47
|
-
gpio_chip = "
|
|
47
|
+
gpio_chip = "gpiochip0"
|
|
48
|
+
if gpiod_v == 1:
|
|
49
|
+
for c in gpiod.ChipIter():
|
|
50
|
+
if c.label() == "pinctrl-rp1":
|
|
51
|
+
gpio_chip = c.name()
|
|
52
|
+
break
|
|
53
|
+
else:
|
|
54
|
+
for g in glob.glob("/dev/gpiochip*"):
|
|
55
|
+
if gpiod.is_gpiochip_device(g):
|
|
56
|
+
with gpiod.Chip(g) as c:
|
|
57
|
+
info = c.get_info()
|
|
58
|
+
if info.label == "pinctrl-rp1":
|
|
59
|
+
gpio_chip = info.name
|
|
60
|
+
break
|
|
48
61
|
else:
|
|
49
62
|
print("Warning: Use of {} is untested".format(model))
|
|
50
63
|
gpio_chip = "gpiochip0"
|
|
@@ -314,12 +327,12 @@ if __name__ == "__main__":
|
|
|
314
327
|
if sys.argv[2] == "true":
|
|
315
328
|
pol = 1
|
|
316
329
|
|
|
317
|
-
st = st1rx()
|
|
318
|
-
if st.open(pin=gpio, invert=pol) == False:
|
|
319
|
-
print("Error: Failed to open Seatalk1 pin")
|
|
320
|
-
sys.exit()
|
|
321
|
-
|
|
322
330
|
try:
|
|
331
|
+
st = st1rx()
|
|
332
|
+
if st.open(pin=gpio, invert=pol) == False:
|
|
333
|
+
print("Error: Failed to open Seatalk1 pin")
|
|
334
|
+
sys.exit()
|
|
335
|
+
|
|
323
336
|
st_msg = ""
|
|
324
337
|
st_start = False
|
|
325
338
|
while True:
|