Gives ownership of a channel back to the operating system @webref
()
| 110 | * @webref |
| 111 | */ |
| 112 | public void close() { |
| 113 | if (NativeInterface.isSimulated()) { |
| 114 | return; |
| 115 | } |
| 116 | |
| 117 | // XXX: implicit clear()? |
| 118 | // XXX: also check GPIO |
| 119 | |
| 120 | String fn = "/sys/class/pwm/" + chip + "/unexport"; |
| 121 | int ret = NativeInterface.writeFile(fn, Integer.toString(channel)); |
| 122 | if (ret < 0) { |
| 123 | if (ret == -2) { // ENOENT |
| 124 | System.err.println("Make sure your kernel is compiled with PWM_SYSFS enabled and you have the necessary PWM driver for your platform"); |
| 125 | } |
| 126 | // XXX: check |
| 127 | // EINVAL is also returned when trying to unexport pins that weren't exported to begin with |
| 128 | throw new RuntimeException(NativeInterface.getError(ret)); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | |
| 133 | /** |
nothing calls this directly
no test coverage detected