@@ -519,15 +519,19 @@ def __init__(
519519 f"Unique HW ID { unique_hardware_id } not connected or not available."
520520 ) from None
521521 else :
522- if (unique_hardware_id is None ) or (
523- self ._device_info .UniqueHardwareId .AsChar
524- == bytes (unique_hardware_id , "ascii" )
522+ try :
523+ hwid = self ._device_info .UniqueHardwareId .AsChar .decode ("ascii" )
524+ except :
525+ guid = self ._device_info .UniqueHardwareId .AsGuid
526+ hwid = '{{{0:x}-{1:x}-{2:x}-{3}}}' .format (guid .Data1 ,guid .Data2 ,guid .Data3 ,guid .Data4 .hex ())
527+
528+ if (unique_hardware_id is None ) or ( bytes (hwid , "ascii" ) == bytes (unique_hardware_id , "ascii" )
525529 ):
526530 break
527531
528532 log .debug (
529533 "Ignoring IXXAT with hardware id '%s'." ,
530- self . _device_info . UniqueHardwareId . AsChar . decode ( "ascii" ) ,
534+ hwid ,
531535 )
532536 _canlib .vciEnumDeviceClose (self ._device_handle )
533537
@@ -541,7 +545,7 @@ def __init__(
541545 f"Could not open device: { exception } "
542546 ) from exception
543547
544- log .info ("Using unique HW ID %s" , self . _device_info . UniqueHardwareId . AsChar )
548+ log .info ("Using unique HW ID %s" , hwid )
545549
546550 log .info (
547551 "Initializing channel %d in shared mode, %d rx buffers, %d tx buffers" ,
@@ -969,7 +973,11 @@ def get_ixxat_hwids():
969973 except StopIteration :
970974 break
971975 else :
972- hwids .append (device_info .UniqueHardwareId .AsChar .decode ("ascii" ))
976+ try :
977+ hwids .append (device_info .UniqueHardwareId .AsChar .decode ("ascii" ))
978+ except :
979+ guid = device_info .UniqueHardwareId .AsGuid
980+ hwids .append ('{{{0:x}-{1:x}-{2:x}-{3}}}' .format (guid .Data1 ,guid .Data2 ,guid .Data3 ,guid .Data4 .hex ()))
973981 _canlib .vciEnumDeviceClose (device_handle )
974982
975983 return hwids
@@ -994,7 +1002,11 @@ def _detect_available_configs() -> Sequence["AutoDetectedIxxatConfig"]:
9941002 except StopIteration :
9951003 break
9961004 else :
997- hwid = device_info .UniqueHardwareId .AsChar .decode ("ascii" )
1005+ try :
1006+ hwid = device_info .UniqueHardwareId .AsChar .decode ("ascii" )
1007+ except :
1008+ guid = device_info .UniqueHardwareId .AsGuid
1009+ hwid = '{{{0:x}-{1:x}-{2:x}-{3}}}' .format (guid .Data1 ,guid .Data2 ,guid .Data3 ,guid .Data4 .hex ())
9981010 _canlib .vciDeviceOpen (
9991011 ctypes .byref (device_info .VciObjectId ),
10001012 ctypes .byref (device_handle2 ),
0 commit comments