Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add abstraction for FRAM ring array #296

Merged
merged 15 commits into from
Sep 15, 2024
Merged

Add abstraction for FRAM ring array #296

merged 15 commits into from
Sep 15, 2024

Conversation

jeromehue
Copy link
Contributor

@jeromehue jeromehue commented May 28, 2024

Fixes #323

Also, changes PersistentVariables to only take a single Section as template parameter. The three subsections for the redundant storage of the variables are generated inside the class.

@jeromehue jeromehue force-pushed the fram-ringbuffer branch 4 times, most recently from 3adfea5 to d3f244e Compare May 28, 2024 13:47
@codecov-commenter
Copy link

codecov-commenter commented May 28, 2024

Codecov Report

Attention: Patch coverage is 95.09804% with 10 lines in your changes missing coverage. Please review.

Project coverage is 93.63%. Comparing base (c97b363) to head (740db96).

Files with missing lines Patch % Lines
Sts1CobcSw/Edu/ProgramStatusHistory.cpp 0.00% 10 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #296      +/-   ##
==========================================
- Coverage   94.08%   93.63%   -0.46%     
==========================================
  Files          36       38       +2     
  Lines         947     1084     +137     
  Branches       15       26      +11     
==========================================
+ Hits          891     1015     +124     
- Misses         56       69      +13     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@PatrickKa PatrickKa changed the title Add a fram ringbuffer class Add an FRAM ring buffer class Jun 21, 2024
Copy link
Contributor

@PatrickKa PatrickKa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I started with this review at the top of FramRingBuffer.hpp and just added comments while reading along. Only when I was somewhere in Get() I decided to take a step back, look at the bigger picture and try to understand how this ring buffer actually works. As it turns out, it does not do what I thought it does and what I want it to do. I am sorry to say this after taking so long with this review, but please reimplement the FRAM ring buffer to work similarly to an etl::circular_buffer. Of course, we do not need the full API. We only insert elements at the end and never remove anything. We probably also do not need iterators. I think what we need is the following:

  • operator[]
  • Back()
  • maybe Front()
  • Size()
  • maybe Capacity()
  • Push() (just the one inserting a single value)

What I completely forgot so far is that we also need something like an Initialize() function that searches for the current begin and end of the buffer. For this, we must also store a consecutive number along the actual elements. The begin/end is then found by comparing neighboring numbers and checking if the next one is smaller than the previous one.

As a note at the end: Yes, I was too lazy to remove the comments I made so far again, and I didn't take a look at the rest of the code too. The ring buffer implementation must be corrected first.

Sts1CobcSw/Periphery/FramRingBuffer.hpp Outdated Show resolved Hide resolved
Sts1CobcSw/Periphery/FramRingBuffer.hpp Outdated Show resolved Hide resolved
Sts1CobcSw/Periphery/FramRingBuffer.hpp Outdated Show resolved Hide resolved
Sts1CobcSw/Periphery/FramRingBuffer.hpp Outdated Show resolved Hide resolved
Sts1CobcSw/Periphery/FramRingBuffer.hpp Outdated Show resolved Hide resolved
Sts1CobcSw/Periphery/FramRingBuffer.hpp Outdated Show resolved Hide resolved
Sts1CobcSw/Periphery/FramRingBuffer.hpp Outdated Show resolved Hide resolved
Sts1CobcSw/Periphery/FramRingBuffer.hpp Outdated Show resolved Hide resolved
Sts1CobcSw/Periphery/FramRingBuffer.hpp Outdated Show resolved Hide resolved
Sts1CobcSw/Periphery/FramRingBuffer.hpp Outdated Show resolved Hide resolved
The logic of the Fram ringbuffer is based on the ETL circular buffer.
It offers the following methods : Front(), Back(), Push(), Capacity(),
Size(), and the bracket operator for element access.
Its usage is demonstrated in the FramRinfBuffer.test.cpp unit test.
@PatrickKa PatrickKa force-pushed the fram-ringbuffer branch 2 times, most recently from 3378561 to 8d6e6ad Compare September 1, 2024 18:04
It has basically the same public interface but using my new cool stuff
like `Section` and `PersistentVariables`. Also, the class has only
`static` members now, because it doesn't make sense to have multiple
`RingArray` instances over the same FRAM section.
It was explicitly defaulted but the implicitly defined one does the same
so no reason to waste vertical space.
@PatrickKa PatrickKa changed the title Add an FRAM ring buffer class Add abstraction for FRAM ring array Sep 12, 2024
Instead of prividing three separate `Section`s, the constructor of
`PersistentVariables` now only requires a single one. The three sections
for the three copies of the variables are generated inside the class.
@PatrickKa PatrickKa marked this pull request as ready for review September 15, 2024 14:24
@PatrickKa PatrickKa self-requested a review September 15, 2024 14:24
@PatrickKa PatrickKa merged commit ba7f400 into master Sep 15, 2024
6 checks passed
@PatrickKa PatrickKa deleted the fram-ringbuffer branch September 15, 2024 14:46
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.

Add abstraction for FRAM ring array
3 participants