Skip to content

Commit a13d0a1

Browse files
committed
raise error for invalid input
1 parent 51123b4 commit a13d0a1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pycyphal/transport/can/media/pythoncan/_pythoncan.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,8 @@ def _construct_pcan(parameters: _InterfaceParameters) -> can.ThreadSafeBus:
489489
),
490490
)
491491
if isinstance(parameters, _FDInterfaceParameters):
492+
if parameters.bitrate[0] == 0 or parameters.bitrate[1] == 0:
493+
raise InvalidMediaConfigurationError("Bitrate must be non-zero")
492494
# These magic numbers come from the settings of PCAN adapter.
493495
# They don't allow any direct baudrate settings, you have to set all lengths and value of the main frequency.
494496
# Bit lengths below are very universal and can be applied for almost every popular baudrate.

0 commit comments

Comments
 (0)