Enhance CLI actions and default handling

Add timed follow, src/lib upload helpers, and store default startup pattern under default key.

Made-with: Cursor
This commit is contained in:
2026-03-11 22:51:36 +13:00
parent 8df1d9dd81
commit d6ed6ad9f5
2 changed files with 70 additions and 14 deletions

View File

@@ -208,12 +208,21 @@ class DeviceConnection:
except Exception as e:
raise TransportError(f"Failed to reset device: {e}") from e
def follow_output(self):
"""Follow device output continuously (like tail -f)."""
def follow_output(self, duration=None):
"""
Follow device output (like tail -f).
Args:
duration: Optional number of seconds to follow output for. If None,
follow indefinitely until interrupted.
"""
# Use direct serial connection like dev.py does
start_time = time.time()
try:
with serial.Serial(self.device, baudrate=115200) as ser:
while True:
if duration is not None and (time.time() - start_time) >= duration:
break
if ser.in_waiting > 0:
data = ser.readline().decode('utf-8', errors='replace').strip()
if data: