Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cant read initial value of pin #35

Closed
nursultan156 opened this issue Feb 18, 2015 · 3 comments
Closed

Cant read initial value of pin #35

nursultan156 opened this issue Feb 18, 2015 · 3 comments

Comments

@nursultan156
Copy link

Hi,

i encountered with the problem reading initial value of pin inside ready function, here is the code snippet

var gpio11 = gpio.export(17, {
    direction: "in",
    interval: 200,
    ready: function (val) {
        //here, how to read value of pin?
        console.log(val); // "undefined" - always
        console.log(gpio11.value); // "0" - always
        
        gpio11.on("change", function (val) {
            console.log(val); // reads correctly, "1" or "0"
        });
    }
});
@rzr
Copy link
Collaborator

rzr commented Jun 28, 2018

According to:

https://github.com/EnotionZ/GpiO/blob/master/lib/gpio.js#L114

ready has no parameters, I wish It has a status argument to trap errors

rzr added a commit to TizenTeam/GpiO that referenced this issue Jul 4, 2018
Bug: EnotionZ#35
Change-Id: Ib61747dd145c98f19e2789092a471fab2816eeed
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/GpiO that referenced this issue Jul 4, 2018
This fix a bug that before first change,
value is always zero, while it could be different,

For instance using anavi's Flex button it is high when not released,

Note if you need to test this device make sure to configure pullup:
    gpio -g mode 11 up

Bug: EnotionZ#35
Change-Id: Ib61747dd145c98f19e2789092a471fab2816eeed
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/GpiO that referenced this issue Jul 4, 2018
Bug: EnotionZ#35
Change-Id: Ib61747dd145c98f19e2789092a471fab2816eeed
Signed-off-by: Philippe Coval <[email protected]>
@rzr
Copy link
Collaborator

rzr commented Jul 4, 2018

I think I have fixed this issue please confirm,

I used this example with @leon-anavi Flex Rpi Hat:
https://github.com/TizenTeam/GpiO/blob/sandbox/rzr/devel/master/input-example.js

It may relate to related bug:

#34

#38

rzr added a commit to TizenTeam/GpiO that referenced this issue Jul 4, 2018
This fix a bug that before first change,
value is always zero, while it could be different.

For instance using Anavi's Flex RPi hat
button is high by default (when not pressed).

Note if you need to test this device,
make sure to configure pullup before:
    gpio -g mode 11 up

Bug: EnotionZ#35
Origin: EnotionZ#41
Change-Id: Ib61747dd145c98f19e2789092a471fab2816eeed
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/webthing-node that referenced this issue Jul 4, 2018
gpio.js is bugged: value can be trusted before first change:

   Cant read initial value of pin WebThingsIO#35

problem is know and fix is pending,

So until the upstream fix is applied,
this workaround resolve the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/webthing-node that referenced this issue Jul 4, 2018
gpio.js is bugged: value can be trusted before first change,
problem is know and fix is pending:

   Cant read initial value of pin WebThingsIO#35

So until the upstream fix is released,
this workaround resolves the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

It has been tested on RPi and ARTIK10.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/webthing-node that referenced this issue Jul 9, 2018
gpio.js is bugged: value can be trusted before first change,
problem is know and fix is pending:

   Cant read initial value of pin WebThingsIO#35

So until the upstream fix is released,
this workaround resolves the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

It has been tested on RPi and ARTIK10.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/GpiO that referenced this issue Jul 9, 2018
This fix a bug that before first change,
value is always zero, while it could be different.

For instance using Anavi's Flex RPi hat
button is high by default (when not pressed).

Note if you need to test this device,
make sure to configure pullup before:
    gpio -g mode 11 up

Bug: EnotionZ#35
Origin: EnotionZ#41
Change-Id: Ib61747dd145c98f19e2789092a471fab2816eeed
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/webthing-node that referenced this issue Jul 9, 2018
gpio.js is bugged: value can be trusted before first change,
problem is know and fix is pending:

   Cant read initial value of pin WebThingsIO#35

So until the upstream fix is released,
this workaround resolves the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

It has been tested on RPi and ARTIK10.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/GpiO that referenced this issue Jul 9, 2018
This fix a bug that before first change,
value is always zero, while it could be different.

For instance using Anavi's Flex RPi hat
button is high by default (when not pressed).

Note if you need to test this device,
make sure to configure pullup before:
    gpio -g mode 11 up

Bug: EnotionZ#35
Origin: EnotionZ#41
Change-Id: Ib61747dd145c98f19e2789092a471fab2816eeed
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/webthing-node that referenced this issue Jul 10, 2018
gpio.js is bugged: value can be trusted before first change,
problem is know and fix is pending:

   Cant read initial value of pin WebThingsIO#35

So until the upstream fix is released,
this workaround resolves the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

It has been tested on RPi and ARTIK10.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/webthing-node that referenced this issue Jul 10, 2018
GPIO undefined value on ready

gpio.js is bugged: value can be trusted before first change,
problem is know and fix is pending:

   Cant read initial value of pin WebThingsIO#35

So until the upstream fix is released,
this workaround resolves the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

It has been tested on RPi and ARTIK10.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
EnotionZ pushed a commit that referenced this issue Jul 10, 2018
This fix a bug that before first change,
value is always zero, while it could be different,
since value is undetermined, it is set to undefined.
for input mode and updated ASAP.

For instance using Anavi's Flex RPi hat
button is high by default (when not pressed).

Note if you need to test this device,
make sure to configure pullup before:
    gpio -g mode 11 up

It was also tested on ARTIK10 on GPIO8 pin=J26/2
(pulldown resistor, active high input)

Bug: #35
Origin: #41
Change-Id: Ib61747dd145c98f19e2789092a471fab2816eeed
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/webthing-node that referenced this issue Aug 2, 2018
GPIO undefined value on ready

gpio.js is bugged: value can be trusted before first change,
problem is know and fix is pending:

   Cant read initial value of pin WebThingsIO#35

So until the upstream fix is released,
this workaround resolves the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

It has been tested on RPi and ARTIK10.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/webthing-node that referenced this issue Aug 21, 2018
GPIO undefined value on ready

gpio.js is bugged: value can be trusted before first change,
problem is know and fix is pending:

   Cant read initial value of pin WebThingsIO#35

So until the upstream fix is released,
this workaround resolves the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

It has been tested on RPi and ARTIK10.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to rzr/webthing-node that referenced this issue Aug 23, 2018
gpio.js is bugged: value can be trusted before first change,
problem is know and fix is pending:

   Cant read initial value of pin WebThingsIO#35

So until the upstream fix is released,
this workaround resolves the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

It has been tested on RPi and ARTIK10.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
@EnotionZ
Copy link
Owner

EnotionZ commented Oct 1, 2018

The patch was already merged into master. Tests are in #58 and will be merged into v1 branch. Closing issue.

@EnotionZ EnotionZ closed this as completed Oct 1, 2018
rzr added a commit to TizenTeam/webthing-node that referenced this issue Oct 23, 2018
GPIO undefined value on ready

gpio.js is bugged: value can be trusted before first change,
problem is know and fix is pending:

   Cant read initial value of pin WebThingsIO#35

So until the upstream fix is released,
this workaround resolves the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

It has been tested on RPi and ARTIK10.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
rzr added a commit to TizenTeam/webthing-node that referenced this issue Oct 23, 2018
GPIO undefined value on ready

gpio.js is bugged: value can be trusted before first change,
problem is know and fix is pending:

   Cant read initial value of pin WebThingsIO#35

So until the upstream fix is released,
this workaround resolves the possibly wrong value on ready
(before 1st change).

This single change can be reverted on upgrade,
since previous base is sane.

It has been tested on RPi and ARTIK10.

Relate-to: EnotionZ/gpio#35
Change-Id: I2ea607f48e450a0728624ef15c17d14c98049072
Signed-off-by: Philippe Coval <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants