Skip to content

Commit 5cb344f

Browse files
committed
fixing weird gpio export timing bug
1 parent 7949940 commit 5cb344f

File tree

1 file changed

+5
-1
lines changed
  • coder-apps/tests/gpio_test/app

1 file changed

+5
-1
lines changed

coder-apps/tests/gpio_test/app/app.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,12 @@ var enableGPIO = function() {
119119
// Set up the LED output GPIO
120120
console.log("Setting up LED as an output on GPIO " + ledGPIOID );
121121
ledDevice = gpio.export( ledGPIOID, {
122-
direction: "out",
123122
ready: function() {
123+
// This works around a bug in gpio, where sometimes this device
124+
// doesn't become immediately available.
125+
setTimeout( function() {
126+
ledDevice.setDirection("out");
127+
}, 100); //wait 100 ms before setting direction
124128
}
125129
});
126130

0 commit comments

Comments
 (0)