diff --git a/bsp_hosted/main.cpp b/bsp_hosted/main.cpp index 4fa1eb04..5b43da1e 100644 --- a/bsp_hosted/main.cpp +++ b/bsp_hosted/main.cpp @@ -21,7 +21,7 @@ int main(void) std::cout << "-- EIVE OBSW --" << std::endl; std::cout << "-- Compiled for " << COMPILE_PRINTOUT << " --" << std::endl; std::cout << "-- Software version " << SW_NAME << " v" << SW_VERSION << "." - << SW_SUBVERSION << "." << SW_SUBSUBVERSION << " -- " << std::endl; + << SW_SUBVERSION << "." << SW_REVISION << " -- " << std::endl; std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; initmission::initMission(); diff --git a/bsp_linux_board/main.cpp b/bsp_linux_board/main.cpp index 67801c4b..2e9ce8a4 100644 --- a/bsp_linux_board/main.cpp +++ b/bsp_linux_board/main.cpp @@ -1,7 +1,8 @@ #include "InitMission.h" -#include +#include "OBSWVersion.h" -#include +#include "fsfw/FSFWVersion.h" +#include "fsfw/tasks/TaskFactory.h" #include @@ -21,8 +22,9 @@ int main(void) { std::cout << "-- EIVE OBSW --" << std::endl; std::cout << "-- Compiled for Linux board " << BOARD_NAME << " --" << std::endl; - std::cout << "-- Software version " << SW_NAME << " v" << SW_VERSION << "." - << SW_SUBVERSION << "." << SW_SUBSUBVERSION << " -- " << std::endl; + std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << + "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << + FSFW_REVISION << "--" << std::endl; std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; initmission::initMission(); diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 55cd0252..dddc4c97 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -1,10 +1,12 @@ #include "CoreController.h" #include "q7sConfig.h" +#include "OBSWVersion.h" +#include "fsfw/FSFWVersion.h" #include "fsfw/serviceinterface/ServiceInterface.h" -#include "../memory/scratchApi.h" -#include "../memory/SdCardManager.h" +#include "bsp_q7s/memory/scratchApi.h" +#include "bsp_q7s/memory/SdCardManager.h" #include @@ -46,6 +48,7 @@ ReturnValue_t CoreController::initialize() { sif::warning << "CoreController::initialize: Setting up alloc failure " "count failed" << std::endl; } + return HasReturnvaluesIF::RETURN_OK; } @@ -180,6 +183,14 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_ } } +ReturnValue_t CoreController::initializeAfterTaskCreation() { + ReturnValue_t result = versionFileInit(); + if(result != HasReturnvaluesIF::RETURN_OK) { + sif::warning << "CoreController::initialize: Version initialization failed" << std::endl; + } + return result; +} + ReturnValue_t CoreController::sdCardColdRedundantInit(SdCardManager* sdcMan, SdCardManager::SdStatusPair& statusPair) { sd::SdCard preferredSdCard = sd::SdCard::SLOT_0; @@ -254,3 +265,86 @@ ReturnValue_t CoreController::incrementAllocationFailureCount() { count++; return scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, count); } + +ReturnValue_t CoreController::versionFileInit() { + + std::string unameFileName = "/tmp/uname_version.txt"; + std::string unameCmd = "uname -a > " + unameFileName; + int result = std::system(unameCmd.c_str()); + if(result != 0) { + utility::handleSystemError(result, "CoreController::versionFileInit"); + } + std::ifstream unameFile(unameFileName); + std::string unameLine; + if(not std::getline(unameFile, unameLine)) { + sif::warning << "CoreController::versionFileInit: Retrieving uname line failed" + << std::endl; + } + + std::string fullObswVersionString = "OBSW: v" + std::to_string(SW_VERSION) + "." + + std::to_string(SW_SUBVERSION) + "." + std::to_string(SW_REVISION); + std::string fullFsfwVersionString = "FSFW: v" + std::to_string(FSFW_VERSION) + "." + + std::to_string(FSFW_SUBVERSION) + "." + std::to_string(FSFW_REVISION); + std::string systemString = "System: " + unameLine; + std::string mountPrefix = SdCardManager::instance()->getCurrentMountPrefix(); + std::string versionFilePath = mountPrefix + "/conf/version.txt"; + std::fstream versionFile; + + if(not std::filesystem::exists(versionFilePath)) { + sif::info << "Writing version file " << versionFilePath << ".." << std::endl; + versionFile.open(versionFilePath, std::ios_base::out); + versionFile << fullObswVersionString << std::endl; + versionFile << fullFsfwVersionString << std::endl; + versionFile << systemString << std::endl; + return HasReturnvaluesIF::RETURN_OK; + } + + // Check whether any version has changed + bool createNewFile = false; + versionFile.open(versionFilePath); + std::string currentVersionString; + uint8_t idx = 0; + while(std::getline(versionFile, currentVersionString)) { + if(idx == 0) { + if(currentVersionString != fullObswVersionString) { + sif::info << "OBSW version changed" << std::endl; + sif::info << "From " << currentVersionString << " to " << + fullObswVersionString << std::endl; + createNewFile = true; + } + } + else if(idx == 1) { + if(currentVersionString != fullFsfwVersionString) { + sif::info << "FSFW version changed" << std::endl; + sif::info << "From " << currentVersionString << " to " << + fullFsfwVersionString << std::endl; + createNewFile = true; + } + } + else if(idx == 2) { + if(currentVersionString != systemString) { + sif::info << "System version changed" << std::endl; + sif::info << "Old: " << currentVersionString << std::endl; + sif::info << "New: " << systemString << std::endl; + createNewFile = true; + } + } + else { + sif::warning << "Invalid version file! Rewriting it.." << std::endl; + createNewFile = true; + } + idx++; + } + + // Overwrite file if necessary + if(createNewFile) { + sif::info << "Rewriting version.txt file with updated versions.." << std::endl; + versionFile.close(); + versionFile.open(versionFilePath, std::ios_base::out | std::ios_base::trunc); + versionFile << fullObswVersionString << std::endl; + versionFile << fullFsfwVersionString << std::endl; + versionFile << systemString << std::endl; + } + + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 3e7e108a..d815f302 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -18,6 +18,8 @@ public: ReturnValue_t initialize() override; + ReturnValue_t initializeAfterTaskCreation() override; + ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t *data, size_t size) override; @@ -37,6 +39,9 @@ private: sd::SdCard sdCard, sd::SdStatus status, std::string sdString); ReturnValue_t sdCardColdRedundantInit(SdCardManager* sdcMan, SdCardManager::SdStatusPair& statusPair); + + ReturnValue_t versionFileInit(); + }; diff --git a/bsp_q7s/core/obsw.cpp b/bsp_q7s/core/obsw.cpp index 41c6c5b9..e6d46ae7 100644 --- a/bsp_q7s/core/obsw.cpp +++ b/bsp_q7s/core/obsw.cpp @@ -15,7 +15,7 @@ int obsw::obsw() { std::cout << "-- Compiled for Linux (TE0720) --" << std::endl; #endif std::cout << "-- OBSW " << SW_NAME << " v" << SW_VERSION << "." << SW_SUBVERSION << - "." << SW_SUBSUBVERSION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << + "." << SW_REVISION << ", FSFW v" << FSFW_VERSION << "." << FSFW_SUBVERSION << FSFW_REVISION << "--" << std::endl; std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl; diff --git a/cmake/scripts/Host/create_cmake_debug_cfg.sh b/cmake/scripts/Host/make_debug_cfg.sh similarity index 100% rename from cmake/scripts/Host/create_cmake_debug_cfg.sh rename to cmake/scripts/Host/make_debug_cfg.sh diff --git a/common/config/OBSWVersion.h b/common/config/OBSWVersion.h index b796f146..0274b91f 100644 --- a/common/config/OBSWVersion.h +++ b/common/config/OBSWVersion.h @@ -4,7 +4,7 @@ const char* const SW_NAME = "eive"; #define SW_VERSION 1 -#define SW_SUBVERSION 3 -#define SW_SUBSUBVERSION 0 +#define SW_SUBVERSION 5 +#define SW_REVISION 0 #endif /* COMMON_CONFIG_OBSWVERSION_H_ */ diff --git a/fsfw b/fsfw index 3e422f51..c5420c7b 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 3e422f51bd1b5f934a138f5e496675b398e27827 +Subproject commit c5420c7b538ec12f841b27f95b91d75e41b53f94 diff --git a/tmtc b/tmtc index 941f4640..2e942ec2 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 941f46401e13fb6ee5fc653875eebff8496133ec +Subproject commit 2e942ec21e47485b9ab6416a0341b9ab8ec30543