Open
Conversation
- Adds double buffer SD task design
- Modifies queue sizes for CAN Frames
- Adds proper timestamping
- Fixes CAN fanout, adds filtering stub
SamrutGadde
approved these changes
Feb 26, 2026
SamrutGadde
left a comment
There was a problem hiding this comment.
Honestly looks really good, only critique could be using some C++ features to protect those raw pointers, but ngl I think this is fine. We tested so this is good.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Closes #4
This PR introduces a proper SD Card logging system to ESP-DAQ. This system writes to SD Card over SDIO and integrates with the existing TWAI and CAN system. This PR also brings certain fixes to the CAN system, especially regarding memory management.
Design
Diagram note: red represents data flow
The SD Card is mounted via the ESP_VFS module, allowing for normal POSIX calls to the file system. FAT32 (ESP's FatFS) is used.
The SD Card system is a double buffer, two task, non-blocking system. Buffer A is written to until full, then swapped out with buffer B, which is written to. Meanwhile, a background task flushes the buffer to the SD card.
Timestamping is also introduced. Session files are created on SD card init. The behavior changes depending on whether we have real time from GPS or not. If so, a file in the format
/sdcard/LOGS/YYYY/MM/DD/SESSION_Nis created. Otherwise, a file at/sdcard/NOTIME/SESSION_RANDOMis created.Data is logged in the format:
Which is seconds.micro,can id,data.
/sdcard/METAis also created. This is where any metadata for the DAQ system may live, such as CAN ID Filtration lists.Summary of Changes
TODOs
Notes
Laptop -> (via socketcan) UCAN device -> (via CAN transceiver) ESP -> (via code, TWAI, SDIO) SD Card.
Currently, the two python scripts in the PR are used for testing. 400kbps data has been handled with minimal data drop.