@@ -400,7 +400,11 @@ def _read_bus_params(self, channel: int) -> "VectorBusParams":
400
400
vcc_list = get_channel_configs ()
401
401
for vcc in vcc_list :
402
402
if vcc .channel_mask == channel_mask :
403
- return vcc .bus_params
403
+ bus_params = vcc .bus_params
404
+ if bus_params is None :
405
+ # for CAN channels, this should never be `None`
406
+ raise ValueError ("Invalid bus parameters." )
407
+ return bus_params
404
408
405
409
raise CanInitializationError (
406
410
f"Channel configuration for channel { channel } not found."
@@ -1090,7 +1094,7 @@ class VectorChannelConfig(NamedTuple):
1090
1094
channel_bus_capabilities : xldefine .XL_BusCapabilities
1091
1095
is_on_bus : bool
1092
1096
connected_bus_type : xldefine .XL_BusTypes
1093
- bus_params : VectorBusParams
1097
+ bus_params : Optional [ VectorBusParams ]
1094
1098
serial_number : int
1095
1099
article_number : int
1096
1100
transceiver_name : str
@@ -1110,9 +1114,14 @@ def _get_xl_driver_config() -> xlclass.XLdriverConfig:
1110
1114
return driver_config
1111
1115
1112
1116
1113
- def _read_bus_params_from_c_struct (bus_params : xlclass .XLbusParams ) -> VectorBusParams :
1117
+ def _read_bus_params_from_c_struct (
1118
+ bus_params : xlclass .XLbusParams ,
1119
+ ) -> Optional [VectorBusParams ]:
1120
+ bus_type = xldefine .XL_BusTypes (bus_params .busType )
1121
+ if bus_type is not xldefine .XL_BusTypes .XL_BUS_TYPE_CAN :
1122
+ return None
1114
1123
return VectorBusParams (
1115
- bus_type = xldefine . XL_BusTypes ( bus_params . busType ) ,
1124
+ bus_type = bus_type ,
1116
1125
can = VectorCanParams (
1117
1126
bitrate = bus_params .data .can .bitRate ,
1118
1127
sjw = bus_params .data .can .sjw ,
0 commit comments