-
Notifications
You must be signed in to change notification settings - Fork 659
Closed
Labels
Description
Describe the bug
data_bitrate requires a value set -- the default results in an error.
To Reproduce
Install version 4.6.0 of python-can[serial] using pip.
Then run the following code:
can_interface="/dev/ttyACM0"
bus = can.interface.Bus(interface="slcan", channel=can_interface, bitrate=500000)
where the slack device is a canable 2.0.
The result is:
error_message = None, exception_type = <class 'can.exceptions.CanInitializationError'>
@contextmanager
def error_check(
error_message: Optional[str] = None,
exception_type: type[CanError] = CanOperationError,
) -> Generator[None, None, None]:
"""Catches any exceptions and turns them into the new type while preserving the stack trace."""
try:
yield
except Exception as error: # pylint: disable=broad-except
if error_message is None:
> raise exception_type(str(error)) from error
E can.exceptions.CanInitializationError: Invalid data bitrate, choose one of 0, 2000000, 5000000.
Expected behavior
The above should return a valid bus, since we are not using Can FD.
Additional context
OS and version: Ubuntu 22
Python version: 3.13
python-can version: 4.6.0
python-can interface/s (if applicable): slcan