Send media file to device via JSON-RPC and decode on-device. Args: decode_path: Local file path or URL to a media file. port: Serial port for device communication. timeout: RPC timeout in seconds. serial_interface: Optional serial interface override. Returns
(
decode_path: str,
port: str,
timeout: float = 120.0,
serial_interface: "SerialInterface | None" = None,
)
| 140 | |
| 141 | |
| 142 | async def run_device_decode_autoresearch( |
| 143 | decode_path: str, |
| 144 | port: str, |
| 145 | timeout: float = 120.0, |
| 146 | serial_interface: "SerialInterface | None" = None, |
| 147 | ) -> int: |
| 148 | """Send media file to device via JSON-RPC and decode on-device. |
| 149 | |
| 150 | Args: |
| 151 | decode_path: Local file path or URL to a media file. |
| 152 | port: Serial port for device communication. |
| 153 | timeout: RPC timeout in seconds. |
| 154 | serial_interface: Optional serial interface override. |
| 155 | |
| 156 | Returns: |
| 157 | Exit code (0 = success, 1 = failure). |
| 158 | """ |
| 159 | from ci.rpc_client import RpcClient, RpcTimeoutError |
| 160 | from ci.util.global_interrupt_handler import handle_keyboard_interrupt |
| 161 | |
| 162 | print() |
| 163 | print("=" * 60) |
| 164 | print("DEVICE DECODE AUTORESEARCH MODE") |
| 165 | print("=" * 60) |
| 166 | print() |
| 167 | |
| 168 | temp_download: str | None = None |
| 169 | client: RpcClient | None = None |
| 170 | |
| 171 | try: |
| 172 | resolved = _resolve_file(decode_path) |
| 173 | file_path = resolved.file_path |
| 174 | ext = resolved.extension |
| 175 | temp_download = resolved.temp_download_path |
| 176 | |
| 177 | if ext not in SUPPORTED_EXTENSIONS: |
| 178 | supported = ", ".join(sorted(SUPPORTED_EXTENSIONS.keys())) |
| 179 | print( |
| 180 | f"{Fore.RED}Error: Unsupported file extension '{ext}'{Style.RESET_ALL}" |
| 181 | ) |
| 182 | print(f" Supported: {supported}") |
| 183 | return 1 |
| 184 | |
| 185 | if not os.path.isfile(file_path): |
| 186 | print(f"{Fore.RED}Error: File not found: {file_path}{Style.RESET_ALL}") |
| 187 | return 1 |
| 188 | |
| 189 | codec_name = SUPPORTED_EXTENSIONS[ext] |
| 190 | file_size = os.path.getsize(file_path) |
| 191 | print(f" File: {file_path}") |
| 192 | print(f" Size: {file_size:,} bytes") |
| 193 | print(f" Codec: {codec_name}") |
| 194 | print(f" Port: {port}") |
| 195 | print() |
| 196 | |
| 197 | with open(file_path, "rb") as f: |
| 198 | file_bytes = f.read() |
| 199 |
no test coverage detected