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

Returns "-1" a certain number of times #1

Open
kazuohprc opened this issue Sep 10, 2021 · 0 comments
Open

Returns "-1" a certain number of times #1

kazuohprc opened this issue Sep 10, 2021 · 0 comments

Comments

@kazuohprc
Copy link

Hello

I use this program to get distances on a regular basis.
At first the program works fine.
However, it returns [-1] from around 50 to 130 times,
After working normally 2-3 times
Returns [-1] all the time.

Normal value and pin status
1 pin_trig = ["pin_trig" <GPIO 24>] pin_echo = ["GPIO 25" <GPIO 25>]
2 pin_trig.getName () = [pin_trig] pin_echo.getName () = [GPIO 25]
3 pin_trig.getState () = [LOW] pin_echo.getState () = [LOW]
4 pin_trig.getPin () = [GPIO 24] pin_echo.getPin () = [GPIO 25]
5 pin_trig.getPin (). getAddress () = [24] pin_echo.getPin (). getAddress () = [25]
9 start_time: 45708706408821 end_time: 45708707102520
147 171 117

Bad behavior
1 pin_trig = ["pin_trig" <GPIO 24>] pin_echo = ["GPIO 25" <GPIO 25>]
2 pin_trig.getName () = [pin_trig] pin_echo.getName () = [GPIO 25]
3 pin_trig.getState () = [LOW] pin_echo.getState () = [LOW]
4 pin_trig.getPin () = [GPIO 24] pin_echo.getPin () = [GPIO 25]
5 pin_trig.getPin (). getAddress () = [24] pin_echo.getPin (). getAddress () = [25]
148 172 -1

After returning [-1], after post-processing such as
If you recreate the class, it will continue to return [-1].

sonic.gpio.shutdown ();
sonic.gpio.unprovisionPin (sonic.pin_echo);
sonic.gpio.unprovisionPin (sonic.pin_trig);

If you quit all the programs and run them again, it works fine.
However, it returns [-1] from around 50 to 130 times.
Is this a bug in pi4j?

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

1 participant