@@ -295,12 +295,12 @@ def _find_global_channel_idx(
295
295
if serial is not None :
296
296
hw_type : Optional [xldefine .XL_HardwareType ] = None
297
297
for channel_config in channel_configs :
298
- if channel_config .serial_number != serial :
298
+ if channel_config .serialNumber != serial :
299
299
continue
300
300
301
- hw_type = xldefine .XL_HardwareType (channel_config .hw_type )
302
- if channel_config .hw_channel == channel :
303
- return channel_config .channel_index
301
+ hw_type = xldefine .XL_HardwareType (channel_config .hwType )
302
+ if channel_config .hwChannel == channel :
303
+ return channel_config .channelIndex
304
304
305
305
if hw_type is None :
306
306
err_msg = f"No interface with serial { serial } found."
@@ -331,7 +331,7 @@ def _find_global_channel_idx(
331
331
332
332
# check if channel is a valid global channel index
333
333
for channel_config in channel_configs :
334
- if channel == channel_config .channel_index :
334
+ if channel == channel_config .channelIndex :
335
335
return channel
336
336
337
337
raise CanInitializationError (
@@ -727,28 +727,26 @@ def _detect_available_configs() -> List[AutoDetectedConfig]:
727
727
LOG .info ("Found %d channels" , len (channel_configs ))
728
728
for channel_config in channel_configs :
729
729
if (
730
- not channel_config .channel_bus_capabilities
730
+ not channel_config .channelBusCapabilities
731
731
& xldefine .XL_BusCapabilities .XL_BUS_ACTIVE_CAP_CAN
732
732
):
733
733
continue
734
734
LOG .info (
735
- "Channel index %d: %s" ,
736
- channel_config .channel_index ,
737
- channel_config .name ,
735
+ "Channel index %d: %s" , channel_config .channelIndex , channel_config .name
738
736
)
739
737
configs .append (
740
738
{
741
739
# data for use in VectorBus.__init__():
742
740
"interface" : "vector" ,
743
- "channel" : channel_config .hw_channel ,
744
- "serial" : channel_config .serial_number ,
741
+ "channel" : channel_config .hwChannel ,
742
+ "serial" : channel_config .serialNumber ,
745
743
# data for use in VectorBus.set_application_config():
746
- "hw_type" : channel_config .hw_type ,
747
- "hw_index" : channel_config .hw_index ,
748
- "hw_channel" : channel_config .hw_channel ,
744
+ "hw_type" : channel_config .hwType ,
745
+ "hw_index" : channel_config .hwIndex ,
746
+ "hw_channel" : channel_config .hwChannel ,
749
747
# additional information:
750
748
"supports_fd" : bool (
751
- channel_config .channel_capabilities
749
+ channel_config .channelCapabilities
752
750
& xldefine .XL_ChannelCapabilities .XL_CHANNEL_FLAG_CANFD_ISO_SUPPORT
753
751
),
754
752
"vector_channel_config" : channel_config ,
@@ -877,53 +875,22 @@ def set_timer_rate(self, timer_rate_ms: int) -> None:
877
875
self .xldriver .xlSetTimerRate (self .port_handle , timer_rate_10us )
878
876
879
877
880
- class VectorCanParams (NamedTuple ):
881
- bitrate : int
882
- sjw : int
883
- tseg1 : int
884
- tseg2 : int
885
- sam : int
886
- output_mode : xldefine .XL_OutputMode
887
- can_op_mode : xldefine .XL_CANFD_BusParams_CanOpMode
888
-
889
-
890
- class VectorCanFdParams (NamedTuple ):
891
- bitrate : int
892
- data_bitrate : int
893
- sjw_abr : int
894
- tseg1_abr : int
895
- tseg2_abr : int
896
- sam_abr : int
897
- sjw_dbr : int
898
- tseg1_dbr : int
899
- tseg2_dbr : int
900
- output_mode : xldefine .XL_OutputMode
901
- can_op_mode : xldefine .XL_CANFD_BusParams_CanOpMode
902
-
903
-
904
- class VectorBusParams (NamedTuple ):
905
- bus_type : xldefine .XL_BusTypes
906
- can : VectorCanParams
907
- canfd : VectorCanFdParams
908
-
909
-
910
878
class VectorChannelConfig (NamedTuple ):
911
879
"""NamedTuple which contains the channel properties from Vector XL API."""
912
880
913
881
name : str
914
- hw_type : xldefine .XL_HardwareType
915
- hw_index : int
916
- hw_channel : int
917
- channel_index : int
918
- channel_mask : int
919
- channel_capabilities : xldefine .XL_ChannelCapabilities
920
- channel_bus_capabilities : xldefine .XL_BusCapabilities
921
- is_on_bus : bool
922
- connected_bus_type : xldefine .XL_BusTypes
923
- bus_params : VectorBusParams
924
- serial_number : int
925
- article_number : int
926
- transceiver_name : str
882
+ hwType : xldefine .XL_HardwareType
883
+ hwIndex : int
884
+ hwChannel : int
885
+ channelIndex : int
886
+ channelMask : int
887
+ channelCapabilities : xldefine .XL_ChannelCapabilities
888
+ channelBusCapabilities : xldefine .XL_BusCapabilities
889
+ isOnBus : bool
890
+ connectedBusType : xldefine .XL_BusTypes
891
+ serialNumber : int
892
+ articleNumber : int
893
+ transceiverName : str
927
894
928
895
929
896
def _get_xl_driver_config () -> xlclass .XLdriverConfig :
@@ -940,38 +907,6 @@ def _get_xl_driver_config() -> xlclass.XLdriverConfig:
940
907
return driver_config
941
908
942
909
943
- def _read_bus_params_from_c_struct (bus_params : xlclass .XLbusParams ) -> VectorBusParams :
944
- return VectorBusParams (
945
- bus_type = xldefine .XL_BusTypes (bus_params .busType ),
946
- can = VectorCanParams (
947
- bitrate = bus_params .data .can .bitRate ,
948
- sjw = bus_params .data .can .sjw ,
949
- tseg1 = bus_params .data .can .tseg1 ,
950
- tseg2 = bus_params .data .can .tseg2 ,
951
- sam = bus_params .data .can .sam ,
952
- output_mode = xldefine .XL_OutputMode (bus_params .data .can .outputMode ),
953
- can_op_mode = xldefine .XL_CANFD_BusParams_CanOpMode (
954
- bus_params .data .can .canOpMode
955
- ),
956
- ),
957
- canfd = VectorCanFdParams (
958
- bitrate = bus_params .data .canFD .arbitrationBitRate ,
959
- data_bitrate = bus_params .data .canFD .dataBitRate ,
960
- sjw_abr = bus_params .data .canFD .sjwAbr ,
961
- tseg1_abr = bus_params .data .canFD .tseg1Abr ,
962
- tseg2_abr = bus_params .data .canFD .tseg2Abr ,
963
- sam_abr = bus_params .data .canFD .samAbr ,
964
- sjw_dbr = bus_params .data .canFD .sjwDbr ,
965
- tseg1_dbr = bus_params .data .canFD .tseg1Dbr ,
966
- tseg2_dbr = bus_params .data .canFD .tseg2Dbr ,
967
- output_mode = xldefine .XL_OutputMode (bus_params .data .canFD .outputMode ),
968
- can_op_mode = xldefine .XL_CANFD_BusParams_CanOpMode (
969
- bus_params .data .canFD .canOpMode
970
- ),
971
- ),
972
- )
973
-
974
-
975
910
def get_channel_configs () -> List [VectorChannelConfig ]:
976
911
"""Read channel properties from Vector XL API."""
977
912
try :
@@ -984,23 +919,22 @@ def get_channel_configs() -> List[VectorChannelConfig]:
984
919
xlcc : xlclass .XLchannelConfig = driver_config .channel [i ]
985
920
vcc = VectorChannelConfig (
986
921
name = xlcc .name .decode (),
987
- hw_type = xldefine .XL_HardwareType (xlcc .hwType ),
988
- hw_index = xlcc .hwIndex ,
989
- hw_channel = xlcc .hwChannel ,
990
- channel_index = xlcc .channelIndex ,
991
- channel_mask = xlcc .channelMask ,
992
- channel_capabilities = xldefine .XL_ChannelCapabilities (
922
+ hwType = xldefine .XL_HardwareType (xlcc .hwType ),
923
+ hwIndex = xlcc .hwIndex ,
924
+ hwChannel = xlcc .hwChannel ,
925
+ channelIndex = xlcc .channelIndex ,
926
+ channelMask = xlcc .channelMask ,
927
+ channelCapabilities = xldefine .XL_ChannelCapabilities (
993
928
xlcc .channelCapabilities
994
929
),
995
- channel_bus_capabilities = xldefine .XL_BusCapabilities (
930
+ channelBusCapabilities = xldefine .XL_BusCapabilities (
996
931
xlcc .channelBusCapabilities
997
932
),
998
- is_on_bus = bool (xlcc .isOnBus ),
999
- bus_params = _read_bus_params_from_c_struct (xlcc .busParams ),
1000
- connected_bus_type = xldefine .XL_BusTypes (xlcc .connectedBusType ),
1001
- serial_number = xlcc .serialNumber ,
1002
- article_number = xlcc .articleNumber ,
1003
- transceiver_name = xlcc .transceiverName .decode (),
933
+ isOnBus = bool (xlcc .isOnBus ),
934
+ connectedBusType = xldefine .XL_BusTypes (xlcc .connectedBusType ),
935
+ serialNumber = xlcc .serialNumber ,
936
+ articleNumber = xlcc .articleNumber ,
937
+ transceiverName = xlcc .transceiverName .decode (),
1004
938
)
1005
939
channel_list .append (vcc )
1006
940
return channel_list
0 commit comments