Skip to content

Commit 5c7810f

Browse files
committed
Change ascii conversion to be compatible with Python2.7 in ixxat backend.
Contributed by @wkemps
1 parent b47ca2f commit 5c7810f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

can/interfaces/ixxat/canlib.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,12 @@ def __init__(self, channel, can_filters=None, **kwargs):
328328
else:
329329
raise VCIDeviceNotFoundError("Unique HW ID {} not connected or not available.".format(UniqueHardwareId))
330330
else:
331-
if (UniqueHardwareId is None) or (self._device_info.UniqueHardwareId.AsChar == bytes(UniqueHardwareId, 'ascii')):
331+
if (UniqueHardwareId is None) or (
332+
self._device_info.UniqueHardwareId.AsChar == UniqueHardwareId.encode("ascii")):
332333
break
333334
else:
334-
log.debug("Ignoring IXXAT with hardware id '%s'.", self._device_info.UniqueHardwareId.AsChar.decode("ascii"))
335+
log.debug("Ignoring IXXAT with hardware id '%s'.",
336+
self._device_info.UniqueHardwareId.AsChar.decode("ascii"))
335337
_canlib.vciEnumDeviceClose(self._device_handle)
336338
_canlib.vciDeviceOpen(ctypes.byref(self._device_info.VciObjectId), ctypes.byref(self._device_handle))
337339
log.info("Using unique HW ID %s", self._device_info.UniqueHardwareId.AsChar)

0 commit comments

Comments
 (0)