Skip to content

Commit 5b80767

Browse files
committed
traces
1 parent 3f7fe47 commit 5b80767

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/meshcore_cli/meshcore_cli.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,6 +1694,39 @@ async def next_cmd(mc, cmds, json_output=False):
16941694
print(res.payload)
16951695
print(json.dumps(res.payload, indent=4))
16961696

1697+
case "trace" :
1698+
argnum = 1
1699+
res = await mc.commands.send_trace(path=cmds[1])
1700+
if res and res.type != EventType.ERROR:
1701+
tag= int.from_bytes(res.payload['expected_ack'], byteorder="little")
1702+
timeout = res.payload["suggested_timeout"] / 1000 * 1.2
1703+
ev = await mc.wait_for_event(EventType.TRACE_DATA,
1704+
attribute_filters={"tag": tag},
1705+
timeout=timeout)
1706+
if ev is None:
1707+
if json_output:
1708+
print(json.dumps({"error" : "timeout waiting trace"}))
1709+
else :
1710+
print("Timeout waiting trace")
1711+
elif ev.type == EventType.ERROR:
1712+
if json_output:
1713+
print(ev.payload)
1714+
else :
1715+
print("Error waiting trace")
1716+
else:
1717+
if json_output:
1718+
print(ev.payload)
1719+
else :
1720+
print("Self]",end="")
1721+
for t in ev.payload["path"]:
1722+
print("→",end="")
1723+
print(f"{t['snr']:.2f}",end="")
1724+
print("→",end="")
1725+
if "hash" in t:
1726+
print(f"[{t['hash']}]",end="")
1727+
else:
1728+
print("[Self")
1729+
16971730
case "login" | "l" :
16981731
argnum = 2
16991732
await mc.ensure_contacts()

0 commit comments

Comments
 (0)