velxio/backend/app/services
David Montero Crespo 2a3935f682 fix(esp32-worker): never block QEMU callbacks on stdout (_emit queue)
_emit() wrote to stdout synchronously from QEMU callback context — the
iothread fires _on_uart_tx per UART byte, each becoming ~45 bytes of
JSON. When the parent's pipe reader stalled, the 64 KB pipe filled and
the write blocked INSIDE the QEMU iothread, freezing the entire guest.
Observed as an intermittent (~1 in 10) boot hang: serial output stops
right after the ROM log / rtcinit line — exactly where the accumulated
boot events cross the pipe capacity — and never recovers. Direct worker
harness runs (fast reader) never reproduced it; the browser/WS path did.

Route _emit() through a bounded queue drained by a dedicated writer
thread (opportunistic batching, one write per drain). Under extreme
backpressure events are dropped and counted on stderr — losing telemetry
beats freezing the emulated CPU. The shutdown path posts a sentinel and
joins the writer so crash/system events still flush before os._exit.

Verified on staging: 10/10 UI run/stop cycles + 8/8 direct harness boots
with identical serial latency (~0.95s to first app output).
2026-07-15 20:00:15 +02:00
..
boot_images feat(pi): gpiozero core + boot feedback, terminal and upload UX 2026-06-22 20:21:06 +02:00
esp-idf-template fix(esp32): enable mbedTLS PSK so WiFiClientSecure/HTTPClient link 2026-06-10 20:50:48 +02:00
__init__.py
arduino_cli.py feat(P2.1h): Library Manager 'Installed' list reads the cache, not the global volume 2026-06-08 06:14:17 +02:00
asm8080.py
asmz80.py
board_access.py feat: STM32 (Blue Pill / Black Pill) QEMU emulation + Pro board gating 2026-05-30 19:06:14 -03:00
c_compile.py fix(c-compile): drop --code-loc 0x100 that overwrote SDCC's crt0 init (Z80) 2026-06-03 20:11:01 +02:00
chip_compile.py
esp32_flash_image.py
esp32_i2c_slaves.py
esp32_lib_bridge.py
esp32_lib_manager.py feat(microsd): SD-over-SPI card storage for AVR, RP2040 and ESP32 2026-06-11 03:59:53 +02:00
esp32_sd_slave.py feat(microsd): SD-over-SPI card storage for AVR, RP2040 and ESP32 2026-06-11 03:59:53 +02:00
esp32_signals.py
esp32_spi_slaves.py feat(epaper): decode the UC8179/GD7965 7.5" panel + fix its BUSY polarity 2026-06-04 23:45:37 -03:00
esp32_worker.py fix(esp32-worker): never block QEMU callbacks on stdout (_emit queue) 2026-07-15 20:00:15 +02:00
esp_qemu_manager.py
espidf_compiler.py fix(espidf): compile ESP32-S3 for the esp32s3 target (not esp32) 2026-07-11 01:51:02 +02:00
gpio_shim.py
qemu_manager.py feat: STM32 (Blue Pill / Black Pill) QEMU emulation + Pro board gating 2026-05-30 19:06:14 -03:00
rom_compile.py
signal_router.py
stm32_lib_manager.py feat(boards): add 6 STM32 boards (F4 Discovery, Olimex H405, Netduino 2/+2, Pill variants) 2026-05-31 03:19:26 -03:00
stm32_worker.py sim: drive RP2040 + STM32 digital inputs from the real circuit 2026-06-26 22:05:24 +02:00
wasm_chip_runtime.py
wasm_chip_slave.py
wifi_status_parser.py