Skip to content

fix(logs): open log files from the UI task (#7513) [2.12]#7524

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

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

Conversation

@raphaelcoeffic

Copy link
Copy Markdown
Member

Backport of #7523 to 2.12. Fixes #7513.

Telemetry briefly drops when SD-card logging starts if the LOGS/ directory is large. Log files were opened lazily from logsWrite(), which 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.

The fix moves the open/close into logsHandle(), called from perMain() on the UI task; logsWrite() only appends to an already-open file. On 2.12 the affected files (logs.cpp, sdcard.h) are identical to main, so this is a clean cherry-pick.

See #7523 for the full description.

Tested: X7 firmware + simulator build.

🤖 Generated with Claude Code

Log files were opened lazily from logsWrite(), which runs on the
FreeRTOS timer daemon task (priority 2). Telemetry frame polling is
dispatched to that same task via async_call_isr(). 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 (priority 1). logsWrite() 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 being created.

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: e89b9dcb-602c-4570-b2b4-6abf5dc27684

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.12-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:37
After logsWrite() reported a read/write error it set error_displayed and
then no-op'd on every timer tick, leaving the file open and 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, 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