Skip to content

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

Merged
merged 6 commits into from
Jul 22, 2025

Conversation

Gregox273
Copy link
Contributor

Fix bug in pcan interface where state values cannot be read from config files.

@@ -268,6 +268,12 @@ def __init__(

self.check_api_version()

if not isinstance(state, BusState):
Copy link
Collaborator

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().

@zariiii9003
Copy link
Collaborator

Could you add a test to TestBusConfig in test/test_util.py?

)
state = can_cfg["state"]
assert isinstance(state, can.BusState)
assert state == can.BusState.PASSIVE
Copy link
Collaborator

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)

)
state = can_cfg["state"]
assert isinstance(state, can.BusState)
assert state == expected_state
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Collaborator

@zariiii9003 zariiii9003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you

@zariiii9003 zariiii9003 merged commit 32f07c3 into hardbyte:main Jul 22, 2025
28 checks 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