Skip to content

Commit

Permalink
Turn framIsWorking into an EdacVariable<bool>
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickKa committed Aug 27, 2024
1 parent 4a19cdb commit 3382744
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Sts1CobcSw/CobcSoftware/FramEpsStartupTestThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class FramEpsStartupTestThread : public RODOS::StaticThread<stackSize>
auto deviceId = fram::ReadDeviceId();
if(deviceId != fram::correctDeviceId)
{
persistentstate::FramIsWorking(false);
fram::framIsWorking.Store(false);
}
eps::Initialize();
(void)eps::Read();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <Sts1CobcSw/CobcSoftware/ThreadPriorities.hpp>
#include <Sts1CobcSw/Hal/Spi.hpp>
#include <Sts1CobcSw/Periphery/Flash.hpp>
#include <Sts1CobcSw/Periphery/Fram.hpp>
#include <Sts1CobcSw/Periphery/FramEpsSpi.hpp>
#include <Sts1CobcSw/Periphery/PersistentState.hpp>
#include <Sts1CobcSw/Periphery/Rf.hpp>
Expand Down Expand Up @@ -48,7 +49,7 @@ class SpiStartupTestAndSupervisorThread : public RODOS::StaticThread<stackSize>
auto testWasSuccessful = ExecuteStartupTest(ResumeFramEpsStartupTestThread);
if(not testWasSuccessful)
{
persistentstate::FramIsWorking(false);
fram::framIsWorking.Store(false);
persistentstate::EpsIsWorking(false);
}
testWasSuccessful = ExecuteStartupTest(ResumeFlashStartupTestThread);
Expand Down
4 changes: 2 additions & 2 deletions Sts1CobcSw/FramSections/PersistentVariables.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ auto PersistentVariables<parentSection0,
{
auto protector = RODOS::ScopeProtector(&semaphore); // NOLINT(google-readability-casting)
auto [value0, value1, value2] =
fram::framIsWorking ? ReadFromFram<name>() : ReadFromCache<name>();
fram::framIsWorking.Load() ? ReadFromFram<name>() : ReadFromCache<name>();
auto voteResult = ComputeMajorityVote(value0, value1, value2);
auto value = voteResult.value_or(value0);
auto allVotesAreEqual = (value0 == value1) && (value1 == value2);
Expand All @@ -60,7 +60,7 @@ auto PersistentVariables<parentSection0,
PersistentVariableInfos...>::Store(ValueType<name> const & value)
{
auto protector = RODOS::ScopeProtector(&semaphore); // NOLINT(google-readability-casting)
if(fram::framIsWorking)
if(fram::framIsWorking.Load())
{
WriteToFram<name>(value);
}
Expand Down
2 changes: 1 addition & 1 deletion Sts1CobcSw/Periphery/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
target_link_libraries(
Sts1CobcSw_Periphery PUBLIC rodos::without_main_on_linux Sts1CobcSw_Serial Sts1CobcSw_Outcome
Sts1CobcSw_Utility
)

if(CMAKE_SYSTEM_NAME STREQUAL Generic)
target_sources(
Sts1CobcSw_Periphery PRIVATE PersistentState.cpp Flash.cpp Fram.cpp Rf.cpp Eps.cpp
FramEpsSpi.cpp
)
target_link_libraries(Sts1CobcSw_Periphery PRIVATE Sts1CobcSw_Utility)
target_link_libraries(Sts1CobcSw_Periphery PUBLIC Sts1CobcSw_Hal)
else()
target_sources(Sts1CobcSw_Periphery PRIVATE FramMock.cpp)
Expand Down
3 changes: 2 additions & 1 deletion Sts1CobcSw/Periphery/Fram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
namespace sts1cobcsw::fram
{
// --- Public globals ---
bool framIsWorking = true;

EdacVariable<bool> framIsWorking(true);


// --- Private globals ---
Expand Down
5 changes: 2 additions & 3 deletions Sts1CobcSw/Periphery/Fram.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


#include <Sts1CobcSw/Serial/Byte.hpp>
#include <Sts1CobcSw/Utility/ErrorDetectionAndCorrection.hpp>

#include <strong_type/affine_point.hpp>
#include <strong_type/equality.hpp>
Expand Down Expand Up @@ -37,9 +38,7 @@ inline constexpr auto memorySize = Size(1024 * 1024);
inline constexpr auto correctDeviceId =
DeviceId{0x03_b, 0x2E_b, 0xC2_b, 0x7F_b, 0x7F_b, 0x7F_b, 0x7F_b, 0x7F_b, 0x7F_b};

// TODO: This needs to be implemented as an EDAC variable. Maybe it should also be moved to
// somewhere else then :man-shrugging:
extern bool framIsWorking;
extern EdacVariable<bool> framIsWorking;


auto Initialize() -> void;
Expand Down
4 changes: 3 additions & 1 deletion Sts1CobcSw/Periphery/FramMock.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <Sts1CobcSw/Periphery/Fram.hpp>
#include <Sts1CobcSw/Periphery/FramMock.hpp>
#include <Sts1CobcSw/Utility/ErrorDetectionAndCorrection.hpp>

#include <strong_type/type.hpp>

Expand All @@ -7,7 +9,7 @@

namespace sts1cobcsw::fram
{
bool framIsWorking = true;
EdacVariable<bool> framIsWorking(true);


auto doInitialize = empty::DoInitialize;
Expand Down
4 changes: 2 additions & 2 deletions Tests/UnitTests/PersistentVariables.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ auto RunUnitTest() -> void
// Section: FRAM is working
{
memory.fill(0x00_b);
framIsWorking = true;
framIsWorking.Store(true);

// Section: You load what you store
{
Expand Down Expand Up @@ -179,7 +179,7 @@ auto RunUnitTest() -> void
// Section: FRAM is not working
{
memory.fill(0x00_b);
framIsWorking = false;
framIsWorking.Store(false);

// Section: You load what you store
{
Expand Down

0 comments on commit 3382744

Please sign in to comment.