Drain pending boot output from serial buffer (async). Args: max_lines: Maximum lines to drain verbose: Print drained lines Returns: Number of lines drained
(
self, max_lines: int = 100, verbose: bool = False
)
| 289 | await asyncio.sleep(0) # Yield control |
| 290 | |
| 291 | async def drain_boot_output( |
| 292 | self, max_lines: int = 100, verbose: bool = False |
| 293 | ) -> int: |
| 294 | """Drain pending boot output from serial buffer (async). |
| 295 | |
| 296 | Args: |
| 297 | max_lines: Maximum lines to drain |
| 298 | verbose: Print drained lines |
| 299 | |
| 300 | Returns: |
| 301 | Number of lines drained |
| 302 | """ |
| 303 | if not self.is_connected: |
| 304 | raise RpcError("Not connected") |
| 305 | |
| 306 | assert self._serial is not None |
| 307 | |
| 308 | lines_drained = 0 |
| 309 | |
| 310 | # Poll for boot output with short timeout (wait for buffer to drain) |
| 311 | # Use read_lines with a short timeout to drain existing buffer |
| 312 | try: |
| 313 | async for line in self._serial.read_lines(timeout=1.0): |
| 314 | self._check_interrupt() |
| 315 | lines_drained += 1 |
| 316 | |
| 317 | if verbose: |
| 318 | if lines_drained <= 3: |
| 319 | print(f" [boot] {line[:80]}") |
| 320 | elif lines_drained == 4: |
| 321 | print(" [boot] ... (draining boot output)") |
| 322 | |
| 323 | if lines_drained >= max_lines: |
| 324 | break |
| 325 | |
| 326 | except KeyboardInterrupt: |
| 327 | notify_main_thread() |
| 328 | raise |
| 329 | except Exception: |
| 330 | pass # Timeout is normal when buffer is drained |
| 331 | |
| 332 | return lines_drained |
| 333 | |
| 334 | async def send( |
| 335 | self, |
no test coverage detected