fix(#776): capture waits for the radio's first reply before timing steps

A real radio can take seconds to answer right after the port opens, and a
busy one can answer a step late. Both filed replies under the wrong step.
Send DEVICE_QUERY until DEVICE_INFO comes back (5 tries), drain stragglers,
and wait up to 5 s for a reply before giving up on a step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat/758-fake-radio-ci
diffwireauto 1 month ago
parent 8ff9a98090
commit 62bb410c38

@ -117,7 +117,9 @@ class Link:
return out
if not got and out and time.time() - last > quiet:
return out
if not got and not out and time.time() - start > max(quiet, 1.5):
# No reply yet: a radio busy with mesh traffic can take a few
# seconds, and giving up early files its answer under the next step.
if not got and not out and time.time() - start > max(quiet, 5.0):
return out
return out
@ -165,6 +167,17 @@ def main():
})
return replies
# A radio can take a few seconds to answer right after the port opens. Wait
# for the first reply before timing anything, or late answers get filed
# under the wrong step. Unanswered queries are dropped from the trace.
for _ in range(5):
link.send(bytes([CMD_DEVICE_QUERY, 3]))
first = link.frames(quiet=0.4, limit=4.0)
if any(f and f[0] == RESP_DEVICE_INFO for f in first):
break
else:
sys.exit("the radio never answered DEVICE_QUERY: is it a USB companion, and is the app closed?")
link.frames(quiet=0.6, limit=2.0) # drain any straggler
info = step(bytes([CMD_DEVICE_QUERY, 3]))
channels = info[0][3] if info and info[0][0] == RESP_DEVICE_INFO and len(info[0]) > 3 else 8
step(bytes([CMD_APP_START, 0, 0, 0, 0, 0, 0, 0]) + b"offband-trace")

Loading…
Cancel
Save

Powered by TurnKey Linux.