MCPcopy Create free account
hub / github.com/FastLED/FastLED / run

Method run

ci/util/serial_monitor.py:415–523  ·  view source on GitHub ↗

Run the PIO device monitor until timeout or handler requests stop. Returns: True if all handlers succeeded, False otherwise

(self)

Source from the content-addressed store, hash-verified

413 self.mHandlers.append(handler)
414
415 def run(self) -> bool:
416 """Run the PIO device monitor until timeout or handler requests stop.
417
418 Returns:
419 True if all handlers succeeded, False otherwise
420 """
421 cmd = [
422 "pio",
423 "device",
424 "monitor",
425 "--project-dir",
426 str(self.mBuildDir),
427 ]
428 if self.mEnvironment:
429 cmd.extend(["--environment", self.mEnvironment])
430 if self.mMonitorPort:
431 cmd.extend(["--port", self.mMonitorPort])
432 if self.mVerbose:
433 cmd.append("--verbose")
434
435 formatter = TimestampFormatter()
436 proc = RunningProcess(
437 cmd,
438 cwd=self.mBuildDir,
439 auto_run=True,
440 output_formatter=formatter,
441 env=get_utf8_env(),
442 )
443
444 start_time = time.time()
445 timeout_reached = False
446 should_continue = True
447
448 try:
449 while should_continue:
450 # Check timeout (unless in streaming mode)
451 if not self.mStream:
452 elapsed = time.time() - start_time
453 if elapsed >= self.mTimeoutSeconds:
454 print(
455 f"\n⏱️ Timeout reached ({self.mTimeoutSeconds}s), stopping monitor..."
456 )
457 timeout_reached = True
458 proc.terminate()
459 break
460
461 # Read next line with 30 second read timeout
462 try:
463 line = proc.get_next_line(timeout=30)
464 if isinstance(line, EndOfStream):
465 break
466 if line:
467 print(line) # Real-time output
468
469 # Dispatch to all handlers
470 for handler in self.mHandlers:
471 if not handler.handle_line(str(line)):
472 # Handler requested stop

Callers

nothing calls this directly

Calls 11

TimestampFormatterClass · 0.90
get_utf8_envFunction · 0.90
allFunction · 0.85
timeMethod · 0.80
terminateMethod · 0.80
printFunction · 0.50
appendMethod · 0.45
handle_lineMethod · 0.45
waitMethod · 0.45
is_successfulMethod · 0.45

Tested by

no test coverage detected