@@ -118,6 +118,22 @@ def test_bus_creation() -> None:
118
118
bus .shutdown ()
119
119
120
120
121
+ @pytest .mark .skipif (not XLDRIVER_FOUND , reason = "Vector XL API is unavailable" )
122
+ def test_bus_creation_channel_index () -> None :
123
+ channel_index = 3
124
+ bus = can .Bus (
125
+ channel = 0 ,
126
+ serial = _find_virtual_can_serial (),
127
+ channel_index = channel_index ,
128
+ interface = "vector" ,
129
+ )
130
+ assert isinstance (bus , canlib .VectorBus )
131
+ assert bus .protocol == can .CanProtocol .CAN_20
132
+ assert bus .channel_masks [0 ] == 1 << channel_index
133
+
134
+ bus .shutdown ()
135
+
136
+
121
137
def test_bus_creation_bitrate_mocked (mock_xldriver ) -> None :
122
138
bus = can .Bus (channel = 0 , interface = "vector" , bitrate = 200_000 , _testing = True )
123
139
assert isinstance (bus , canlib .VectorBus )
@@ -833,6 +849,31 @@ def test_get_channel_configs() -> None:
833
849
canlib ._get_xl_driver_config = _original_func
834
850
835
851
852
+ @pytest .mark .skipif (
853
+ sys .byteorder != "little" , reason = "Test relies on little endian data."
854
+ )
855
+ def test_detect_available_configs () -> None :
856
+ _original_func = canlib ._get_xl_driver_config
857
+ canlib ._get_xl_driver_config = _get_predefined_xl_driver_config
858
+
859
+ available_configs = canlib .VectorBus ._detect_available_configs ()
860
+
861
+ assert len (available_configs ) == 5
862
+
863
+ assert available_configs [0 ]["interface" ] == "vector"
864
+ assert available_configs [0 ]["channel" ] == 2
865
+ assert available_configs [0 ]["serial" ] == 1001
866
+ assert available_configs [0 ]["channel_index" ] == 2
867
+ assert available_configs [0 ]["hw_type" ] == xldefine .XL_HardwareType .XL_HWTYPE_VN8900
868
+ assert available_configs [0 ]["hw_index" ] == 0
869
+ assert available_configs [0 ]["supports_fd" ] is True
870
+ assert isinstance (
871
+ available_configs [0 ]["vector_channel_config" ], VectorChannelConfig
872
+ )
873
+
874
+ canlib ._get_xl_driver_config = _original_func
875
+
876
+
836
877
@pytest .mark .skipif (not IS_WINDOWS , reason = "Windows specific test" )
837
878
def test_winapi_availability () -> None :
838
879
assert canlib .WaitForSingleObject is not None
0 commit comments