examples: gpio-tool.js now catches exception if invalid pin is specified
Signed-off-by: Henry Bruce <henry.bruce@intel.com>
This commit is contained in:
committed by
Brendan Le Foll
parent
143bc38e47
commit
6c83886a51
@@ -62,6 +62,7 @@ function onPinLevelChange() {
|
|||||||
|
|
||||||
function monitorPin() {
|
function monitorPin() {
|
||||||
var pinNumber = arguments[0];
|
var pinNumber = arguments[0];
|
||||||
|
try {
|
||||||
var pin = new mraa.Gpio(pinNumber);
|
var pin = new mraa.Gpio(pinNumber);
|
||||||
pin.dir(mraa.DIR_IN);
|
pin.dir(mraa.DIR_IN);
|
||||||
pin.isr(mraa.EDGE_BOTH, onPinLevelChange);
|
pin.isr(mraa.EDGE_BOTH, onPinLevelChange);
|
||||||
@@ -69,6 +70,9 @@ function monitorPin() {
|
|||||||
rl.close();
|
rl.close();
|
||||||
pin.isrExit();
|
pin.isrExit();
|
||||||
});
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err.message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const args = process.argv;
|
const args = process.argv;
|
||||||
|
|||||||
Reference in New Issue
Block a user