From 3d941191e37be2b19a9b10f2dd4b189fb9f25579 Mon Sep 17 00:00:00 2001 From: a2nr Date: Fri, 17 Jul 2026 10:35:23 +0700 Subject: [PATCH] refactor(usb-deployer): name timing constants for sync window tuning --- frontend/src/lib/services/usb-deployer.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/services/usb-deployer.ts b/frontend/src/lib/services/usb-deployer.ts index 6f552d3..e158534 100644 --- a/frontend/src/lib/services/usb-deployer.ts +++ b/frontend/src/lib/services/usb-deployer.ts @@ -91,12 +91,16 @@ const ATMEGA328P_SIG_2 = 0x0f; const ATMEGA328P_FLASH_SIZE = 32768; const ATMEGA328P_PAGE_SIZE = 128; -const STK_SYNC_RETRIES = 10; -const STK_SYNC_TIMEOUT_MS = 500; /* Longer timeout for initial sync (optiboot may be slow) */ +const STK_SYNC_RETRIES = 6; +const STK_SYNC_TIMEOUT_MS = 300; /* Per-attempt read timeout during initial sync */ const STK_CMD_TIMEOUT_MS = 200; const STK_PAGE_TIMEOUT_MS = 500; const STK_LEAVE_TIMEOUT_MS = 100; +const BOOTLOADER_SETTLE_MS = 100; /* Wait after DTR release for optiboot to start */ +const DRAIN_BYTE_TIMEOUT_MS = 10; /* How long to wait for the next stray byte */ +const DRAIN_TOTAL_MS = 50; /* Max total time to spend draining */ + /* ── Arduino VID/PID pairs for port filter ─────────────────────────── */ const ARDUINO_VID_PIDS: SerialPortFilter[] = [ { usbVendorId: 0x2341, usbProductId: 0x0043 },