-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
3adfea5
to
d3f244e
Compare
Codecov ReportAttention: Patch coverage is
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. |
a114b96
to
f31eeb7
Compare
There was a problem hiding this 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.
1c9c064
to
5f33388
Compare
5c2108e
to
049ac75
Compare
384d7e3
to
21cb751
Compare
5646472
to
580722d
Compare
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.
3378561
to
8d6e6ad
Compare
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.
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.
Fixes #323
Also, changes
PersistentVariables
to only take a singleSection
as template parameter. The three subsections for the redundant storage of the variables are generated inside the class.