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

Handle strtof parsing errors #49

Merged
merged 5 commits into from
May 22, 2024
Merged

Conversation

ullbergm
Copy link
Contributor

Description:
This pull request adds error checking to the code that parses the weight from the scales.
This may be an edge case, but it won't hurt to handle it correctly. In the event that strtof fails to parse a float out of the string, it will return 0 and without error checking, that could make OpenTrickler dispense powder when it shouldn't.

Changes:

  • Implemented error checking to the rest of the scale types to return NaN if strtof fails to decode the data.

Testing:

  • Only tested with JFDBS00058-100G model (which sends "+ ~~~~~~~~GN" in the case where the item is too heavy for it).
  • Confirmed error handling returns NaN on strtof failure.

@eamars eamars merged commit 53cae0a into eamars:main May 22, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants