Skip to content

Conversation

@peterohman
Copy link
Contributor

Improved validation of reported data and reported id now independent of sw version

peterohman and others added 2 commits October 25, 2024 13:48
Improved validation of reported data and reported id now independent of sw version
@mr-manuel mr-manuel merged commit 9155cab into mr-manuel:master Oct 25, 2024
@mr-manuel
Copy link
Owner

Thanks for helping to improve the driver

@peterohman
Copy link
Contributor Author

peterohman commented Oct 25, 2024

Isn't this code contradicting the comment?

# only read next data if the first one was successful, this saves time when checking multiple battery types
            result = result and self.get_settings()

This will always execute self.get_settings() even if the first one failed

@mr-manuel
Copy link
Owner

No, since it's the same as:

if result:
    result = self.get_settings()

only in a shorter form. The code is always elaborated from top to down and left to right. If there is a condition, the condition is only elaborated, if the result is not clear.

In the case result is true, then self.get_settings() is executed, since it could be false and both have to be true.

In the case result is false, then self.get_settings() is NOT executed, since it would not change the overall result.

@peterohman
Copy link
Contributor Author

Right, I read "and" as a bitwise "and", but it is of course a logical "and"

cgoudie pushed a commit to TechBlueprints/venus-os_dbus-serialbattery that referenced this pull request Nov 4, 2025
Improved validation of reported data and reported id now independent of sw version
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