mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
IO: Fix pinMode() retry logic
If the file node is not accessible yet, NativeInterface.writeFile() will return -EACCES instead of -EPERM. Thanks @msurguy for reporting this and testing.
This commit is contained in:
@@ -389,14 +389,14 @@ public class GPIO {
|
||||
}
|
||||
|
||||
// we need to give udev some time to change the file permissions behind our back
|
||||
// retry for 500ms when writing to the file fails with -EPERM
|
||||
// retry for 500ms when writing to the file fails with -EACCES
|
||||
long start = System.currentTimeMillis();
|
||||
do {
|
||||
ret = NativeInterface.writeFile(fn, out);
|
||||
if (ret == -1) {
|
||||
if (ret == -13) {
|
||||
Thread.yield();
|
||||
}
|
||||
} while (ret == -1 && System.currentTimeMillis()-start < 500);
|
||||
} while (ret == -13 && System.currentTimeMillis()-start < 500);
|
||||
|
||||
if (ret < 0) {
|
||||
throw new RuntimeException(fn + ": " + NativeInterface.getError(ret));
|
||||
|
||||
Reference in New Issue
Block a user