Gives ownership of a pin back to the operating system Without calling this function, the pin will remain in the current state even after the sketch has been closed. @param pin GPIO pin @see pinMode @webref GPIO @webBrief Gives ownership of a pin back to the operating system
(int pin)
| 506 | * @webBrief Gives ownership of a pin back to the operating system |
| 507 | */ |
| 508 | public static void releasePin(int pin) { |
| 509 | checkValidPin(pin); |
| 510 | |
| 511 | if (NativeInterface.isSimulated()) { |
| 512 | return; |
| 513 | } |
| 514 | |
| 515 | String fn = "/sys/class/gpio/unexport"; |
| 516 | int ret = NativeInterface.writeFile(fn, Integer.toString(pin)); |
| 517 | if (ret < 0) { |
| 518 | if (ret == -2) { // ENOENT |
| 519 | System.err.println("Make sure your kernel is compiled with GPIO_SYSFS enabled"); |
| 520 | } |
| 521 | // EINVAL is returned when trying to unexport pins that weren't exported to begin with, ignore this case |
| 522 | if (ret != -22) { |
| 523 | throw new RuntimeException(NativeInterface.getError(ret)); |
| 524 | } |
| 525 | } |
| 526 | } |
| 527 | |
| 528 | |
| 529 | /** |
nothing calls this directly
no test coverage detected