gpio incorrectly assumes 0 value by default
Closed this issue · 4 comments
In set there's comparison of current value with the new one. But current value is not read from hardware but assumed to be 0
by default. Therefore if gpio is high I cannot make it back low.
This is not exactly a bug with this GpiO
package. The linux sysfs gpio interface specifies that the output starts as low unless the direction is set to high
instead of out
. See #38 for more.
I confirm that it is a bug, especially for inputs. If we have an input with pull-up enabled, the default state is '1', but the library returns 0 as long as there was no transition on that input.
So, at least here:
https://github.com/EnotionZ/GpiO/blob/master/lib/gpio.js#L104
you have to manually read the value and store it. The same situation is for output because you have no guarantee that something before your applications, changed the output value.
@mmajchrzycki please confirm linked patch is working.
I have to do similar fixes app's side so I thought this can be done internally with: