-
Notifications
You must be signed in to change notification settings - Fork 587
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
Fix GrovePi binding timing issue when read sensors #2359
base: main
Are you sure you want to change the base?
Fix GrovePi binding timing issue when read sensors #2359
Conversation
@dotnet-policy-service agree |
|
||
throw new IOException($"{nameof(DigitalRead)}: Failed to read byte with command {GrovePiCommand.DigitalRead}", innerEx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you removing the throw here and replace with the -1 logic? Throwing is a good way to say that things did not work properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ellerbach
I initially considered making this change because the existing AnalogRead
method was designed to return -1 instead of throwing an exception. However, I have adjusted the behavior at commit 93c6303 accordingly.
/azp run |
Azure Pipelines successfully started running 1 pipeline(s). |
Fixes #2337
Summary
Fix timing issue in the GrovePi Binding logic for sensor reading.
Detail
As mentioned in the issue I raised, there is a bug in the current GrovePi Binding that prevents it from correctly reading sensor values on the Raspberry Pi 4. To fix this bug, I have modified the code to wait and retry when an invalid response is received from the device. Additionally, I've standardized the implementation of the
DigitalRead
method with other sensor readings so that it can also benefit from this bug fix.Validation
I have confirmed that the changes in this PR work as intended by testing with sample code from the GrovePi directory. I connected a button, potentiometer, relay, ultrasonic distance sensor, and temperature & humidity sensor to both Raspberry Pi 3 and 4.
Microsoft Reviewers: Open in CodeFlow