@@ -295,12 +295,12 @@ def _find_global_channel_idx(
295295        if  serial  is  not None :
296296            hw_type : Optional [xldefine .XL_HardwareType ] =  None 
297297            for  channel_config  in  channel_configs :
298-                 if  channel_config .serialNumber  !=  serial :
298+                 if  channel_config .serial_number  !=  serial :
299299                    continue 
300300
301-                 hw_type  =  xldefine .XL_HardwareType (channel_config .hwType )
302-                 if  channel_config .hwChannel  ==  channel :
303-                     return  channel_config .channelIndex 
301+                 hw_type  =  xldefine .XL_HardwareType (channel_config .hw_type )
302+                 if  channel_config .hw_channel  ==  channel :
303+                     return  channel_config .channel_index 
304304
305305            if  hw_type  is  None :
306306                err_msg  =  f"No interface with serial { serial }  
@@ -331,7 +331,7 @@ def _find_global_channel_idx(
331331
332332        # check if channel is a valid global channel index 
333333        for  channel_config  in  channel_configs :
334-             if  channel  ==  channel_config .channelIndex :
334+             if  channel  ==  channel_config .channel_index :
335335                return  channel 
336336
337337        raise  CanInitializationError (
@@ -727,26 +727,28 @@ def _detect_available_configs() -> List[AutoDetectedConfig]:
727727        LOG .info ("Found %d channels" , len (channel_configs ))
728728        for  channel_config  in  channel_configs :
729729            if  (
730-                 not  channel_config .channelBusCapabilities 
730+                 not  channel_config .channel_bus_capabilities 
731731                &  xldefine .XL_BusCapabilities .XL_BUS_ACTIVE_CAP_CAN 
732732            ):
733733                continue 
734734            LOG .info (
735-                 "Channel index %d: %s" , channel_config .channelIndex , channel_config .name 
735+                 "Channel index %d: %s" ,
736+                 channel_config .channel_index ,
737+                 channel_config .name ,
736738            )
737739            configs .append (
738740                {
739741                    # data for use in VectorBus.__init__(): 
740742                    "interface" : "vector" ,
741-                     "channel" : channel_config .hwChannel ,
742-                     "serial" : channel_config .serialNumber ,
743+                     "channel" : channel_config .hw_channel ,
744+                     "serial" : channel_config .serial_number ,
743745                    # data for use in VectorBus.set_application_config(): 
744-                     "hw_type" : channel_config .hwType ,
745-                     "hw_index" : channel_config .hwIndex ,
746-                     "hw_channel" : channel_config .hwChannel ,
746+                     "hw_type" : channel_config .hw_type ,
747+                     "hw_index" : channel_config .hw_index ,
748+                     "hw_channel" : channel_config .hw_channel ,
747749                    # additional information: 
748750                    "supports_fd" : bool (
749-                         channel_config .channelCapabilities 
751+                         channel_config .channel_capabilities 
750752                        &  xldefine .XL_ChannelCapabilities .XL_CHANNEL_FLAG_CANFD_ISO_SUPPORT 
751753                    ),
752754                    "vector_channel_config" : channel_config ,
@@ -875,22 +877,53 @@ def set_timer_rate(self, timer_rate_ms: int) -> None:
875877        self .xldriver .xlSetTimerRate (self .port_handle , timer_rate_10us )
876878
877879
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+ 
878910class  VectorChannelConfig (NamedTuple ):
879911    """NamedTuple which contains the channel properties from Vector XL API.""" 
880912
881913    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 
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 
894927
895928
896929def  _get_xl_driver_config () ->  xlclass .XLdriverConfig :
@@ -907,6 +940,38 @@ def _get_xl_driver_config() -> xlclass.XLdriverConfig:
907940    return  driver_config 
908941
909942
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+ 
910975def  get_channel_configs () ->  List [VectorChannelConfig ]:
911976    """Read channel properties from Vector XL API.""" 
912977    try :
@@ -919,22 +984,23 @@ def get_channel_configs() -> List[VectorChannelConfig]:
919984        xlcc : xlclass .XLchannelConfig  =  driver_config .channel [i ]
920985        vcc  =  VectorChannelConfig (
921986            name = xlcc .name .decode (),
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 (
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 (
928993                xlcc .channelCapabilities 
929994            ),
930-             channelBusCapabilities = xldefine .XL_BusCapabilities (
995+             channel_bus_capabilities = xldefine .XL_BusCapabilities (
931996                xlcc .channelBusCapabilities 
932997            ),
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 (),
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 (),
9381004        )
9391005        channel_list .append (vcc )
9401006    return  channel_list 
0 commit comments