Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

FIX: Some hardware ID are not compatible with ascii, in that case fal... #2001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
prunith wants to merge 4 commits into hardbyte:main
base: main
Choose a base branch
Loading
from prunith:main
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions can/interfaces/ixxat/canlib_vcinpl.py
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,20 @@ def __init__(
f"Unique HW ID {unique_hardware_id} not connected or not available."
) from None
else:
try:
hwid = self._device_info.UniqueHardwareId.AsChar.decode("ascii")
except UnicodeDecodeError:
guid = self._device_info.UniqueHardwareId.AsGuid
hwid = f"{{{guid.Data1:x}-{guid.Data2:x}-{guid.Data3:x}-{guid.Data4.hex()}}}"

if (unique_hardware_id is None) or (
self._device_info.UniqueHardwareId.AsChar
== bytes(unique_hardware_id, "ascii")
bytes(hwid, "ascii") == bytes(unique_hardware_id, "ascii")
):
break

log.debug(
"Ignoring IXXAT with hardware id '%s'.",
self._device_info.UniqueHardwareId.AsChar.decode("ascii"),
hwid,
)
_canlib.vciEnumDeviceClose(self._device_handle)

Expand All @@ -541,7 +546,7 @@ def __init__(
f"Could not open device: {exception}"
) from exception

log.info("Using unique HW ID %s", self._device_info.UniqueHardwareId.AsChar)
log.info("Using unique HW ID %s", hwid)

log.info(
"Initializing channel %d in shared mode, %d rx buffers, %d tx buffers",
Expand Down Expand Up @@ -969,7 +974,13 @@ def get_ixxat_hwids():
except StopIteration:
break
else:
hwids.append(device_info.UniqueHardwareId.AsChar.decode("ascii"))
try:
hwids.append(device_info.UniqueHardwareId.AsChar.decode("ascii"))
except UnicodeDecodeError:
guid = device_info.UniqueHardwareId.AsGuid
hwids.append(
f"{{{guid.Data1:x}-{guid.Data2:x}-{guid.Data3:x}-{guid.Data4.hex()}}}"
)
_canlib.vciEnumDeviceClose(device_handle)

return hwids
Expand All @@ -994,7 +1005,11 @@ def _detect_available_configs() -> Sequence["AutoDetectedIxxatConfig"]:
except StopIteration:
break
else:
hwid = device_info.UniqueHardwareId.AsChar.decode("ascii")
try:
hwid = device_info.UniqueHardwareId.AsChar.decode("ascii")
except UnicodeDecodeError:
guid = device_info.UniqueHardwareId.AsGuid
hwid = f"{{{guid.Data1:x}-{guid.Data2:x}-{guid.Data3:x}-{guid.Data4.hex()}}}"
_canlib.vciDeviceOpen(
ctypes.byref(device_info.VciObjectId),
ctypes.byref(device_handle2),
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /