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