Skip to content

Commit

Permalink
fine tune delay after export. Testing fast SSD failed at 25 ms, worke…
Browse files Browse the repository at this point in the history
…d 99% at 30. Set to 70 ms. Also, fixed bug if application with no pwm config shutdown value call pwm.shutdown(), then pi4j shutdown would invoke unexport a second time
  • Loading branch information
taartspi committed Apr 4, 2024
1 parent 7c2b149 commit ba13376
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public Pwm initialize(Context context) throws InitializeException {
logger.trace("exporting PWM [" + this.config.address() + "]; " + pwm.getPwmPath());
pwm.export();
// Delay to allow the SSD to persist the new directory and device partitions
Thread.sleep(250);
Thread.sleep(70);
} else{
logger.trace("PWM [" + this.config.address() + "] is already exported; " + pwm.getPwmPath());
}
Expand Down Expand Up @@ -224,7 +224,9 @@ public Pwm shutdown(Context context) throws ShutdownException {
// otherwise ... un-export the GPIO pin from the Linux file system impl
try {
logger.trace("un-exporting PWM [" + this.config.address() + "]; " + pwm.getPwmPath());
pwm.unexport();
if(pwm.isExported()) {
pwm.unexport();
}
} catch (java.io.IOException e) {
logger.error(e.getMessage(), e);
throw new ShutdownException("Failed to UN-EXPORT PWM [" + config().address() + "] @ <" + pwm.systemPath() + ">; " + e.getMessage(), e);
Expand Down

0 comments on commit ba13376

Please sign in to comment.