rpi-io 1.2.2 → 1.2.4
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/README.md +10 -0
- package/esm/rio.mjs +36 -8
- package/history.md +6 -0
- package/package.json +1 -1
- package/scr/test.js +3 -0
package/README.md
CHANGED
|
@@ -334,6 +334,16 @@ servo.pwmDuty(1500000)
|
|
|
334
334
|
|
|
335
335
|
|
|
336
336
|
### Utility functions
|
|
337
|
+
#### Rio.disableAll()
|
|
338
|
+
|
|
339
|
+
To to disable all instances
|
|
340
|
+
|
|
341
|
+
##### Example
|
|
342
|
+
|
|
343
|
+
```javascript
|
|
344
|
+
Rio.disableAll()
|
|
345
|
+
```
|
|
346
|
+
|
|
337
347
|
#### Rio.stopMonitoring()
|
|
338
348
|
|
|
339
349
|
To stop monitoring subprocess when leaving your app script or in case of failure. This prevents having a runaway subprocess that could block a new call to the `monitor()` method.
|
package/esm/rio.mjs
CHANGED
|
@@ -133,12 +133,30 @@ export class Rio {
|
|
|
133
133
|
*/
|
|
134
134
|
disable() {
|
|
135
135
|
if (Rio.instances.has(this.gpio)) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.
|
|
139
|
-
|
|
136
|
+
|
|
137
|
+
// Stop watch process
|
|
138
|
+
if (this.type === "in") {
|
|
139
|
+
this.watch.edge = "stop"
|
|
140
|
+
this.watch.callback = false
|
|
141
|
+
if (this.watch.process !== null) {
|
|
142
|
+
this.watch.process.kill("SIGTERM")
|
|
143
|
+
log("monitoring of gpio", this.gpio, "has been stopped")
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
// Disable signal then unexport channel
|
|
149
|
+
if (this.type === "pwm") {
|
|
150
|
+
writeFileSync(this.pathChannel + "enable", "0")
|
|
151
|
+
this.enabled = false
|
|
152
|
+
writeFileSync(this.pathPwm + "unexport", this.channel)
|
|
153
|
+
this.exported = true
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Delete entry in instance Map
|
|
140
157
|
Rio.instances.delete(this.gpio)
|
|
141
158
|
log("gpio", this.gpio, "has been disabled")
|
|
159
|
+
this.gpio = -1
|
|
142
160
|
} else {
|
|
143
161
|
log("gpio", this.gpio, "is already disabled")
|
|
144
162
|
}
|
|
@@ -532,16 +550,25 @@ Rio.version = () => {
|
|
|
532
550
|
*/
|
|
533
551
|
Rio.stopMonitoring = () => {
|
|
534
552
|
Rio.instances.forEach((that) => {
|
|
553
|
+
that.watch.edge = "stop"
|
|
554
|
+
that.watch.callback = false
|
|
535
555
|
if (that.watch.process !== null) {
|
|
536
556
|
that.watch.process.kill("SIGTERM")
|
|
537
|
-
that.watch.edge = "stop"
|
|
538
|
-
that.watch.callback = false
|
|
539
|
-
that.watch.process = null
|
|
540
557
|
log("monitoring of gpio", that.gpio, "has been stopped")
|
|
541
558
|
}
|
|
542
559
|
})
|
|
543
560
|
}
|
|
544
561
|
|
|
562
|
+
/** ------------------------------------------------------------------
|
|
563
|
+
* @function Rio.disableAll
|
|
564
|
+
* @description Disable all instances
|
|
565
|
+
*/
|
|
566
|
+
Rio.disableAll = () => {
|
|
567
|
+
Rio.instances.forEach((that) => {
|
|
568
|
+
that.disable()
|
|
569
|
+
})
|
|
570
|
+
}
|
|
571
|
+
|
|
545
572
|
/** ------------------------------------------------------------------
|
|
546
573
|
* @function Rio.cpuInfo
|
|
547
574
|
* @description Read '/proc/cpuinfo' and store it for further call
|
|
@@ -641,7 +668,8 @@ Rio.log = log
|
|
|
641
668
|
/** ------------------------------------------------------------------
|
|
642
669
|
* @function Rio.trap
|
|
643
670
|
*/
|
|
644
|
-
Rio.
|
|
671
|
+
Rio.trap = trap
|
|
672
|
+
|
|
645
673
|
// -------------------------------------------------------------------
|
|
646
674
|
// EoF
|
|
647
675
|
// -------------------------------------------------------------------
|
package/history.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
1.2.4 - Nov 12, 2025
|
|
2
|
+
===================
|
|
3
|
+
* fix in `Rio.stopMonitoring()`
|
|
4
|
+
* fix in method `disable()`
|
|
5
|
+
* New utility function: `Rio.disableAll()`
|
|
6
|
+
|
|
1
7
|
1.2.2 - Nov 10, 2025
|
|
2
8
|
===================
|
|
3
9
|
* Change utility API function name from `Rio.log` to `Rio.logCfg`.
|
package/package.json
CHANGED