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

Move Edu program status history to FRAM #328

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

jeromehue
Copy link
Contributor

@jeromehue jeromehue commented Oct 1, 2024

Description

Move EDU program status history to FRAM by using the fram::RingArray to store program status history entries. Additionally, improve the unit test for RingArray with the addition of a custom type RingArray test case.

Fixes #204

Add a new RingArray programStatusHistory variable,
and a new update() method for it.
The only missing thing is to test that the fram is correctly written,
i.e something like `Require(fram::ram::memory[address] == value)`.
@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.83%. Comparing base (d2088ec) to head (8f382c0).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #328      +/-   ##
==========================================
+ Coverage   97.69%   97.83%   +0.13%     
==========================================
  Files          33       33              
  Lines        1039     1106      +67     
  Branches       25       25              
==========================================
+ Hits         1015     1082      +67     
  Misses         24       24              

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

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.

  • Unit tests should be as self-contained as possible. Therefore, please remove the dependency on the EDU code and test RingArray with a custom type that is defined right in the source file.

Sts1CobcSw/Edu/ProgramStatusHistory.hpp Outdated Show resolved Hide resolved
Sts1CobcSw/Edu/ProgramStatusHistory.cpp Outdated Show resolved Hide resolved
Comment on lines 22 to 26
auto entry = programStatusHistory.Get(i);
if(entry.startTime == startTime and entry.programId == programId)
{
programStatusHistory.vals[i].status = newStatus;
entry.status = newStatus;
programStatusHistory.Set(i, entry);
Copy link
Contributor

Choose a reason for hiding this comment

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

I just realized that this is not thread-safe in the sense that someone might call PushBack() between Get() and Set(). This would mean that the index i might point to a different location/entry. We somehow need to ensure that getting and setting the entry is atomic. The only way that I can think of right now that would achieve that is to add RingArray<T>::FindAndReplace(predicate, newData/Element/Entry) where predicate is a callable that takes a T const & and returns something convertible to bool.

Sts1CobcSw/Edu/ProgramStatusHistory.hpp Outdated Show resolved Hide resolved
@PatrickKa PatrickKa marked this pull request as ready for review October 19, 2024 11:38
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.

Move EDU program status history to FRAM
3 participants