Gives ownership of a pin back to the operating system @param pin GPIO pin @see pinMode @webref
(int pin)
| 438 | * @webref |
| 439 | */ |
| 440 | public static void releasePin(int pin) { |
| 441 | checkValidPin(pin); |
| 442 | |
| 443 | if (NativeInterface.isSimulated()) { |
| 444 | return; |
| 445 | } |
| 446 | |
| 447 | String fn = "/sys/class/gpio/unexport"; |
| 448 | int ret = NativeInterface.writeFile(fn, Integer.toString(pin)); |
| 449 | if (ret < 0) { |
| 450 | if (ret == -2) { // ENOENT |
| 451 | System.err.println("Make sure your kernel is compiled with GPIO_SYSFS enabled"); |
| 452 | } |
| 453 | // EINVAL is returned when trying to unexport pins that weren't exported to begin with, ignore this case |
| 454 | if (ret != -22) { |
| 455 | throw new RuntimeException(NativeInterface.getError(ret)); |
| 456 | } |
| 457 | } |
| 458 | } |
| 459 | |
| 460 | |
| 461 | /** |
nothing calls this directly
no test coverage detected