Skip to content

Commit 4dbe33c

Browse files
committed
fix mic race and mcu install
1 parent 434d093 commit 4dbe33c

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎robot_orchestrator/cli.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ def _ensure_platformio_venv(paths: Paths) -> Path:
105105
venv_path.parent.mkdir(parents=True, exist_ok=True)
106106
subprocess.run([sys.executable, "-m", "venv", str(venv_path)], check=True, capture_output=True, text=True)
107107
subprocess.run([str(venv_pip(venv_path)), "install", "platformio"], check=True, capture_output=True, text=True)
108+
env = {**os.environ, "PLATFORMIO_CORE_DIR": str(paths.pio_core_dir)}
109+
subprocess.run(
110+
[str(venv_python(venv_path)), "-m", "platformio", "pkg", "install", "-g", "-t", "platformio/tool-openocd"],
111+
env=env, check=True, capture_output=True, text=True,
112+
)
108113
marker.write_text("")
109114
return venv_path
110115

‎robot_orchestrator/hal/real/microphone.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1+
import time
2+
13
from robot_orchestrator.config import MicrophoneConfig
24
from robot_orchestrator.hal.base import ProbeResult
35

46
FALLBACK_SAMPLERATES = [48000, 44100, 32000, 22050, 16000, 8000]
7+
RETRY_ATTEMPTS = 3
8+
RETRY_DELAY_S = 1.0
59

610

711
class RealMicProbe:
812
def __init__(self, config: MicrophoneConfig):
913
self.config = config
1014

1115
def probe(self) -> ProbeResult:
16+
result = self._probe_once()
17+
for _ in range(RETRY_ATTEMPTS - 1):
18+
if result.ok:
19+
return result
20+
time.sleep(RETRY_DELAY_S)
21+
result = self._probe_once()
22+
return result
23+
24+
def _probe_once(self) -> ProbeResult:
1225
try:
1326
import numpy as np
1427
import sounddevice as sd

0 commit comments

Comments
 (0)