Skip to content

fix(logs): open log files from the UI task (#7513) [2.11] - #7525

Open
raphaelcoeffic wants to merge 3 commits into
2.11from
2.11-fix-7513
Open

fix(logs): open log files from the UI task (#7513) [2.11]#7525
raphaelcoeffic wants to merge 3 commits into
2.11from
2.11-fix-7513

Conversation

@raphaelcoeffic

Copy link
Copy Markdown
Member

Backport of #7523 to 2.11. Fixes #7513.

Telemetry briefly drops when SD-card logging starts if the LOGS/ directory is large. Log files were opened lazily from logsWrite(), which on firmware runs on the FreeRTOS timer daemon task — the same task that dispatches telemetry frame polling. A large LOGS/ makes f_open(FA_OPEN_ALWAYS) scan the whole FAT directory and blocks that task long enough to starve telemetry.

Note on this backport

2.11 predates the os/timer.h abstraction, so this is a hand-port rather than a cherry-pick:

  • The logging timer is raw FreeRTOS (xTimer*) inside #if !defined(SIMU).
  • In the simulator, logsWrite() was already called directly from perMain() (UI thread), so SIMU never had the bug.

The unified logsHandle() opens the file on the UI thread in both configs, then either drives the FreeRTOS timer (firmware) or calls logsWrite() directly (simulator).

See #7523 for the full description.

Tested: X7 firmware + simulator build.

🤖 Generated with Claude Code

Log files were opened lazily from logsWrite(), which on firmware runs on
the FreeRTOS timer daemon task. Telemetry frame polling is dispatched to
that same task via xTimerPendFunctionCallFromISR(). When the LOGS
directory is large (thousands of files), f_open() with FA_OPEN_ALWAYS
has to scan the whole FAT directory and blocks the timer task long
enough to starve telemetry polling, producing a brief "Telemetry lost"
/ "Telemetry recovered" at log start.

Move the file open/close into the new logsHandle(), called cyclically
from perMain() on the menus/UI task. On firmware the logging timer now
only appends a line to an already-open file and never blocks on
f_open(); because the timer/telemetry task is higher priority it
preempts the directory scan running on the UI task, so telemetry keeps
flowing while the log file is created. In the simulator logsHandle()
opens the file and calls logsWrite() directly, as before (the open
already happened on the UI thread there, so it was never affected).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a63a7cc0-10d7-4b0d-9f27-5b8f76b9c702

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2.11-fix-7513

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

raphaelcoeffic and others added 2 commits July 4, 2026 07:39
After logsWrite() reported a read/write error it set error_displayed and
then no-op'd on every tick, leaving the file open (and, on firmware, the
timer firing empty callbacks) until the user toggled logging off and on.
The open-error path in logsHandle() already retried automatically, so
the two error paths were inconsistent.

Handle a pending error in logsHandle() (UI task): stop the timer (on
firmware), close the file, and retry a fresh open through the existing
open path. A successful (re)open clears error_displayed and resumes
logging; while the error persists the timer stays stopped and the file
closed, and the popup remains deduplicated.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The previous change retried the open on every perMain() cycle after any
error. For a persistent hard error (bad card / corrupted FS) that means
rescanning a potentially huge LOGS directory indefinitely, which is
wasteful and cannot succeed.

Only a full SD card is treated as recoverable: sdIsFull() is a cheap
check (no directory scan) and the condition clears when the user frees
space, so logging resumes automatically. Any other error now stops
logging until the user re-enables it (which clears error_displayed).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@pfeerick pfeerick added bug/regression ↩️ A new version of EdgeTX broke something firmware General radio firmware issue, not colorlcd or B&W specific labels Jul 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug/regression ↩️ A new version of EdgeTX broke something firmware General radio firmware issue, not colorlcd or B&W specific

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants