Try not returning but calling?

This commit is contained in:
Skylar Grant 2024-08-18 13:50:54 -04:00
parent 27cc6bafe5
commit f0ad09fadd

View File

@ -47,18 +47,18 @@ module.exports = {
togglePin(pin, callback) {
exec(`python3 src/python/gpio_interface.py toggle ${pin}`, (error, stdout, stderr) => {
if (error) {
return callback(error);
callback(error);
}
if (stderr) {
return callback(new Error(stderr));
callback(new Error(stderr));
}
});
},
// Calls the GPIO Interface script to read a pin's state
readPin(pin, callback) {
exec(`python3 src/python/gpio_interface.py read ${pin}`, (error, stdout, stderr) => {
if (error) return callback(error);
if (stderr) return callback(new Error(stderr));
if (error) callback(error);
if (stderr) callback(new Error(stderr));
callback(null, stdout.trim());
});
},
@ -66,10 +66,10 @@ module.exports = {
setPin(pin, state, callback) {
exec(`python3 src/python/gpio_interface.py set ${pin} ${state}`, (error, stdout, stderr) => {
if (error) {
return callback(error);
callback(error);
}
if (stderr) {
return callback(new Error(stderr));
callback(new Error(stderr));
}
callback(null);
})