Skip to content

Commit 243b4a7

Browse files
committed
I/O: Don't throw an exception when trying to release unused pins
1 parent 73d1376 commit 243b4a7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

java/libraries/io/src/processing/io/GPIO.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,10 @@ public static void releasePin(int pin) {
492492
if (ret == -2) { // ENOENT
493493
System.err.println("Make sure your kernel is compiled with GPIO_SYSFS enabled");
494494
}
495-
// EINVAL is also returned when trying to unexport pins that weren't exported to begin with
496-
throw new RuntimeException(NativeInterface.getError(ret));
495+
// EINVAL is returned when trying to unexport pins that weren't exported to begin with, ignore this case
496+
if (ret != -22) {
497+
throw new RuntimeException(NativeInterface.getError(ret));
498+
}
497499
}
498500
}
499501

0 commit comments

Comments
 (0)