Skip to content

Unable to parse BusState from config.ini #1956

Closed

Description

@Gregox273

Describe the bug

I'm attempting to read a configuration from %APPDATA%\can.ini, specifically this config from the documentation for the PCAN Basic API:

[default]
interface = pcan
channel = PCAN_USBBUS1
state = can.bus.BusState.PASSIVE
bitrate = 500000

Rather than interpret the state config as an enum value, python-can seems to treat it as a string, so fails with:

ValueError: BusState must be Active or Passive

To Reproduce

Try to instantiate can.Bus() with the above config in %APPDATA%\can.ini.

Expected behavior

state = can.bus.BusState.PASSIVE is interpreted as the enum value rather than the string 'can.bus.BusState.PASSIVE'.

Additional context

OS and version: Windows 11 Pro 24H2
Python version: 3.13.4
python-can version: 4.5.0
python-can interface/s (if applicable): PCAN Basic API

Activity

  1. Gregox273 commented on Jul 22, 2025

    @Gregox273
    ContributorAuthor

    Fixed by #1957

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions