(device: Any, index: int)
| 32 | |
| 33 | |
| 34 | def _device_info(device: Any, index: int) -> DeviceInfo: |
| 35 | info_obj = device.get_device_info() |
| 36 | out: DeviceInfo = {"backend": "orbbec", "index": str(index)} |
| 37 | method_fields = { |
| 38 | "name": "get_name", |
| 39 | "serial": "get_serial_number", |
| 40 | "firmware": "get_firmware_version", |
| 41 | "hardware": "get_hardware_version", |
| 42 | "uid": "get_uid", |
| 43 | "connection_type": "get_connection_type", |
| 44 | "min_sdk": "get_supported_min_sdk_version", |
| 45 | } |
| 46 | for key, method_name in method_fields.items(): |
| 47 | value = _safe_call(info_obj, method_name) |
| 48 | if value: |
| 49 | out[key] = value |
| 50 | for key, method_name in {"vid": "get_vid", "pid": "get_pid"}.items(): |
| 51 | value = _safe_call(info_obj, method_name) |
| 52 | if value: |
| 53 | out[key] = value |
| 54 | out[f"{key}_hex"] = f"{int(value):04x}" |
| 55 | if out.get("vid_hex") and out.get("pid_hex"): |
| 56 | out["usb_id"] = f"{out['vid_hex']}:{out['pid_hex']}" |
| 57 | return out |
| 58 | |
| 59 | |
| 60 | def list_devices() -> list[DeviceInfo]: |
no test coverage detected