-
Notifications
You must be signed in to change notification settings - Fork 650
Closed
Labels
Description
Describe the bug
The CAN bus (VectorBus) cannot be created because the can_op_mode value reported by the Vector CANcaseXL driver is set to 0, which is not an expected value.
To Reproduce
Connect the CANcaseXL to a CAN bus.
Configure the CANcaseXL using Vector HardwareConfiguration tool.
Run the following python code:
from can.interfaces import vector
bus = vector.VectorBus(0)
Expected behavior
The bus object shall be initialized correctly.
Additional context
OS and version: Windows 10
Python version: 3.8.10
python-can version: 4.1.0
python-can interface/s (if applicable): Vector CANcaseXL
The setup works with BusMaster v3.2.2.
The failing test is in can/interfaces/vector/canlib.py
line 278:
if not all(
[
bus_params.bus_type is xldefine.XL_BusTypes.XL_BUS_TYPE_CAN,
_can.can_op_mode
& xldefine.XL_CANFD_BusParams_CanOpMode.XL_BUS_PARAMS_CANOPMODE_CAN20,
_can.bitrate == bitrate if bitrate else True,
]
):
This test has been added in commit cd51ec4.
Maybe it should be extended to account for the case when _can.can_op_mode
= 0?
Traceback and logs
Traceback (most recent call last):
File "C:/Program Files/JetBrains/PyCharm Community Edition 2022.2.2/plugins/python-ce/helpers/pydev/pydevd.py", line 1496, in _exec
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2022.2.2\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:\git\xxx\essai.py", line 6, in <module>
bus = vector.VectorBus(0)
File "C:\git\xxx\venv\lib\site-packages\can\util.py", line 337, in wrapper
return f(*args, **kwargs)
File "C:\git\xxx\venv\lib\site-packages\can\interfaces\vector\canlib.py", line 286, in __init__
raise CanInitializationError(
can.exceptions.CanInitializationError: The requested CAN settings could not be set for channel 0. Another application might have set incompatible settings. These are the currently active settings: {'bitrate': 250000, 'sjw': 1, 'tseg1': 10, 'tseg2': 5, 'sam': 1, 'output_mode': <XL_OutputMode.XL_OUTPUT_MODE_NORMAL: 1>, 'can_op_mode': <XL_CANFD_BusParams_CanOpMode.0: 0>}
python-BaseException