Merge branch 'irini' into scex-additions

This commit is contained in:
Irini Kosmidou 2022-09-27 19:08:40 +02:00
commit d3c7bae087
39 changed files with 407 additions and 213 deletions

View File

@ -382,10 +382,8 @@ add_subdirectory(${TEST_PATH})
add_subdirectory(${UNITTEST_PATH}) add_subdirectory(${UNITTEST_PATH})
# This should have already been downloaded by the FSFW Still include it to be # This should have already been downloaded by the FSFW Still include it to be
# safe # safe find_package(etl ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET) Not
# find_package(etl ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET) # installed, so use FetchContent to download and provide etl if(NOT etl_FOUND)
# Not installed, so use FetchContent to download and provide etl
# if(NOT etl_FOUND)
message( message(
STATUS STATUS
"No ETL installation was found with find_package. Installing and providing " "No ETL installation was found with find_package. Installing and providing "

View File

@ -1,5 +1,5 @@
target_sources(${OBSW_NAME} PUBLIC InitMission.cpp main.cpp gpioInit.cpp target_sources(${OBSW_NAME} PUBLIC InitMission.cpp main.cpp gpioInit.cpp
ObjectFactory.cpp) ObjectFactory.cpp RPiSdCardManager.cpp)
add_subdirectory(boardconfig) add_subdirectory(boardconfig)
add_subdirectory(boardtest) add_subdirectory(boardtest)

View File

@ -8,6 +8,7 @@
#include <fsfw/tasks/FixedTimeslotTaskIF.h> #include <fsfw/tasks/FixedTimeslotTaskIF.h>
#include <fsfw/tasks/PeriodicTaskIF.h> #include <fsfw/tasks/PeriodicTaskIF.h>
#include <fsfw/tasks/TaskFactory.h> #include <fsfw/tasks/TaskFactory.h>
#include <linux/InitMission.h>
#include <mission/utility/InitMission.h> #include <mission/utility/InitMission.h>
#include <iostream> #include <iostream>
@ -78,34 +79,10 @@ void initmission::initTasks() {
sif::error << "Add component TMTC Polling failed" << std::endl; sif::error << "Add component TMTC Polling failed" << std::endl;
} }
#if OBSW_ADD_SCEX == 1 #if OBSW_ADD_SCEX_DEVICE == 1
PeriodicTaskIF* scexDevHandler = factory->createPeriodicTask( PeriodicTaskIF* scexDevHandler;
"SCEX_DEV", 35, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc); PeriodicTaskIF* scexReaderTask;
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION); scheduling::schedulingScex(*factory, scexDevHandler, scexReaderTask);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("SCEX_DEV", objects::SCEX);
}
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("SCEX_DEV", objects::SCEX);
}
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("SCEX_DEV", objects::SCEX);
}
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("SCEX_DEV", objects::SCEX);
}
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ);
result = HasReturnvaluesIF::RETURN_OK;
PeriodicTaskIF* scexReaderTask = factory->createPeriodicTask(
"SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = scexReaderTask->addComponent(objects::SCEX_UART_READER);
if (result != HasReturnvaluesIF::RETURN_OK) {
initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER);
}
#endif #endif
/* PUS Services */ /* PUS Services */
@ -140,7 +117,7 @@ void initmission::initTasks() {
#endif /* OBSW_ADD_TEST_CODE == 1 */ #endif /* OBSW_ADD_TEST_CODE == 1 */
taskStarter(pstTasks, "PST Tasks"); taskStarter(pstTasks, "PST Tasks");
#if OBSW_ADD_SCEX == 1 #if OBSW_ADD_SCEX_DEVICE == 1
scexDevHandler->startTask(); scexDevHandler->startTask();
scexReaderTask->startTask(); scexReaderTask->startTask();
#endif #endif
@ -229,9 +206,9 @@ void initmission::createPstTasks(TaskFactory& factory,
FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask(
"SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); "SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc);
result = pst::pstSpi(spiPst); result = pst::pstSpi(spiPst);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl; sif::error << "InitMission::createPstTasks: Creating PST failed!" << std::endl;
} }
} else { } else {
taskVec.push_back(spiPst); taskVec.push_back(spiPst);
@ -269,7 +246,7 @@ void initmission::createTestTasks(TaskFactory& factory,
PeriodicTaskIF* scexReaderTask = factory.createPeriodicTask( PeriodicTaskIF* scexReaderTask = factory.createPeriodicTask(
"SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); "SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = scexReaderTask->addComponent(objects::SCEX_UART_READER); result = scexReaderTask->addComponent(objects::SCEX_UART_READER);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER); initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER);
} }
taskVec.push_back(scexReaderTask); taskVec.push_back(scexReaderTask);

View File

@ -28,7 +28,7 @@
#define OBSW_ADD_RTD_DEVICES 0 #define OBSW_ADD_RTD_DEVICES 0
#define OBSW_ADD_PL_PCDU 0 #define OBSW_ADD_PL_PCDU 0
#define OBSW_ADD_TMP_DEVICES 0 #define OBSW_ADD_TMP_DEVICES 0
#define OBSW_ADD_SCEX 1 #define OBSW_ADD_SCEX_DEVICE 1
#define OBSW_ADD_RAD_SENSORS 0 #define OBSW_ADD_RAD_SENSORS 0
#define OBSW_ADD_SYRLINKS 0 #define OBSW_ADD_SYRLINKS 0
#define OBSW_STAR_TRACKER_GROUND_CONFIG 1 #define OBSW_STAR_TRACKER_GROUND_CONFIG 1

View File

@ -1,5 +1,6 @@
#include "ObjectFactory.h" #include "ObjectFactory.h"
#include <bsp_linux_board/RPiSdCardManager.h>
#include <linux/devices/ScexUartReader.h> #include <linux/devices/ScexUartReader.h>
#include "OBSWConfig.h" #include "OBSWConfig.h"
@ -47,8 +48,8 @@
#include "fsfw_hal/linux/spi/SpiCookie.h" #include "fsfw_hal/linux/spi/SpiCookie.h"
void Factory::setStaticFrameworkObjectIds() { void Factory::setStaticFrameworkObjectIds() {
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; PusServiceBase::PUS_DISTRIBUTOR = objects::PUS_PACKET_DISTRIBUTOR;
PusServiceBase::packetDestination = objects::TM_FUNNEL; PusServiceBase::PACKET_DESTINATION = objects::TM_FUNNEL;
CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR;
CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL;
@ -56,9 +57,6 @@ void Factory::setStaticFrameworkObjectIds() {
TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; TmFunnel::downlinkDestination = objects::TMTC_BRIDGE;
// No storage object for now. // No storage object for now.
TmFunnel::storageDestination = objects::NO_OBJECT; TmFunnel::storageDestination = objects::NO_OBJECT;
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
TmPacketBase::timeStamperId = objects::TIME_STAMPER;
} }
void ObjectFactory::produce(void* args) { void ObjectFactory::produce(void* args) {
@ -84,8 +82,9 @@ void ObjectFactory::produce(void* args) {
#endif #endif
#endif #endif
#if OBSW_ADD_SCEX == 1 #if OBSW_ADD_SCEX_DEVICE == 1
createScexComponents(uart::DEV, pwrSwitcher); auto* sdcMan = new RPiSdCardManager("/tmp");
createScexComponents(uart::DEV, pwrSwitcher, *sdcMan, true, std::nullopt);
#endif #endif
#if OBSW_ADD_SUN_SENSORS == 1 #if OBSW_ADD_SUN_SENSORS == 1
@ -202,8 +201,7 @@ void ObjectFactory::createTestTasks() {
#endif #endif
#if OBSW_ADD_UART_TEST_CODE == 1 #if OBSW_ADD_UART_TEST_CODE == 1
auto scexReader = new ScexUartReader(objects::SCEX_UART_READER); new UartTestClass(objects::UART_TEST);
new UartTestClass(objects::UART_TEST, scexReader);
#else #else
new UartComIF(objects::UART_COM_IF); new UartComIF(objects::UART_COM_IF);
#endif #endif

View File

@ -0,0 +1,13 @@
#include "RPiSdCardManager.h"
RPiSdCardManager::RPiSdCardManager(std::string prefix) : prefix(std::move(prefix)) {}
const std::string& RPiSdCardManager::getCurrentMountPrefix() const { return prefix; }
bool RPiSdCardManager::isSdCardMounted(sd::SdCard sdCard) { return true; }
std::optional<sd::SdCard> RPiSdCardManager::getPreferredSdCard() const { return std::nullopt; }
void RPiSdCardManager::setActiveSdCard(sd::SdCard sdCard) {}
std::optional<sd::SdCard> RPiSdCardManager::getActiveSdCard() const { return std::nullopt; }

View File

@ -0,0 +1,18 @@
#ifndef BSP_LINUX_BOARD_RPISDCARDMANAGER_H_
#define BSP_LINUX_BOARD_RPISDCARDMANAGER_H_
#include <mission/memory/SdCardMountedIF.h>
class RPiSdCardManager : public SdCardMountedIF {
public:
RPiSdCardManager(std::string prefix);
const std::string& getCurrentMountPrefix() const override;
bool isSdCardMounted(sd::SdCard sdCard) override;
std::optional<sd::SdCard> getPreferredSdCard() const override;
void setActiveSdCard(sd::SdCard sdCard) override;
std::optional<sd::SdCard> getActiveSdCard() const override;
private:
std::string prefix;
};
#endif /* BSP_LINUX_BOARD_RPISDCARDMANAGER_H_ */

View File

@ -15,6 +15,7 @@ static constexpr char UART_PLOC_MPSOC_DEV[] = "/dev/ul-plmpsoc";
static constexpr char UART_PLOC_SUPERVSIOR_DEV[] = "/dev/ul-plsv"; static constexpr char UART_PLOC_SUPERVSIOR_DEV[] = "/dev/ul-plsv";
static constexpr char UART_SYRLINKS_DEV[] = "/dev/ul-syrlinks"; static constexpr char UART_SYRLINKS_DEV[] = "/dev/ul-syrlinks";
static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ul-str"; static constexpr char UART_STAR_TRACKER_DEV[] = "/dev/ul-str";
static constexpr char UART_SCEX_DEV[] = "/dev/ul-scex";
static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0"; static constexpr char UIO_PDEC_REGISTERS[] = "/dev/uio0";
static constexpr char UIO_PTME[] = "/dev/uio1"; static constexpr char UIO_PTME[] = "/dev/uio1";

View File

@ -139,7 +139,11 @@ ReturnValue_t CoreController::initialize() {
ReturnValue_t CoreController::initializeAfterTaskCreation() { ReturnValue_t CoreController::initializeAfterTaskCreation() {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
sdInfo.pref = sdcMan->getPreferredSdCard(); auto sdCard = sdcMan->getPreferredSdCard();
if (not sdCard) {
return returnvalue::FAILED;
}
sdInfo.pref = sdCard.value();
sdcMan->setActiveSdCard(sdInfo.pref); sdcMan->setActiveSdCard(sdInfo.pref);
currMntPrefix = sdcMan->getCurrentMountPrefix(); currMntPrefix = sdcMan->getCurrentMountPrefix();
if (BLOCKING_SD_INIT) { if (BLOCKING_SD_INIT) {
@ -337,7 +341,11 @@ ReturnValue_t CoreController::sdStateMachine() {
if (sdInfo.state == SdStates::SET_STATE_SELF) { if (sdInfo.state == SdStates::SET_STATE_SELF) {
if (not sdInfo.commandExecuted) { if (not sdInfo.commandExecuted) {
result = sdcMan->getSdCardsStatus(sdInfo.currentState); result = sdcMan->getSdCardsStatus(sdInfo.currentState);
sdInfo.pref = sdcMan->getPreferredSdCard(); auto sdCard = sdcMan->getPreferredSdCard();
if (not sdCard) {
return returnvalue::FAILED;
}
sdInfo.pref = sdCard.value();
updateSdInfoOther(); updateSdInfoOther();
if (sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { if (sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) {
sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl; sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl;
@ -384,6 +392,7 @@ ReturnValue_t CoreController::sdStateMachine() {
if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) { if (nonBlockingOpChecking(SdStates::DETERMINE_OTHER, 5, "Mounting SD card")) {
sdInfo.prefState = sd::SdState::MOUNTED; sdInfo.prefState = sd::SdState::MOUNTED;
currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED); currentStateSetter(sdInfo.pref, sd::SdState::MOUNTED);
sdcMan->setActiveSdCard(sdInfo.pref);
} }
} }
} }

View File

@ -1,6 +1,7 @@
#include "bsp_q7s/core/InitMission.h" #include "bsp_q7s/core/InitMission.h"
#include <fsfw/devicehandlers/DeviceCommunicationIF.h> #include <fsfw/devicehandlers/DeviceCommunicationIF.h>
#include <linux/InitMission.h>
#include <iostream> #include <iostream>
#include <vector> #include <vector>
@ -242,6 +243,11 @@ void initmission::initTasks() {
initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE); initmission::printAddObjectError("PTME_TEST", objects::CCSDS_IP_CORE_BRIDGE);
} }
#endif #endif
#if OBSW_ADD_SCEX_DEVICE == 1
PeriodicTaskIF* scexDevHandler;
PeriodicTaskIF* scexReaderTask;
scheduling::schedulingScex(*factory, scexDevHandler, scexReaderTask);
#endif
std::vector<PeriodicTaskIF*> pusTasks; std::vector<PeriodicTaskIF*> pusTasks;
createPusTasks(*factory, missedDeadlineFunc, pusTasks); createPusTasks(*factory, missedDeadlineFunc, pusTasks);
@ -280,8 +286,9 @@ void initmission::initTasks() {
taskStarter(pstTasks, "PST task vector"); taskStarter(pstTasks, "PST task vector");
taskStarter(pusTasks, "PUS task vector"); taskStarter(pusTasks, "PUS task vector");
#if OBSW_ADD_TEST_CODE == 1 #if OBSW_ADD_SCEX_DEVICE == 1
taskStarter(testTasks, "Test task vector"); scexDevHandler->startTask();
scexReaderTask->startTask();
#endif #endif
#if OBSW_TEST_CCSDS_BRIDGE == 1 #if OBSW_TEST_CCSDS_BRIDGE == 1
@ -304,6 +311,11 @@ void initmission::initTasks() {
#if OBSW_ADD_PLOC_SUPERVISOR == 1 #if OBSW_ADD_PLOC_SUPERVISOR == 1
supvHelperTask->startTask(); supvHelperTask->startTask();
#endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */ #endif /* OBSW_ADD_PLOC_SUPERVISOR == 1 */
#if OBSW_ADD_TEST_CODE == 1
taskStarter(testTasks, "Test task vector");
#endif
sif::info << "Tasks started.." << std::endl; sif::info << "Tasks started.." << std::endl;
} }
@ -514,23 +526,23 @@ void initmission::createTestTasks(TaskFactory& factory,
} }
/** /**
â â
âŒâ∠ââââŒ
âŒââ∠ââââââ<EFBFBD>
â<EFBFBD>ââââââââââââââââââ<EFBFBD>
âââââââââââââââˆââââˆââ<EFBFBD>
âââââââââââââââââââˆâˆâââŒ
â<EFBFBD>ââââââââââââââââââââââââŒ
âŒâââŒâˆâââââââââˆâââââââââˆââ<EFBFBD>
â<EFBFBD>ââââââââââââŒâˆâˆââââââââââââŒ
âŒââââˆâˆâââââââââââââââââââââŒ
âŒâââ<EFBFBD>ââˆââˆâŒâââââââââââââââââââ<EFBFBD>
â<EFBFBD>âââ<EFBFBD>ââ<EFBFBD>âââââââââââââââââââââââŒ
â<EFBFBD>âââââââââââââââââââââââââââ<EFBFBD>
âŒââââââââââââââââââââââââââŒ
â<EFBFBD>âââââââââââââââââââââââââ<EFBFBD>
âââââââââââââââââââââââââŒ
ââââââââââââââââââââââ
ââââââââââââââââââ
ââââââââââââ
**/ **/

View File

@ -1,5 +1,7 @@
#include "ObjectFactory.h" #include "ObjectFactory.h"
#include <linux/devices/ScexUartReader.h>
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "bsp_q7s/boardtest/Q7STestTask.h" #include "bsp_q7s/boardtest/Q7STestTask.h"
#include "bsp_q7s/callbacks/gnssCallback.h" #include "bsp_q7s/callbacks/gnssCallback.h"
@ -865,6 +867,7 @@ void ObjectFactory::createTestComponents(LinuxLibgpioIF* gpioComIF) {
new I2cTestClass(objects::I2C_TEST, q7s::I2C_DEFAULT_DEV); new I2cTestClass(objects::I2C_TEST, q7s::I2C_DEFAULT_DEV);
#endif #endif
#if OBSW_ADD_UART_TEST_CODE == 1 #if OBSW_ADD_UART_TEST_CODE == 1
// auto* reader= new ScexUartReader(objects::SCEX_UART_READER);
new UartTestClass(objects::UART_TEST); new UartTestClass(objects::UART_TEST);
#endif #endif
} }

View File

@ -1,3 +1,5 @@
#include <mission/devices/devicedefinitions/GomspaceDefinitions.h>
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "bsp_q7s/core/CoreController.h" #include "bsp_q7s/core/CoreController.h"
#include "bsp_q7s/core/ObjectFactory.h" #include "bsp_q7s/core/ObjectFactory.h"
@ -56,6 +58,11 @@ void ObjectFactory::produce(void* args) {
#if OBSW_USE_CCSDS_IP_CORE == 1 #if OBSW_USE_CCSDS_IP_CORE == 1
createCcsdsComponents(gpioComIF); createCcsdsComponents(gpioComIF);
#endif /* OBSW_USE_CCSDS_IP_CORE == 1 */ #endif /* OBSW_USE_CCSDS_IP_CORE == 1 */
#if OBSW_ADD_SCEX_DEVICE == 1
createScexComponents(q7s::UART_GNSS_DEV, pwrSwitcher, *SdCardManager::instance(), false,
pcdu::Switches::PDU1_CH5_SOLAR_CELL_EXP_5V);
#endif
/* Test Task */ /* Test Task */
#if OBSW_ADD_TEST_CODE == 1 #if OBSW_ADD_TEST_CODE == 1
createTestComponents(gpioComIF); createTestComponents(gpioComIF);

View File

@ -71,8 +71,9 @@ void FileSystemHandler::fileSystemHandlerLoop() {
void FileSystemHandler::fileSystemCheckup() { void FileSystemHandler::fileSystemCheckup() {
SdCardManager::SdStatePair statusPair; SdCardManager::SdStatePair statusPair;
sdcMan->getSdCardsStatus(statusPair); sdcMan->getSdCardsStatus(statusPair);
sd::SdCard preferredSdCard = sdcMan->getPreferredSdCard(); auto preferredSdCard = sdcMan->getPreferredSdCard();
if ((preferredSdCard == sd::SdCard::SLOT_0) and (statusPair.first == sd::SdState::MOUNTED)) { if (preferredSdCard and (preferredSdCard == sd::SdCard::SLOT_0) and
(statusPair.first == sd::SdState::MOUNTED)) {
currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT;
} else if ((preferredSdCard == sd::SdCard::SLOT_1) and } else if ((preferredSdCard == sd::SdCard::SLOT_1) and
(statusPair.second == sd::SdState::MOUNTED)) { (statusPair.second == sd::SdState::MOUNTED)) {
@ -90,7 +91,7 @@ void FileSystemHandler::fileSystemCheckup() {
sif::warning << "Preferred SD card is " << sdString sif::warning << "Preferred SD card is " << sdString
<< " but does not appear to be mounted. Attempting fix.." << std::endl; << " but does not appear to be mounted. Attempting fix.." << std::endl;
// This function will appear to fix the inconsistent state // This function will appear to fix the inconsistent state
ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard); ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard.value());
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
// Oh no. // Oh no.
triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0); triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0);
@ -108,7 +109,11 @@ ReturnValue_t FileSystemHandler::initialize() {
<< std::endl; << std::endl;
} }
sdcMan = SdCardManager::instance(); sdcMan = SdCardManager::instance();
sd::SdCard preferredSdCard = sdcMan->getPreferredSdCard(); auto sdCard = sdcMan->getPreferredSdCard();
if (not sdCard) {
return returnvalue::FAILED;
}
sd::SdCard preferredSdCard = sdCard.value();
if (preferredSdCard == sd::SdCard::SLOT_0) { if (preferredSdCard == sd::SdCard::SLOT_0) {
currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT;
} else if (preferredSdCard == sd::SdCard::SLOT_1) { } else if (preferredSdCard == sd::SdCard::SLOT_1) {

View File

@ -300,11 +300,6 @@ ReturnValue_t SdCardManager::sanitizeState(SdStatePair* statusPair, sd::SdCard p
blocking = true; blocking = true;
resetNonBlockingState = true; resetNonBlockingState = true;
} }
if (prefSdCard == sd::SdCard::NONE) {
result = getPreferredSdCard();
if (result != returnvalue::OK) {
}
}
if (statusPair == nullptr) { if (statusPair == nullptr) {
sdStatusPtr = std::make_unique<SdStatePair>(); sdStatusPtr = std::make_unique<SdStatePair>();
statusPair = sdStatusPtr.get(); statusPair = sdStatusPtr.get();
@ -379,7 +374,7 @@ void SdCardManager::processSdStatusLine(std::pair<sd::SdState, sd::SdState>& act
idx++; idx++;
} }
sd::SdCard SdCardManager::getPreferredSdCard() const { std::optional<sd::SdCard> SdCardManager::getPreferredSdCard() const {
MutexGuard mg(mutex); MutexGuard mg(mutex);
auto res = mg.getLockResult(); auto res = mg.getLockResult();
if (res != returnvalue::OK) { if (res != returnvalue::OK) {
@ -412,13 +407,9 @@ ReturnValue_t SdCardManager::updateSdCardStateFile() {
return result; return result;
} }
std::string SdCardManager::getCurrentMountPrefix() const { const std::string& SdCardManager::getCurrentMountPrefix() const {
MutexGuard mg(mutex); MutexGuard mg(mutex);
if (sdInfo.active == sd::SdCard::SLOT_0) { return currentPrefix;
return SD_0_MOUNT_POINT;
} else {
return SD_1_MOUNT_POINT;
}
} }
SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) { SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations& currentOp) {
@ -552,6 +543,17 @@ ReturnValue_t SdCardManager::performFsck(sd::SdCard sdcard, bool printOutput, in
return result; return result;
} }
void SdCardManager::setActiveSdCard(sd::SdCard sdCard) { sdInfo.active = sdCard; } void SdCardManager::setActiveSdCard(sd::SdCard sdCard) {
MutexGuard mg(mutex);
sdInfo.active = sdCard;
if (sdInfo.active == sd::SdCard::SLOT_0) {
currentPrefix = SD_0_MOUNT_POINT;
} else {
currentPrefix = SD_1_MOUNT_POINT;
}
}
sd::SdCard SdCardManager::getActiveSdCard() const { return sdInfo.active; } std::optional<sd::SdCard> SdCardManager::getActiveSdCard() const {
MutexGuard mg(mutex);
return sdInfo.active;
}

View File

@ -92,7 +92,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
* @param sdCard * @param sdCard
* @return * @return
*/ */
sd::SdCard getPreferredSdCard() const override; std::optional<sd::SdCard> getPreferredSdCard() const override;
/** /**
* Switch on the specified SD card. * Switch on the specified SD card.
@ -159,7 +159,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
* mounted * mounted
* @return * @return
*/ */
sd::SdCard getActiveSdCard() const override; std::optional<sd::SdCard> getActiveSdCard() const override;
/** /**
* Unmount the specified SD card. This is recommended before switching it off. The SD card * Unmount the specified SD card. This is recommended before switching it off. The SD card
@ -188,7 +188,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
* @param prefSdCardPtr * @param prefSdCardPtr
* @return * @return
*/ */
std::string getCurrentMountPrefix() const override; const std::string& getCurrentMountPrefix() const override;
OpStatus checkCurrentOp(Operations& currentOp); OpStatus checkCurrentOp(Operations& currentOp);

View File

@ -215,4 +215,6 @@ Event ID (dec); Event ID (hex); Name; Severity; Description; File Path
13701;0x3585;REBOOT_SW;MEDIUM; Software reboot occurred. Can also be a systemd reboot. P1: Current Chip, P2: Current Copy;bsp_q7s/core/CoreController.h 13701;0x3585;REBOOT_SW;MEDIUM; Software reboot occurred. Can also be a systemd reboot. P1: Current Chip, P2: Current Copy;bsp_q7s/core/CoreController.h
13702;0x3586;REBOOT_MECHANISM_TRIGGERED;MEDIUM;The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots;bsp_q7s/core/CoreController.h 13702;0x3586;REBOOT_MECHANISM_TRIGGERED;MEDIUM;The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots;bsp_q7s/core/CoreController.h
13703;0x3587;REBOOT_HW;MEDIUM;;bsp_q7s/core/CoreController.h 13703;0x3587;REBOOT_HW;MEDIUM;;bsp_q7s/core/CoreController.h
13800;0x35e8;EXPERIMENT_TIMEDOUT;LOW;;mission/devices/devicedefinitions/ScexDefinitions.h 13800;0x35e8;MISSING_PACKET;LOW;;mission/devices/devicedefinitions/ScexDefinitions.h
13801;0x35e9;EXPERIMENT_TIMEDOUT;LOW;;mission/devices/devicedefinitions/ScexDefinitions.h
13802;0x35ea;MULTI_PACKET_COMMAND_DONE;INFO;;mission/devices/devicedefinitions/ScexDefinitions.h

1 Event ID (dec) Event ID (hex) Name Severity Description File Path
215 13701 0x3585 REBOOT_SW MEDIUM Software reboot occurred. Can also be a systemd reboot. P1: Current Chip, P2: Current Copy bsp_q7s/core/CoreController.h
216 13702 0x3586 REBOOT_MECHANISM_TRIGGERED MEDIUM The reboot mechanism was triggered. P1: First 16 bits: Last Chip, Last 16 bits: Last Copy, P2: Each byte is the respective reboot count for the slots bsp_q7s/core/CoreController.h
217 13703 0x3587 REBOOT_HW MEDIUM bsp_q7s/core/CoreController.h
218 13800 0x35e8 EXPERIMENT_TIMEDOUT MISSING_PACKET LOW mission/devices/devicedefinitions/ScexDefinitions.h
219 13801 0x35e9 EXPERIMENT_TIMEDOUT LOW mission/devices/devicedefinitions/ScexDefinitions.h
220 13802 0x35ea MULTI_PACKET_COMMAND_DONE INFO mission/devices/devicedefinitions/ScexDefinitions.h

View File

@ -1,6 +1,6 @@
Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path
0x0000;OK;System-wide code for ok.;0;HasReturnvaluesIF;fsfw/returnvalues/HasReturnvaluesIF.h 0x0000;OK;System-wide code for ok.;0;HasReturnvaluesIF;fsfw/returnvalues/returnvalue.h
0x0001;Failed;Unspecified system-wide code for failed.;1;HasReturnvaluesIF;fsfw/returnvalues/HasReturnvaluesIF.h 0x0001;Failed;Unspecified system-wide code for failed.;1;HasReturnvaluesIF;fsfw/returnvalues/returnvalue.h
0x63a0;NVMB_KeyNotExists;Specified key does not exist in json file;160;NVM_PARAM_BASE;mission/memory/NVMParameterBase.h 0x63a0;NVMB_KeyNotExists;Specified key does not exist in json file;160;NVM_PARAM_BASE;mission/memory/NVMParameterBase.h
0x58a0;SUSS_ErrorUnlockMutex;;160;SUS_HANDLER;mission/devices/SusHandler.h 0x58a0;SUSS_ErrorUnlockMutex;;160;SUS_HANDLER;mission/devices/SusHandler.h
0x58a1;SUSS_ErrorLockMutex;;161;SUS_HANDLER;mission/devices/SusHandler.h 0x58a1;SUSS_ErrorLockMutex;;161;SUS_HANDLER;mission/devices/SusHandler.h
@ -361,8 +361,9 @@ Full ID (hex); Name; Description; Unique ID; Subsytem Name; File Path
0x2cd2;CCS_TooShortBlockedPacket;;210;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h 0x2cd2;CCS_TooShortBlockedPacket;;210;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h
0x2cd3;CCS_TooShortMapExtraction;;211;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h 0x2cd3;CCS_TooShortMapExtraction;;211;CCSDS_HANDLER_IF;fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h
0x4201;PUS11_InvalidTypeTimeWindow;;1;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4201;PUS11_InvalidTypeTimeWindow;;1;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h
0x4202;PUS11_TimeshiftingNotPossible;;2;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4202;PUS11_InvalidTimeWindow;;2;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h
0x4203;PUS11_InvalidRelativeTime;;3;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h 0x4203;PUS11_TimeshiftingNotPossible;;3;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h
0x4204;PUS11_InvalidRelativeTime;;4;PUS_SERVICE_11;fsfw/src/fsfw/pus/Service11TelecommandScheduling.h
0x3401;DC_NoReplyReceived;;1;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h 0x3401;DC_NoReplyReceived;;1;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h
0x3402;DC_ProtocolError;;2;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h 0x3402;DC_ProtocolError;;2;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h
0x3403;DC_Nullpointer;;3;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h 0x3403;DC_Nullpointer;;3;DEVICE_COMMUNICATION_IF;fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h

1 Full ID (hex) Name Description Unique ID Subsytem Name File Path
2 0x0000 OK System-wide code for ok. 0 HasReturnvaluesIF fsfw/returnvalues/HasReturnvaluesIF.h fsfw/returnvalues/returnvalue.h
3 0x0001 Failed Unspecified system-wide code for failed. 1 HasReturnvaluesIF fsfw/returnvalues/HasReturnvaluesIF.h fsfw/returnvalues/returnvalue.h
4 0x63a0 NVMB_KeyNotExists Specified key does not exist in json file 160 NVM_PARAM_BASE mission/memory/NVMParameterBase.h
5 0x58a0 SUSS_ErrorUnlockMutex 160 SUS_HANDLER mission/devices/SusHandler.h
6 0x58a1 SUSS_ErrorLockMutex 161 SUS_HANDLER mission/devices/SusHandler.h
361 0x2cd2 CCS_TooShortBlockedPacket 210 CCSDS_HANDLER_IF fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h
362 0x2cd3 CCS_TooShortMapExtraction 211 CCSDS_HANDLER_IF fsfw/src/fsfw/datalinklayer/CCSDSReturnValuesIF.h
363 0x4201 PUS11_InvalidTypeTimeWindow 1 PUS_SERVICE_11 fsfw/src/fsfw/pus/Service11TelecommandScheduling.h
364 0x4202 PUS11_TimeshiftingNotPossible PUS11_InvalidTimeWindow 2 PUS_SERVICE_11 fsfw/src/fsfw/pus/Service11TelecommandScheduling.h
365 0x4203 PUS11_InvalidRelativeTime PUS11_TimeshiftingNotPossible 3 PUS_SERVICE_11 fsfw/src/fsfw/pus/Service11TelecommandScheduling.h
366 0x4204 PUS11_InvalidRelativeTime 4 PUS_SERVICE_11 fsfw/src/fsfw/pus/Service11TelecommandScheduling.h
367 0x3401 DC_NoReplyReceived 1 DEVICE_COMMUNICATION_IF fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h
368 0x3402 DC_ProtocolError 2 DEVICE_COMMUNICATION_IF fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h
369 0x3403 DC_Nullpointer 3 DEVICE_COMMUNICATION_IF fsfw/src/fsfw/devicehandlers/DeviceCommunicationIF.h

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 217 translations. * @brief Auto-generated event translation file. Contains 219 translations.
* @details * @details
* Generated on: 2022-08-24 16:53:50 * Generated on: 2022-08-31 16:07:07
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -217,7 +217,9 @@ const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE";
const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_SW_STRING = "REBOOT_SW";
const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED";
const char *REBOOT_HW_STRING = "REBOOT_HW"; const char *REBOOT_HW_STRING = "REBOOT_HW";
const char *MISSING_PACKET_STRING = "MISSING_PACKET";
const char *EXPERIMENT_TIMEDOUT_STRING = "EXPERIMENT_TIMEDOUT"; const char *EXPERIMENT_TIMEDOUT_STRING = "EXPERIMENT_TIMEDOUT";
const char *MULTI_PACKET_COMMAND_DONE_STRING = "MULTI_PACKET_COMMAND_DONE";
const char *translateEvents(Event event) { const char *translateEvents(Event event) {
switch ((event & 0xFFFF)) { switch ((event & 0xFFFF)) {
@ -646,7 +648,11 @@ const char *translateEvents(Event event) {
case (13703): case (13703):
return REBOOT_HW_STRING; return REBOOT_HW_STRING;
case (13800): case (13800):
return MISSING_PACKET_STRING;
case (13801):
return EXPERIMENT_TIMEDOUT_STRING; return EXPERIMENT_TIMEDOUT_STRING;
case (13802):
return MULTI_PACKET_COMMAND_DONE_STRING;
default: default:
return "UNKNOWN_EVENT"; return "UNKNOWN_EVENT";
} }

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 135 translations. * Contains 135 translations.
* Generated on: 2022-08-24 16:53:50 * Generated on: 2022-08-31 16:07:07
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -6,4 +6,4 @@ add_subdirectory(devices)
add_subdirectory(fsfwconfig) add_subdirectory(fsfwconfig)
add_subdirectory(obc) add_subdirectory(obc)
target_sources(${OBSW_NAME} PUBLIC ObjectFactory.cpp) target_sources(${OBSW_NAME} PUBLIC ObjectFactory.cpp InitMission.cpp)

47
linux/InitMission.cpp Normal file
View File

@ -0,0 +1,47 @@
#include "InitMission.h"
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <fsfw/tasks/PeriodicTaskIF.h>
#include <mission/utility/InitMission.h>
#include "OBSWConfig.h"
#include "ObjectFactory.h"
void scheduling::schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler,
PeriodicTaskIF*& scexReaderTask) {
using namespace initmission;
ReturnValue_t result = returnvalue::OK;
#if OBSW_PRINT_MISSED_DEADLINES == 1
void (*missedDeadlineFunc)(void) = TaskFactory::printMissedDeadline;
#else
void (*missedDeadlineFunc)(void) = nullptr;
#endif
scexDevHandler = factory.createPeriodicTask(
"SCEX_DEV", 35, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc);
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION);
if (result != returnvalue::OK) {
printAddObjectError("SCEX_DEV", objects::SCEX);
}
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE);
if (result != returnvalue::OK) {
printAddObjectError("SCEX_DEV", objects::SCEX);
}
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE);
if (result != returnvalue::OK) {
printAddObjectError("SCEX_DEV", objects::SCEX);
}
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ);
if (result != returnvalue::OK) {
printAddObjectError("SCEX_DEV", objects::SCEX);
}
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ);
result = returnvalue::OK;
scexReaderTask = factory.createPeriodicTask(
"SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = scexReaderTask->addComponent(objects::SCEX_UART_READER);
if (result != returnvalue::OK) {
printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER);
}
}

7
linux/InitMission.h Normal file
View File

@ -0,0 +1,7 @@
#pragma once
#include <fsfw/tasks/TaskFactory.h>
namespace scheduling {
void schedulingScex(TaskFactory& factory, PeriodicTaskIF*& scexDevHandler,
PeriodicTaskIF*& scexReaderTask);
}

View File

@ -323,15 +323,21 @@ void ObjectFactory::createRtdComponents(std::string spiDev, GpioIF* gpioComIF,
#endif // OBSW_ADD_RTD_DEVICES == 1 #endif // OBSW_ADD_RTD_DEVICES == 1
} }
void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher) { void ObjectFactory::createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher,
SdCardMountedIF& mountedIF, bool onImmediately,
std::optional<power::Switch_t> switchId) {
// objekte anlegen // objekte anlegen
SdCardMountedIF* sdcMan = nullptr;
auto* cookie = new UartCookie(objects::SCEX, uartDev, uart::SCEX_BAUD, 4096); auto* cookie = new UartCookie(objects::SCEX, uartDev, uart::SCEX_BAUD, 4096);
auto scexUartReader = new ScexUartReader(objects::SCEX_UART_READER); auto scexUartReader = new ScexUartReader(objects::SCEX_UART_READER);
auto scexHandler = new ScexDeviceHandler(objects::SCEX, *scexUartReader, cookie, sdcMan); auto scexHandler = new ScexDeviceHandler(objects::SCEX, *scexUartReader, cookie, mountedIF);
if (onImmediately) {
scexHandler->setStartUpImmediately(); scexHandler->setStartUpImmediately();
} }
if (switchId) {
scexHandler->setPowerSwitcher(*pwrSwitcher, switchId.value());
}
}
void ObjectFactory::createThermalController() { void ObjectFactory::createThermalController() {
new ThermalController(objects::THERMAL_CONTROLLER, objects::NO_OBJECT); new ThermalController(objects::THERMAL_CONTROLLER, objects::NO_OBJECT);

View File

@ -1,8 +1,11 @@
#pragma once #pragma once
#include <fsfw/power/definitions.h>
#include <fsfw/returnvalues/returnvalue.h> #include <fsfw/returnvalues/returnvalue.h>
#include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h> #include <fsfw_hal/linux/gpio/LinuxLibgpioIF.h>
#include <mission/memory/SdCardMountedIF.h>
#include <optional>
#include <string> #include <string>
class GpioIF; class GpioIF;
@ -16,7 +19,9 @@ void createSunSensorComponents(GpioIF* gpioComIF, SpiComIF* spiComIF, PowerSwitc
void createRtdComponents(std::string spiDev, GpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher, void createRtdComponents(std::string spiDev, GpioIF* gpioComIF, PowerSwitchIF* pwrSwitcher,
SpiComIF* comIF); SpiComIF* comIF);
void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher); void createScexComponents(std::string uartDev, PowerSwitchIF* pwrSwitcher,
SdCardMountedIF& mountedIF, bool onImmediately,
std::optional<power::Switch_t> switchId);
void gpioChecker(ReturnValue_t result, std::string output); void gpioChecker(ReturnValue_t result, std::string output);

View File

@ -27,12 +27,11 @@
using namespace returnvalue; using namespace returnvalue;
UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader) UartTestClass::UartTestClass(object_id_t objectId) : TestTask(objectId) {
: TestTask(objectId), reader(reader) {
mode = TestModes::SCEX; mode = TestModes::SCEX;
scexMode = ScexModes::READER_TASK; scexMode = ScexModes::SIMPLE;
// No one-cell and all-cell support implemented yet // No one-cell and all-cell support implemented yet
currCmd = scex::Cmds::FRAM; currCmd = scex::Cmds::PING;
if (scexMode == ScexModes::SIMPLE) { if (scexMode == ScexModes::SIMPLE) {
auto encodingBuf = new std::array<uint8_t, 4096>; auto encodingBuf = new std::array<uint8_t, 4096>;
DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()}; DleParser::BufPair encodingBufPair{encodingBuf->data(), encodingBuf->size()};
@ -40,6 +39,8 @@ UartTestClass::UartTestClass(object_id_t objectId, ScexUartReader* reader)
DleParser::BufPair decodingBufPair{decodedBuf->data(), decodedBuf->size()}; DleParser::BufPair decodingBufPair{decodedBuf->data(), decodedBuf->size()};
dleParser = new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair, dleParser = new ScexDleParser(*(new SimpleRingBuffer(4096, true)), dleEncoder, encodingBufPair,
decodingBufPair, &foundDlePacketHandler, this); decodingBufPair, &foundDlePacketHandler, this);
} else {
reader = new ScexUartReader(objects::SCEX_UART_READER);
} }
} }
@ -150,13 +151,13 @@ void UartTestClass::gpsPeriodic() {
} }
void UartTestClass::scexInit() { void UartTestClass::scexInit() {
if (scexMode == ScexModes::SIMPLE) {
scexSimpleInit();
} else {
if (reader == nullptr) { if (reader == nullptr) {
sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl; sif::warning << "UartTestClass::scexInit: Reader invalid" << std::endl;
return; return;
} }
if (scexMode == ScexModes::SIMPLE) {
scexSimpleInit();
} else {
#if defined(RASPBERRY_PI) #if defined(RASPBERRY_PI)
std::string devname = "/dev/serial0"; std::string devname = "/dev/serial0";
#else #else
@ -176,13 +177,13 @@ void UartTestClass::scexInit() {
void UartTestClass::scexPeriodic() { void UartTestClass::scexPeriodic() {
using namespace std; using namespace std;
using namespace scex; using namespace scex;
if (reader == nullptr) {
return;
}
if (scexMode == ScexModes::SIMPLE) { if (scexMode == ScexModes::SIMPLE) {
scexSimplePeriodic(); scexSimplePeriodic();
} else { } else {
if (reader == nullptr) {
return;
}
if (not cmdSent) { if (not cmdSent) {
size_t len = 0; size_t len = 0;
prepareScexCmd(currCmd, false, cmdBuf.data(), &len); prepareScexCmd(currCmd, false, cmdBuf.data(), &len);
@ -375,6 +376,7 @@ int UartTestClass::prepareScexCmd(scex::Cmds cmd, bool tempCheck, uint8_t* cmdBu
uint16_t crc = CRC::crc16ccitt(cmdBuf, 5); uint16_t crc = CRC::crc16ccitt(cmdBuf, 5);
cmdBuf[5] = (crc >> 8) & 0xff; cmdBuf[5] = (crc >> 8) & 0xff;
cmdBuf[6] = crc & 0xff; cmdBuf[6] = crc & 0xff;
*len = 7;
return 0; return 0;
} }

View File

@ -19,7 +19,7 @@ class ScexDleParser;
class UartTestClass : public TestTask { class UartTestClass : public TestTask {
public: public:
UartTestClass(object_id_t objectId, ScexUartReader* reader); UartTestClass(object_id_t objectId);
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
ReturnValue_t performOneShotAction() override; ReturnValue_t performOneShotAction() override;

View File

@ -34,7 +34,6 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
lock->unlockMutex(); lock->unlockMutex();
while (true) { while (true) {
semaphore->acquire(); semaphore->acquire();
sif::info << "task was started" << std::endl;
int bytesRead = 0; int bytesRead = 0;
while (true) { while (true) {
bytesRead = read(serialPort, reinterpret_cast<void *>(recBuf.data()), bytesRead = read(serialPort, reinterpret_cast<void *>(recBuf.data()),
@ -42,7 +41,6 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
if (bytesRead == 0) { if (bytesRead == 0) {
MutexGuard mg(lock); MutexGuard mg(lock);
if (state == States::FINISH) { if (state == States::FINISH) {
sif::debug << "finish detected" << std::endl;
state = States::IDLE; state = States::IDLE;
break; break;
} }
@ -66,8 +64,6 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
} }
} }
}; };
// task block comes here
sif::info << "task was stopped" << std::endl;
} }
return OK; return OK;
} }
@ -135,7 +131,6 @@ ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendD
sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl; sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl;
return FAILED; return FAILED;
} }
arrayprinter::print(cmdbuf.data(), encodedLen);
size_t bytesWritten = write(serialPort, cmdbuf.data(), encodedLen); size_t bytesWritten = write(serialPort, cmdbuf.data(), encodedLen);
if (bytesWritten != encodedLen) { if (bytesWritten != encodedLen) {
sif::warning << "ScexUartReader::sendMessage: Sending ping command to solar experiment failed" sif::warning << "ScexUartReader::sendMessage: Sending ping command to solar experiment failed"

View File

@ -1,7 +1,7 @@
/** /**
* @brief Auto-generated event translation file. Contains 217 translations. * @brief Auto-generated event translation file. Contains 219 translations.
* @details * @details
* Generated on: 2022-08-24 16:53:50 * Generated on: 2022-08-31 16:07:07
*/ */
#include "translateEvents.h" #include "translateEvents.h"
@ -217,7 +217,9 @@ const char *ALLOC_FAILURE_STRING = "ALLOC_FAILURE";
const char *REBOOT_SW_STRING = "REBOOT_SW"; const char *REBOOT_SW_STRING = "REBOOT_SW";
const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED"; const char *REBOOT_MECHANISM_TRIGGERED_STRING = "REBOOT_MECHANISM_TRIGGERED";
const char *REBOOT_HW_STRING = "REBOOT_HW"; const char *REBOOT_HW_STRING = "REBOOT_HW";
const char *MISSING_PACKET_STRING = "MISSING_PACKET";
const char *EXPERIMENT_TIMEDOUT_STRING = "EXPERIMENT_TIMEDOUT"; const char *EXPERIMENT_TIMEDOUT_STRING = "EXPERIMENT_TIMEDOUT";
const char *MULTI_PACKET_COMMAND_DONE_STRING = "MULTI_PACKET_COMMAND_DONE";
const char *translateEvents(Event event) { const char *translateEvents(Event event) {
switch ((event & 0xFFFF)) { switch ((event & 0xFFFF)) {
@ -646,7 +648,11 @@ const char *translateEvents(Event event) {
case (13703): case (13703):
return REBOOT_HW_STRING; return REBOOT_HW_STRING;
case (13800): case (13800):
return MISSING_PACKET_STRING;
case (13801):
return EXPERIMENT_TIMEDOUT_STRING; return EXPERIMENT_TIMEDOUT_STRING;
case (13802):
return MULTI_PACKET_COMMAND_DONE_STRING;
default: default:
return "UNKNOWN_EVENT"; return "UNKNOWN_EVENT";
} }

View File

@ -2,7 +2,7 @@
* @brief Auto-generated object translation file. * @brief Auto-generated object translation file.
* @details * @details
* Contains 135 translations. * Contains 135 translations.
* Generated on: 2022-08-24 16:53:50 * Generated on: 2022-08-31 16:07:07
*/ */
#include "translateObjects.h" #include "translateObjects.h"

View File

@ -102,8 +102,8 @@ ReturnValue_t GomspaceDeviceHandler::buildCommandFromCommand(DeviceCommandId_t d
if (getDevType(devType) != returnvalue::OK) { if (getDevType(devType) != returnvalue::OK) {
return returnvalue::FAILED; return returnvalue::FAILED;
} }
result = generateRequestFullCfgTableCmd(devType, tableCfg.cfgTableSize, result =
deviceCommand, cspCookie); generateRequestFullCfgTableCmd(devType, tableCfg.cfgTableSize, deviceCommand, cspCookie);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }

View File

@ -93,9 +93,8 @@ class GomspaceDeviceHandler : public DeviceHandlerBase {
* @param cspCookie * @param cspCookie
* @return * @return
*/ */
ReturnValue_t generateRequestFullCfgTableCmd(GOMSPACE::DeviceType devType, ReturnValue_t generateRequestFullCfgTableCmd(GOMSPACE::DeviceType devType, uint16_t tableSize,
uint16_t tableSize, DeviceCommandId_t id, DeviceCommandId_t id, CspCookie *cspCookie);
CspCookie *cspCookie);
ReturnValue_t getDevType(GOMSPACE::DeviceType &type) const; ReturnValue_t getDevType(GOMSPACE::DeviceType &type) const;
/** /**
* This command handles printing the HK table to the console. This is useful for debugging * This command handles printing the HK table to the console. This is useful for debugging

View File

@ -491,8 +491,8 @@ void PayloadPcduHandler::checkAdcValues() {
void PayloadPcduHandler::checkJsonFileInit() { void PayloadPcduHandler::checkJsonFileInit() {
if (not jsonFileInitComplete) { if (not jsonFileInitComplete) {
sd::SdCard activeSd = sdcMan->getActiveSdCard(); auto activeSd = sdcMan->getActiveSdCard();
if (sdcMan->isSdCardMounted(activeSd)) { if (activeSd and sdcMan->isSdCardMounted(activeSd.value())) {
params.initialize(sdcMan->getCurrentMountPrefix()); params.initialize(sdcMan->getCurrentMountPrefix());
jsonFileInitComplete = true; jsonFileInitComplete = true;
} }

View File

@ -4,6 +4,7 @@
#include <mission/memory/SdCardMountedIF.h> #include <mission/memory/SdCardMountedIF.h>
#include <algorithm> #include <algorithm>
#include <ctime>
#include <iostream> #include <iostream>
#include <random> #include <random>
@ -14,25 +15,18 @@ using std::ofstream;
using namespace returnvalue; using namespace returnvalue;
ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie, ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie,
SdCardMountedIF* sdcMan) SdCardMountedIF& sdcMan)
: DeviceHandlerBase(objectId, reader.getObjectId(), cookie), sdcMan(sdcMan), reader(reader) {} : DeviceHandlerBase(objectId, reader.getObjectId(), cookie), sdcMan(sdcMan), reader(reader) {}
ScexDeviceHandler::~ScexDeviceHandler() {} ScexDeviceHandler::~ScexDeviceHandler() {}
void ScexDeviceHandler::doStartUp() { void ScexDeviceHandler::doStartUp() { setMode(MODE_ON); }
// mode on
setMode(MODE_ON);
}
void ScexDeviceHandler::doShutDown() { setMode(_MODE_POWER_DOWN); } void ScexDeviceHandler::doShutDown() { setMode(_MODE_POWER_DOWN); }
ReturnValue_t ScexDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t ScexDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { return OK; }
return OK;
}
ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { return OK; }
return OK;
}
ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand, ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t* commandData, const uint8_t* commandData,
@ -88,8 +82,17 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic
finishCountdown.setTimeout(LONG_CD); finishCountdown.setTimeout(LONG_CD);
// countdown starten // countdown starten
finishCountdown.resetTimer(); finishCountdown.resetTimer();
if (debugMode) {
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
sif::info << "ScexDeviceHandler::buildCommandFromCommand: RemainingMillis: "
<< remainingMillis << std::endl;
}
prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
{commandData + 1, commandDataLen - 1}, tempCheck); {commandData + 1, commandDataLen - 1}, tempCheck);
updatePeriodicReply(true, deviceCommand);
actionHelper.finish(true, getCommanderQueueId(deviceCommand), deviceCommand, OK);
break; break;
} }
case (ONE_CELL): { case (ONE_CELL): {
@ -98,6 +101,8 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic
finishCountdown.resetTimer(); finishCountdown.resetTimer();
prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
{commandData + 1, commandDataLen - 1}, tempCheck); {commandData + 1, commandDataLen - 1}, tempCheck);
updatePeriodicReply(true, deviceCommand);
actionHelper.finish(true, getCommanderQueueId(deviceCommand), deviceCommand, OK);
break; break;
} }
case (ALL_CELLS_CMD): { case (ALL_CELLS_CMD): {
@ -106,6 +111,8 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic
finishCountdown.resetTimer(); finishCountdown.resetTimer();
prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen, prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
{commandData + 1, commandDataLen - 1}, tempCheck); {commandData + 1, commandDataLen - 1}, tempCheck);
actionHelper.finish(true, getCommanderQueueId(deviceCommand), deviceCommand, OK);
updatePeriodicReply(true, deviceCommand);
break; break;
} }
default: { default: {
@ -123,12 +130,12 @@ void ScexDeviceHandler::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(scex::Cmds::TEMP_CMD, 3); insertInCommandAndReplyMap(scex::Cmds::TEMP_CMD, 3);
insertInCommandAndReplyMap(scex::Cmds::EXP_STATUS_CMD, 3); insertInCommandAndReplyMap(scex::Cmds::EXP_STATUS_CMD, 3);
insertInCommandAndReplyMap(scex::Cmds::ALL_CELLS_CMD, 0, nullptr, 0, false, false, insertInCommandAndReplyMap(scex::Cmds::ALL_CELLS_CMD, 0, nullptr, 0, true, false,
scex::Cmds::ALL_CELLS_CMD, &finishCountdown); scex::Cmds::ALL_CELLS_CMD, &finishCountdown);
insertInCommandAndReplyMap(scex::Cmds::ONE_CELL, 0, nullptr, 0, false, false, insertInCommandAndReplyMap(scex::Cmds::ONE_CELL, 0, nullptr, 0, true, false, scex::Cmds::ONE_CELL,
scex::Cmds::ONE_CELL, &finishCountdown); &finishCountdown);
insertInCommandAndReplyMap(scex::Cmds::FRAM, 0, nullptr, 0, false, false, insertInCommandAndReplyMap(scex::Cmds::FRAM, 0, nullptr, 0, true, false, scex::Cmds::FRAM,
scex::Cmds::FRAM, &finishCountdown); &finishCountdown);
insertInReplyMap(scex::Cmds::ERROR_REPLY, 3); insertInReplyMap(scex::Cmds::ERROR_REPLY, 3);
} }
@ -140,58 +147,93 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai
if (result == ScexHelper::INVALID_CRC) { if (result == ScexHelper::INVALID_CRC) {
sif::warning << "ScexDeviceHandler::scanForReply: CRC invalid" << std::endl; sif::warning << "ScexDeviceHandler::scanForReply: CRC invalid" << std::endl;
*foundLen = remainingSize;
} else {
result = handleValidReply(remainingSize, foundId, foundLen);
}
return result; return result;
} }
*foundId = helper.getCmd();
*foundLen = remainingSize;
return OK; ReturnValue_t ScexDeviceHandler::handleValidReply(size_t remSize, DeviceCommandId_t* foundId,
size_t* foundLen) {
using namespace scex;
ReturnValue_t result = OK;
switch (helper.getCmd()) {
case (FRAM): {
if (debugMode) {
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
sif::info << "ScexDeviceHandler::handleValidReply: RemMillis: " << remainingMillis
<< std::endl;
}
result = APERIODIC_REPLY;
break;
}
case (ONE_CELL): {
result = APERIODIC_REPLY;
break;
}
case (ALL_CELLS_CMD): {
result = APERIODIC_REPLY;
break;
}
default: {
break;
}
}
*foundId = helper.getCmd();
*foundLen = remSize;
return result;
} }
ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) { ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
// cmd auswertung (in file reinschreiben)
using namespace scex; using namespace scex;
ReturnValue_t status = OK; ReturnValue_t status = OK;
auto oneFileHandler = [&](std::string cmdName) { auto oneFileHandler = [&](std::string cmdName) {
fileId = random_string(6); fileId = date_time_string();
std::ostringstream oss("/tmp/scex-", std::ostringstream::ate); std::ostringstream oss;
oss << cmdName << fileId << ".bin"; auto prefix = sdcMan.getCurrentMountPrefix();
oss << prefix << "/scex-" << cmdName << fileId << ".bin";
fileName = oss.str(); fileName = oss.str();
std::cout << fileName << std::endl; sif::info << "ScexDeviceHandler::interpretDeviceReply: FileName: " << fileName << std::endl;
ofstream out(fileName, ofstream::binary); ofstream out(fileName, ofstream::binary);
if (out.bad()) { if (out.bad()) {
sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName
<< std::endl; << std::endl;
return FAILED; return FAILED;
} }
if (debugMode) {
out << helper; out << helper;
}
return OK; return OK;
}; };
auto multiFileHandler = [&](std::string cmdName) { auto multiFileHandler = [&](std::string cmdName) {
if ((helper.getPacketCounter() == 1) or (not fileNameSet)) { if ((helper.getPacketCounter() == 1) or (not fileNameSet)) {
fileId = date_time_string();
fileId = random_string(6); std::ostringstream oss;
std::ostringstream oss("/tmp/scex-", std::ostringstream::ate); auto prefix = sdcMan.getCurrentMountPrefix();
oss << cmdName << fileId << ".bin"; oss << prefix << "/scex-" << cmdName << fileId << ".bin";
fileName = oss.str(); fileName = oss.str();
sif::info << "ScexDeviceHandler::interpretDeviceReply: FileName: " << fileName
<< std::endl; // TODO remove
fileNameSet = true; fileNameSet = true;
ofstream out(fileName, ofstream::binary); ofstream out(fileName, ofstream::binary);
if (out.bad()) { if (out.bad()) {
sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName sif::error << "ScexDeviceHandler::handleValidReply: Could not open file " << fileName
<< std::endl; << std::endl;
return FAILED; return FAILED;
} }
out << helper;
} else { } else {
ofstream out(fileName, ofstream out(fileName,
ofstream::binary | ofstream::app); // append ofstream::binary | ofstream::app); // append
if (debugMode) { if (out.bad()) {
sif::error << "ScexDeviceHandler::handleValidReply: Could not open file " << fileName
<< std::endl;
return FAILED;
}
out << helper; out << helper;
} }
}
return OK; return OK;
}; };
switch (id) { switch (id) {
@ -220,7 +262,7 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
break; break;
} }
case (ALL_CELLS_CMD): { case (ALL_CELLS_CMD): {
status = multiFileHandler("all_cell_"); status = multiFileHandler("multi_cell_");
break; break;
} }
default: default:
@ -231,29 +273,40 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
reader.finish(); reader.finish();
commandActive = false; commandActive = false;
if (id != PING) { if (id != PING) {
sif::info << "Reader is finished" << std::endl;
fileNameSet = false; fileNameSet = false;
} }
if (id == FRAM or id == ALL_CELLS_CMD or id == ONE_CELL) {
triggerEvent(MULTI_PACKET_COMMAND_DONE, id);
updatePeriodicReply(false, id);
}
}
if (debugMode) {
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
sif::info << __FILE__ << __func__ << "(" << __LINE__ << ") RemMillis: " << remainingMillis
<< std::endl;
} }
return status; return status;
} }
void ScexDeviceHandler::performOperationHook() { void ScexDeviceHandler::performOperationHook() {
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
if (commandActive and finishCountdown.hasTimedOut()) { if (commandActive and finishCountdown.hasTimedOut()) {
triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0); triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0);
reader.finish(); reader.finish();
sif::warning << "ScexDeviceHandler::performOperationHook: Reader timeout" << std::endl; sif::warning << "ScexDeviceHandler::scanForReply: Reader timeout; RemMillis: "
<< remainingMillis << std::endl;
fileNameSet = false; fileNameSet = false;
commandActive = false; commandActive = false;
} }
} }
uint32_t ScexDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { uint32_t ScexDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return OK; }
return OK;
}
ReturnValue_t ScexDeviceHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) { ReturnValue_t ScexDeviceHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) {
if (switchId) {
*numberOfSwitches = 1;
*switches = &switchId.value();
}
return OK; return OK;
} }
@ -262,23 +315,38 @@ ReturnValue_t ScexDeviceHandler::initializeLocalDataPool(localpool::DataPool& lo
return OK; return OK;
} }
std::string ScexDeviceHandler::random_string(std::string::size_type length) { std::string ScexDeviceHandler::date_time_string() {
static auto& chrs = using namespace std;
"0123456789" string date_time;
"abcdefghijklmnopqrstuvwxyz" Clock::TimeOfDay_t tod;
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"; Clock::getDateAndTime(&tod);
ostringstream oss(std::ostringstream::ate);
thread_local static std::mt19937 rg{std::random_device{}()}; if (tod.hour < 10) {
thread_local static std::uniform_int_distribution<std::string::size_type> pick(0, oss << tod.year << tod.month << tod.day << "_0" << tod.hour;
sizeof(chrs) - 2); } else {
oss << tod.year << tod.month << tod.day << "_" << tod.hour;
}
if (tod.minute < 10) {
oss << 0 << tod.minute;
std::string s; } else {
oss << tod.minute;
}
if (tod.second < 10) {
oss << 0 << tod.second;
} else {
oss << tod.second;
}
s.reserve(length); date_time = oss.str();
while (length--) s += chrs[pick(rg)]; return date_time;
return s;
} }
void ScexDeviceHandler::modeChanged() {} void ScexDeviceHandler::modeChanged() {}
void ScexDeviceHandler::setPowerSwitcher(PowerSwitchIF& powerSwitcher, power::Switch_t switchId) {
DeviceHandlerBase::setPowerSwitcher(&powerSwitcher);
this->switchId = switchId;
}

View File

@ -5,12 +5,17 @@
#include <linux/devices/ScexHelper.h> #include <linux/devices/ScexHelper.h>
#include <linux/devices/ScexUartReader.h> #include <linux/devices/ScexUartReader.h>
#include <optional>
#include "commonSubsystemIds.h"
class SdCardMountedIF; class SdCardMountedIF;
class ScexDeviceHandler : public DeviceHandlerBase { class ScexDeviceHandler : public DeviceHandlerBase {
public: public:
ScexDeviceHandler(object_id_t objectId, ScexUartReader &reader, CookieIF *cookie, ScexDeviceHandler(object_id_t objectId, ScexUartReader &reader, CookieIF *cookie,
SdCardMountedIF *sdcMan); SdCardMountedIF &sdcMan);
void setPowerSwitcher(PowerSwitchIF &powerSwitcher, power::Switch_t switchId);
virtual ~ScexDeviceHandler(); virtual ~ScexDeviceHandler();
private: private:
@ -18,17 +23,18 @@ class ScexDeviceHandler : public DeviceHandlerBase {
static constexpr uint32_t SHORT_CD = 7000; static constexpr uint32_t SHORT_CD = 7000;
std::array<uint8_t, 64> cmdBuf = {}; std::array<uint8_t, 64> cmdBuf = {};
std::optional<power::Switch_t> switchId;
std::string fileId = ""; std::string fileId = "";
std::string fileName = ""; std::string fileName = "";
bool fileNameSet = false; bool fileNameSet = false;
bool commandActive = false; bool commandActive = false;
bool debugMode = true; bool debugMode = false;
scex::Cmds currCmd = scex::Cmds::PING; scex::Cmds currCmd = scex::Cmds::PING;
SdCardMountedIF *sdcMan = nullptr; SdCardMountedIF &sdcMan;
Countdown finishCountdown = Countdown(LONG_CD); Countdown finishCountdown = Countdown(LONG_CD);
std::string random_string(std::string::size_type length); std::string date_time_string();
// DeviceHandlerBase private function implementation // DeviceHandlerBase private function implementation
void doStartUp() override; void doStartUp() override;
@ -45,6 +51,7 @@ class ScexDeviceHandler : public DeviceHandlerBase {
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
size_t *foundLen) override; size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
ReturnValue_t handleValidReply(size_t remSize, DeviceCommandId_t *foundId, size_t *foundLen);
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override;

View File

@ -14,8 +14,10 @@ namespace scex {
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SCEX_HANDLER; static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SCEX_HANDLER;
static constexpr Event MISSING_PACKET = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); static constexpr Event MISSING_PACKET = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW);
static constexpr Event EXPERIMENT_TIMEDOUT = event::makeEvent(SUBSYSTEM_ID, 1, severity::LOW);
static constexpr Event EXPERIMENT_TIMEDOUT = event::makeEvent(SUBSYSTEM_ID, 0, severity::LOW); //! FRAM, One Cell or All cells command finished. P1: Command ID
static constexpr Event MULTI_PACKET_COMMAND_DONE =
event::makeEvent(SUBSYSTEM_ID, 2, severity::INFO);
enum Cmds : DeviceCommandId_t { enum Cmds : DeviceCommandId_t {
PING = 0b00111, PING = 0b00111,

View File

@ -1,6 +1,7 @@
#ifndef MISSION_MEMORY_SDCARDMOUNTERIF_H_ #ifndef MISSION_MEMORY_SDCARDMOUNTERIF_H_
#define MISSION_MEMORY_SDCARDMOUNTERIF_H_ #define MISSION_MEMORY_SDCARDMOUNTERIF_H_
#include <optional>
#include <string> #include <string>
#include "definitions.h" #include "definitions.h"
@ -8,11 +9,11 @@
class SdCardMountedIF { class SdCardMountedIF {
public: public:
virtual ~SdCardMountedIF(){}; virtual ~SdCardMountedIF(){};
virtual std::string getCurrentMountPrefix() const = 0; virtual const std::string& getCurrentMountPrefix() const = 0;
virtual bool isSdCardMounted(sd::SdCard sdCard) = 0; virtual bool isSdCardMounted(sd::SdCard sdCard) = 0;
virtual sd::SdCard getPreferredSdCard() const = 0; virtual std::optional<sd::SdCard> getPreferredSdCard() const = 0;
virtual void setActiveSdCard(sd::SdCard sdCard) = 0; virtual void setActiveSdCard(sd::SdCard sdCard) = 0;
virtual sd::SdCard getActiveSdCard() const = 0; virtual std::optional<sd::SdCard> getActiveSdCard() const = 0;
private: private:
}; };

View File

@ -1,12 +1,11 @@
#ifndef MISSION_UTILITY_INITMISSION_H_ #pragma once
#define MISSION_UTILITY_INITMISSION_H_
#include <fsfw/objectmanager/SystemObjectIF.h> #include <fsfw/objectmanager/SystemObjectIF.h>
#include <fsfw/serviceinterface/ServiceInterface.h> #include <fsfw/serviceinterface/ServiceInterface.h>
namespace initmission { namespace initmission {
void printAddObjectError(const char* name, object_id_t objectId) { static void printAddObjectError(const char* name, object_id_t objectId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x" sif::error << "InitMission::printAddError: Adding object " << name << " with object ID 0x"
<< std::hex << std::setfill('0') << std::setw(8) << objectId << " failed!" << std::dec << std::hex << std::setfill('0') << std::setw(8) << objectId << " failed!" << std::dec
@ -18,5 +17,3 @@ void printAddObjectError(const char* name, object_id_t objectId) {
} }
} // namespace initmission } // namespace initmission
#endif /* MISSION_UTILITY_INITMISSION_H_ */

2
tmtc

@ -1 +1 @@
Subproject commit 603b7e8574d74ba60692115133cde3cd8b8bd423 Subproject commit a7714747bc45dfa6a9ccb41cc6eb890b21ca0481