fix(node): verify D455 access and share sensor progress and recording UI
This commit is contained in:
@@ -37,17 +37,35 @@ class Host:
|
||||
def work():
|
||||
found = set()
|
||||
for dev in self.context.query_devices():
|
||||
if dev.is_playback():
|
||||
continue
|
||||
if dev.get_info(rs.camera_info.product_id).lower() != "0b5c":
|
||||
continue
|
||||
serial = dev.get_info(rs.camera_info.serial_number)
|
||||
ident = device_id(serial)
|
||||
# SDK module serial and USB serial are distinct on D455.
|
||||
# Resolve the actual transport ancestor, not list order or model count.
|
||||
physical = Path(dev.get_info(rs.camera_info.physical_port)).resolve()
|
||||
usb_serial = None
|
||||
for parent in (physical, *physical.parents):
|
||||
if (
|
||||
(parent / "idVendor").exists()
|
||||
and (parent / "idProduct").exists()
|
||||
and (parent / "idVendor").read_text().strip() == "8086"
|
||||
and (parent / "idProduct").read_text().strip() == "0b5c"
|
||||
):
|
||||
usb_serial = (parent / "serial").read_text().strip()
|
||||
break
|
||||
if not usb_serial:
|
||||
continue
|
||||
ident = device_id(usb_serial)
|
||||
found.add(ident)
|
||||
if ident not in self.devices:
|
||||
self.devices[ident] = Device(serial, self.root, self.execution)
|
||||
self.devices[ident] = Device(serial, self.root, self.execution, usb_serial)
|
||||
self.devices[ident].refresh(dev)
|
||||
for ident, device in self.devices.items():
|
||||
if ident not in found:
|
||||
device.online = False
|
||||
device.verified_this_process = False
|
||||
|
||||
await asyncio.to_thread(work)
|
||||
|
||||
@@ -112,6 +130,8 @@ class Host:
|
||||
device.start, params.get("profiles"), params.get("record", False)
|
||||
)
|
||||
result = {"ok": True}
|
||||
elif action == "replay":
|
||||
result = await asyncio.to_thread(device.replay, params.get("recording_id"))
|
||||
elif action == "stop":
|
||||
result = await asyncio.to_thread(device.stop)
|
||||
elif action == "option":
|
||||
@@ -128,8 +148,20 @@ class Host:
|
||||
except (ValueError, RuntimeError) as error:
|
||||
receipt["result"] = {"state": "error", "error": str(error)[:400]}
|
||||
atomic(path, receipt)
|
||||
self.operation_locks.pop(identifier, None)
|
||||
return web.json_response(receipt["result"])
|
||||
|
||||
async def prepare_safe(self, request):
|
||||
return web.json_response(
|
||||
{
|
||||
"safe": all(
|
||||
d.pipeline is None
|
||||
and d.acquisition not in ("preparing", "starting", "stopping")
|
||||
for d in self.devices.values()
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
async def cleanup(self, app):
|
||||
for peer in list(self.peers.items):
|
||||
await self.peers.close(peer)
|
||||
@@ -154,6 +186,7 @@ def main():
|
||||
host = Host()
|
||||
app = web.Application(client_max_size=65536, middlewares=[errors])
|
||||
app.router.add_get("/inventory", host.inventory)
|
||||
app.router.add_get("/prepare-safe", host.prepare_safe)
|
||||
app.router.add_post("/operation", host.operation)
|
||||
app.on_cleanup.append(host.cleanup)
|
||||
if SOCKET.exists():
|
||||
|
||||
Reference in New Issue
Block a user