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:
13
device.py
13
device.py
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user