-
Notifications
You must be signed in to change notification settings - Fork 643
Convert BusState to enum when read with configparser #1957
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
Conversation
can/interfaces/pcan/pcan.py
Outdated
@@ -268,6 +268,12 @@ def __init__( | |||
|
|||
self.check_api_version() | |||
|
|||
if not isinstance(state, BusState): |
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.
I think this is the wrong place for this. The config value should be converted in can.util._create_bus_config()
.
Could you add a test to |
test/test_util.py
Outdated
) | ||
state = can_cfg["state"] | ||
assert isinstance(state, can.BusState) | ||
assert state == can.BusState.PASSIVE |
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.
nitpick: enums should be compared by identity (state is can.BusState.PASSIVE
)
test/test_util.py
Outdated
) | ||
state = can_cfg["state"] | ||
assert isinstance(state, can.BusState) | ||
assert state == expected_state |
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.
same here
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.
Thank you
Fix bug in pcan interface where state values cannot be read from config files.