Open dionesxxx opened 5 years ago
Are you adding any delays between opening/closing/opening? Perhaps there's some asynchronous logic that isn't ready by the next call.
Basically i did the code below inside onCreate() method.
ButtonInputDriver buttonInputDriver;
for (int i = 0; i <= 500; i++) {
buttonInputDriver = new ButtonInputDriver(SENSOR_ENTRY, Button.LogicState.PRESSED_WHEN_HIGH, ENTRY);
buttonInputDriver.setDebounceDelay(0);
buttonInputDriver.register();
buttonInputDriver.close();
}
I also tried putting a time delay
ButtonInputDriver buttonInputDriver;
for (int i = 0; i <= 500; i++) {
buttonInputDriver = new ButtonInputDriver(SENSOR_ENTRY, Button.LogicState.PRESSED_WHEN_HIGH, ENTRY);
buttonInputDriver.setDebounceDelay(0);
buttonInputDriver.register();
buttonInputDriver.close();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Both cases I have an IllegalArgumentException after 300 to 350 calls of the register() method.
This may be something to put in the Android Things issue tracker, as it may be more of a platform bug.
This probably shouldn't be done in a normal application though, for what it's worth.
I am simulating a situation in raspberry pi where I call the register() method several times, approximately 300 times and after that number is generated an exception as below.
Do you know what might be happening? In all the calls I call the register and close them.
After running 300 times the raspberry does not respond to any other component that I try to use the ButtonInputDriver, only after the manual reset of raspberry the code returns to work