Send JSON-RPC command and wait for response. Args: function: RPC function name (e.g., "configure", "runTest") args: Function arguments as list (default: []) Returns: JSON response dict from device Raises: TimeoutError: If no
(self, function: str, args: list[Any] | None = None)
| 135 | self.timeout = timeout |
| 136 | |
| 137 | def send_rpc(self, function: str, args: list[Any] | None = None) -> dict[str, Any]: |
| 138 | """Send JSON-RPC command and wait for response. |
| 139 | |
| 140 | Args: |
| 141 | function: RPC function name (e.g., "configure", "runTest") |
| 142 | args: Function arguments as list (default: []) |
| 143 | |
| 144 | Returns: |
| 145 | JSON response dict from device |
| 146 | |
| 147 | Raises: |
| 148 | TimeoutError: If no response received within timeout |
| 149 | """ |
| 150 | cmd = {"method": function, "params": args or []} |
| 151 | cmd_str = json.dumps(cmd, separators=(",", ":")) |
| 152 | |
| 153 | # Send command (no manual buffer clearing needed with SerialMonitor) |
| 154 | self._monitor.write(cmd_str + "\n") |
| 155 | |
| 156 | # Wait for REMOTE: prefixed response |
| 157 | return self._wait_for_response() |
| 158 | |
| 159 | def _wait_for_response(self) -> dict[str, Any]: |
| 160 | """Wait for and parse JSON-RPC response. |
no test coverage detected