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

CanInitializationError when creating Vector bus with parameters loaded from can config file #1498

Closed
nuts4coffee opened this issue Jan 25, 2023 · 1 comment · Fixed by #1499
Assignees

Comments

@nuts4coffee
Copy link

Describe the bug

Fail to create the bus object with Vector interface. The following error is raised.

can.exceptions.CanInitializationError: The requested CAN FD settings could not be set for channel 0. Another application might have set incompatible settings. These are the currently active settings: OrderedDict(
[('bitrate', 500000), ('data_bitrate', 2000000), ('sjw_abr', 16), ('tseg1_abr', 63), ('tseg2_abr', 16), ('sam_abr', 1), ('sjw_dbr', 4), ('tseg1_dbr', 15), ('tseg2_dbr', 4), ('output_mode', <XL_OutputMode.XL_OUTPU
T_MODE_NORMAL: 1>), ('can_op_mode', <XL_CANFD_BusParams_CanOpMode.4|XL_BUS_PARAMS_CANOPMODE_CANFD: 6>)]) 

The bus config parameters are set in can.ini file:

[default]
interface = vector
receive_own_messages=1
bitrate = 500000
data_bitrate = 2000000
channel = 0
app_name = Canalyzer
sjw_abr = 16
tseg1_abr = 63
tseg2_abr = 16
sjw_dbr = 4
tseg1_dbr = 15
tseg2_dbr = 4
fd = True

The timing parameters (e.g. sjw_abr and etc) are passed as str to the constructor, and compared to int values at
https://github.com/hardbyte/python-can/blob/v4.1.0/can/interfaces/vector/canlib.py#L262.

To Reproduce

This code works with python-can v4.0.0, but fails on python-can v4.1.0.

import can


def main():
    bus_config = {}
    bus = can.interface.Bus(**bus_config)
    print(bus)
    bus.shutdown()


if __name__ == '__main__':
    main()

Expected behavior

Bus object creation should not fail.

Additional context

OS and version: Windows 10
Python version: 3.7.9
python-can version: 4.1.0
python-can interface/s (if applicable): Vector

Traceback and logs
def func():
    return "hello, world!"
@zariiii9003
Copy link
Collaborator

Thanks for reporting, i can reproduce it.

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

Successfully merging a pull request may close this issue.

2 participants