Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion can/interfaces/pcan/pcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,10 @@ def get_api_version(self):
if error != PCAN_ERROR_OK:
raise CanInitializationError(f"Failed to read pcan basic api version")

return version.parse(value.decode("ascii"))
# fix https://github.com/hardbyte/python-can/issues/1642
version_string = value.decode("ascii").replace(",", ".").replace(" ", "")

return version.parse(version_string)

def check_api_version(self):
apv = self.get_api_version()
Expand Down
13 changes: 13 additions & 0 deletions test/test_pcan.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ def test_api_version_read_fail(self) -> None:
with self.assertRaises(CanInitializationError):
self.bus = can.Bus(interface="pcan")

def test_issue1642(self) -> None:
self.PCAN_API_VERSION_SIM = "1, 3, 0, 50"
with self.assertLogs("can.pcan", level="WARNING") as cm:
self.bus = can.Bus(interface="pcan")
found_version_warning = False
for i in cm.output:
if "version" in i and "pcan" in i:
found_version_warning = True
self.assertTrue(
found_version_warning,
f"No warning was logged for incompatible api version {cm.output}",
)

@parameterized.expand(
[
("no_error", PCAN_ERROR_OK, PCAN_ERROR_OK, "some ok text 1"),
Expand Down