working in production - not entirely validated. parallel mode working.

This commit is contained in:
2026-04-26 19:26:44 -04:00
parent f771ec2b46
commit 00ab311d92
8 changed files with 344 additions and 27 deletions

View File

@@ -63,19 +63,35 @@ def _relink(link: str, target: str) -> None:
async def main() -> int:
candidates = sorted(glob.glob("/dev/hidraw*"))
if not candidates:
print("no /dev/hidraw* devices present", file=sys.stderr)
return 1
# Hot-plug case: udev fires this script as soon as one hidraw appears, but
# a sibling inverter coming up at nearly the same moment may still be
# enumerating. Retry-probe up to ~10 s waiting for all expected serials,
# so a transient single-device sighting doesn't leave one symlink missing.
expected = set(LINK_FOR_SERIAL.keys())
deadline = asyncio.get_event_loop().time() + 10.0
sn_to_path: dict[str, str] = {}
for p in candidates:
sn = await probe_serial(p)
if sn:
print(f"{p}: serial {sn}")
sn_to_path[sn] = p
else:
print(f"{p}: no PI18 response (probably not an LVX6048)")
seen_paths: set[str] = set()
while True:
candidates = sorted(glob.glob("/dev/hidraw*"))
for p in candidates:
if p in seen_paths:
continue
seen_paths.add(p)
sn = await probe_serial(p)
if sn:
print(f"{p}: serial {sn}")
sn_to_path[sn] = p
else:
print(f"{p}: no PI18 response (probably not an LVX6048)")
if expected.issubset(sn_to_path):
break
if asyncio.get_event_loop().time() >= deadline:
break
await asyncio.sleep(0.5)
if not sn_to_path:
print("no LVX6048 devices found on /dev/hidraw*", file=sys.stderr)
return 1
missing = []
for sn, link in LINK_FOR_SERIAL.items():