mirror of
https://github.com/andreili/katapult.git
synced 2025-08-24 03:44:06 +02:00
flash_can: query fix
Don't requre exactly 8 bytes in a response, as its possible that some apps may not return a full 8 bytes. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
a06bf6158a
commit
10cc588874
@ -408,20 +408,22 @@ class CanSocket:
|
|||||||
endtime = curtime + 2.
|
endtime = curtime + 2.
|
||||||
self.uuids: List[int] = []
|
self.uuids: List[int] = []
|
||||||
while curtime < endtime:
|
while curtime < endtime:
|
||||||
diff = endtime - curtime
|
timeout = max(.1, endtime - curtime)
|
||||||
try:
|
try:
|
||||||
resp = await self.admin_node.readexactly(8, diff)
|
resp = await self.admin_node.read(8, timeout)
|
||||||
except asyncio.TimeoutError:
|
except asyncio.TimeoutError:
|
||||||
break
|
continue
|
||||||
finally:
|
finally:
|
||||||
curtime = self._loop.time()
|
curtime = self._loop.time()
|
||||||
if resp[0] != CANBUS_RESP_NEED_NODEID:
|
if len(resp) < 7 or resp[0] != CANBUS_RESP_NEED_NODEID:
|
||||||
continue
|
continue
|
||||||
app_names = {
|
app_names = {
|
||||||
KLIPPER_SET_NODE_CMD: "Klipper",
|
KLIPPER_SET_NODE_CMD: "Klipper",
|
||||||
CANBUS_CMD_SET_NODEID: "CanBoot"
|
CANBUS_CMD_SET_NODEID: "CanBoot"
|
||||||
}
|
}
|
||||||
app = app_names.get(resp[7], "Unknown")
|
app = "Unknown"
|
||||||
|
if len(resp) > 7:
|
||||||
|
app = app_names.get(resp[7], "Unknown")
|
||||||
data = resp[1:7]
|
data = resp[1:7]
|
||||||
output_line(f"Detected UUID: {data.hex()}, Application: {app}")
|
output_line(f"Detected UUID: {data.hex()}, Application: {app}")
|
||||||
uuid = sum([v << ((5 - i) * 8) for i, v in enumerate(data)])
|
uuid = sum([v << ((5 - i) * 8) for i, v in enumerate(data)])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user