Skip to content

Built-in Safe Mode page, retry of refused web requests, serial first-command fix - #9

Merged
fiverecords merged 3 commits into
mainfrom
claude/funny-lamport-f05647
Nov 11, 2026
Merged

fiverecords merged 3 commits into
mainfrom
claude/funny-lamport-f05647

Conversation

@fiverecords

@fiverecords fiverecords commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

Three fixes for the next version. No release: FIRMWARE_VERSION stays 3.8.1 and the README changelog lists them under Unreleased. The Companion protocol (port 8098, HTTP API) is unchanged.

1. Safe Mode: built-in page when safemode.html cannot be read (BOOT-13)

In Safe Mode, / (and /index.html, /ccu) answered 404 or 503 when the SD card was missing or failing, or safemode.html wasn't on it. That put the page with the exit button out of reach. v3.8 announced a built-in page, but SafeMode::printFallbackPage() was never called.

  • SdUtils::serveFile() gets an optional unreadable out-parameter. When it's given, a file that can't be read gets no answer and the caller answers instead. The other callers are unchanged, and a busy 503 still goes out as before.
  • WebServer::serveSafeModePage() serves safemode.html, or the built-in page from flash (200, text/html, no-store).
  • The page shows:
    • what Safe Mode turns off;
    • reason, last reset, failed boots (only after boot failures), uptime and firmware version;
    • the Restart in normal mode button (POST /safemode-exit with X-TallyCCU, then /), with clear messages for a 404 (already left Safe Mode) and for no answer (restarting);
    • normalboot on the serial console.
  • Scenario sm:
    • covers the file missing or back, a failing SD (also after a remount), normal mode still answering 503, the exit request, the script syntax (node --check) and the exact number of restarts;
    • fails on 3.8.1.
  • Flash and RAM: flash +2.1 KB, static RAM unchanged.

2. Web page: retry a request refused at once

With nearly every W5500 socket in use (vMix, Companion, two pages with the stream, a page reloading), port 80 is left with one socket. While that socket closes the previous request there is no listener for a moment, so the next connection is refused. That request never reaches TallyCCU.

  • Reset to Defaults then stopped at that value, and the rest were never sent and stayed unknown.
  • Load or Save preset failed.

Reproduced in the emulator with that socket load: the first Reset stopped at 10 of 16, and those values stayed ? in both tabs.

The fix:

  • sendCcu() opts.retry: a fetch that fails within 2.5 s is retried after 50, 150 and 400 ms, within the same timeout. It is used only for idempotent requests: parameter writes, getJson reads, and load/save preset.
  • Reset names the value where it stopped and how many weren't sent. Errors stay on screen for 8 s.

With the same topology and this page, 6 of 6 Resets and 6 of 6 Loads complete. This came out of a 3-hypothesis investigation (real shield timing, socket pressure, page-logic races); only socket pressure reproduced. In the user's setup the ? that remain are the intentional ones (lens position, video format, unticked groups).

3. Serial: the first command after connecting without a reset was lost

Since v3.8 the configurator opens the port without restarting the board. The USB-serial chip can then deliver a garbage byte (0x00, 0xFF), which gets glued to the first command. So Get Config did nothing until another command (for example help) consumed the byte, as reported by the user. Reproduced in the emulator.

  • Configurator: a newline before each command. Every firmware version (3.7.1 included) ignores an empty line, so this also fixes it with the 3.8/3.8.1 firmware.
  • Firmware: control bytes (except CR, LF, tab) and bytes ≥ 0x7F are dropped from the serial console.
  • Scenario ser (fast set) covers this.

Tests

  • AVR build: 0 sketch warnings, static RAM 3574 B.
  • tests/host/run.sh, check_version.py and check_pages.py pass.
  • Fast scenarios with sm and ser.
  • Chromium on the emulator for the built-in page: renders, the button exits Safe Mode, and the 404 case is handled.
  • Topology runs before and after the retry.
  • An independent review of the Safe Mode change confirmed 5 small findings, all applied.

🤖 Generated with Claude Code

https://claude.ai/code/session_01TWAWkD3MqtdyPvo7NYXQ6D

In Safe Mode, / (and /index.html, /ccu) answered 404 or 503 when the SD
card was missing or failing or safemode.html was not on it, so the page
with the exit button was out of reach. v3.8 announced a built-in page,
but SafeMode::printFallbackPage() was never called.

- SdUtils::serveFile(): optional 'unreadable' out-parameter. When given,
  a file that cannot be read (missing, SD not available, read failure
  before anything was sent) is not answered and the caller answers
  instead. Other callers are unchanged; a busy 503 stays.
- WebServer::serveSafeModePage(): safemode.html, or the built-in page
  from flash (200, text/html, Cache-Control: no-store).
- The built-in page: what Safe Mode turns off, reason, last reset,
  failed boots (only after boot failures), uptime, firmware version, the
  Restart in normal mode button (POST /safemode-exit with X-TallyCCU,
  then the main page; clear messages for 404 when the board already
  left Safe Mode and for no answer while it restarts) and normalboot.
- Scenario 'sm' (fast set): file missing, file back, SD failing (also
  after a remount), normal mode still 503, exit request, script syntax
  (node --check) and exact restart count. It fails on 3.8.1 (404/503).
- README: Safe Mode section, Unreleased changelog, v3.8 line corrected;
  v3.8 release notes file corrected (not republished).

Flash +2.1 KB, static RAM unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TWAWkD3MqtdyPvo7NYXQ6D
With nearly every W5500 socket in use (vMix, Companion, two pages with
the stream, a page reloading), port 80 is left with one socket. While
it closes the previous request there is no listener for a moment and
the next connection is refused (RST to the SYN): the request never
reaches TallyCCU and sendCcu() got no answer. Reset to Defaults then
stopped at that value and the rest were never sent (shown unknown),
and Load or Save preset failed. Reproduced in the emulator with that
socket load: the first Reset stopped at 10 of 16.

- sendCcu() opts.retry: a fetch that fails within 2.5 s (Windows itself
  retries a refused connection for 1-2 s) is tried again after 50, 150
  and 400 ms, within the same timeout. Only for idempotent requests:
  parameter writes (absolute values), getJson reads, load and save
  preset. Not for actions, motion, toggles or reboot.
- Reset names the value it stopped at and how many were not sent;
  errors of Reset and Load stay on screen for 8 s (2-2.5 s before).

Same topology with this page: 6 of 6 Reset and 6 of 6 Load complete.
No firmware or protocol change: Companion is not affected.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TWAWkD3MqtdyPvo7NYXQ6D
Since v3.8 the serial configurator opens the port without restarting
the board. Opening the USB port can deliver a garbage byte (0x00, 0xFF)
to the running sketch; it was glued to the first command ("\xffstatus":
unknown command; a 0x00 cut it to an empty line, ignored silently), so
Get Config did nothing until another command consumed it.

- Configurator: a newline before each command ends any partial line.
  Every firmware version ignores an empty line, so this also fixes it
  with the v3.8 and v3.8.1 firmware.
- Firmware: control bytes other than CR, LF and tab, and bytes from
  0x7F up, are dropped from the serial console.
- Scenario 'ser' (fast set): 0x00, 0xFF, 0xF0 and a CRLF-ended garbage
  byte before 'status', and the configurator's leading newline.
- README changelog (Unreleased): this and the web retry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TWAWkD3MqtdyPvo7NYXQ6D
@fiverecords fiverecords changed the title Safe Mode: built-in page when safemode.html cannot be read (BOOT-13) Built-in Safe Mode page, retry of refused web requests, serial first-command fix Nov 11, 2026
@fiverecords
fiverecords merged commit 73a8486 into main Nov 11, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants