5 Commits

Author SHA1 Message Date
muellerr a523f4ab91 ping works now 2022-07-27 17:57:22 +02:00
muellerr 3acc72470d some clang-tidy imorovements 2022-07-27 17:00:57 +02:00
muellerr c483202852 create verification reporter explicitely 2022-07-27 14:39:56 +02:00
muellerr 43060b3be7 changes for updated TMTC API 2022-07-27 11:33:40 +02:00
muellerr a76b0ae56c tmtc refactoring 2022-07-25 10:18:38 +02:00
15 changed files with 511 additions and 148 deletions
+1 -1
View File
@@ -6,7 +6,7 @@
#include <cstdint>
#cmakedefine01 OBSW_ADD_FMT_TESTS
#cmakedefine01 FSFW_ADD_FMT_TESTS
//! Specify the debug output verbose level
#define OBSW_VERBOSE_LEVEL 1
+14 -2
View File
@@ -33,7 +33,13 @@ ReturnValue_t pst::pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence) {
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_OK;
} else {
FSFW_LOGE("pst::pollingSequenceInitFunction: Initialization errors\n");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!"
<< std::endl;
#else
sif::printError(
"pst::pollingSequenceInitFunction: Initialization errors!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
}
@@ -69,7 +75,13 @@ ReturnValue_t pst::pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence) {
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_OK;
} else {
FSFW_LOGE("pst::pollingSequenceTestFunction: Initialization errors\n");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "pst::pollingSequenceTestFunction: Initialization errors!"
<< std::endl;
#else
sif::printError(
"pst::pollingSequenceTestFunction: Initialization errors!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
}
+99 -38
View File
@@ -27,26 +27,36 @@ void FsfwTestController::performControlOperation() {
return;
}
switch (currentTraceType) {
case (NONE): {
break;
}
case (TRACE_DEV_0_UINT8): {
if (traceCounter == 0) {
FSFW_LOGI("Tracing finished\n");
traceVariable = false;
traceCounter = traceCycles;
currentTraceType = TraceTypes::NONE;
break;
}
PoolReadGuard readHelper(&deviceDataset0.testUint8Var);
FSFW_LOGI("Tracing device 0 variable 0 (UINT8), current value: {}",
static_cast<int>(deviceDataset0.testUint8Var.value));
traceCounter--;
break;
}
case (TRACE_DEV_0_VECTOR): {
case (NONE): {
break;
}
case (TRACE_DEV_0_UINT8): {
if (traceCounter == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Tracing finished" << std::endl;
#else
sif::printInfo("Tracing finished\n");
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
traceVariable = false;
traceCounter = traceCycles;
currentTraceType = TraceTypes::NONE;
break;
}
PoolReadGuard readHelper(&deviceDataset0.testUint8Var);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Tracing device 0 variable 0 (UINT8), current value: "
<< static_cast<int>(deviceDataset0.testUint8Var.value)
<< std::endl;
#else
sif::printInfo("Tracing device 0 variable 0 (UINT8), current value: %d\n",
deviceDataset0.testUint8Var.value);
#endif
traceCounter--;
break;
}
case (TRACE_DEV_0_VECTOR): {
break;
}
}
}
}
@@ -57,10 +67,20 @@ ReturnValue_t FsfwTestController::initializeAfterTaskCreation() {
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
auto* device0 =
ObjectManager::instance()->get<HasLocalDataPoolIF>(deviceDataset0.getCreatorObjectId());
HasLocalDataPoolIF *device0 =
ObjectManager::instance()->get<HasLocalDataPoolIF>(
deviceDataset0.getCreatorObjectId());
if (device0 == nullptr) {
FSFW_LOGW("initializeAfterTaskCreation: Test device handler 0 handle invalid\n");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning
<< "TestController::initializeAfterTaskCreation: Test device handler 0 "
"handle invalid!"
<< std::endl;
#else
sif::printWarning(
"TestController::initializeAfterTaskCreation: Test device handler 0 "
"handle invalid!");
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
ProvidesDataPoolSubscriptionIF *subscriptionIF =
@@ -73,10 +93,20 @@ ReturnValue_t FsfwTestController::initializeAfterTaskCreation() {
td::PoolIds::TEST_UINT8_ID, getObjectId(), getCommandQueue(), false);
}
auto* device1 =
ObjectManager::instance()->get<HasLocalDataPoolIF>(deviceDataset0.getCreatorObjectId());
HasLocalDataPoolIF *device1 =
ObjectManager::instance()->get<HasLocalDataPoolIF>(
deviceDataset0.getCreatorObjectId());
if (device1 == nullptr) {
FSFW_LOGW("initializeAfterTaskCreation: Test device handler 1 handle invalid\n");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning
<< "TestController::initializeAfterTaskCreation: Test device handler 1 "
"handle invalid!"
<< std::endl;
#else
sif::printWarning(
"TestController::initializeAfterTaskCreation: Test device handler 1 "
"handle invalid!");
#endif
}
subscriptionIF = device1->getSubscriptionInterface();
@@ -107,23 +137,39 @@ void FsfwTestController::handleChangedDataset(sid_t sid,
if (verboseLevel >= 1) {
char const *printout = nullptr;
if (storeId == storeId::INVALID_STORE_ADDRESS) {
if (storeId == store_address_t::invalid()) {
printout = "Notification";
} else {
printout = "Snapshot";
}
FSFW_LOGI("handleChangedDataset: {} update from object ID {:#010x} and set ID {}\n", printout,
sid.objectId, sid.ownerSetId);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "FsfwTestController::handleChangedDataset: " << printout
<< " update"
"from object ID "
<< setw(8) << setfill('0') << hex << sid.objectId
<< " and set ID " << sid.ownerSetId << dec << setfill(' ')
<< endl;
#else
sif::printInfo(
"FsfwTestController::handleChangedPoolVariable: %s update from"
"object ID 0x%08x and set ID %lu\n",
printout, sid.objectId, sid.ownerSetId);
#endif
if (storeId == storeId::INVALID_STORE_ADDRESS) {
if (storeId == store_address_t::invalid()) {
if (sid.objectId == device0Id) {
PoolReadGuard readHelper(&deviceDataset0.testFloat3Vec);
float floatVec[3];
floatVec[0] = deviceDataset0.testFloat3Vec.value[0];
floatVec[1] = deviceDataset0.testFloat3Vec.value[1];
floatVec[2] = deviceDataset0.testFloat3Vec.value[2];
FSFW_LOGI("Current float vector (3) values: [{},{},{}]\n", floatVec[0], floatVec[1],
floatVec[2]);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Current float vector (3) values: [" << floatVec[0] << ", "
<< floatVec[1] << ", " << floatVec[2] << "]" << std::endl;
#else
sif::printInfo("Current float vector (3) values: [%f, %f, %f]\n",
floatVec[0], floatVec[1], floatVec[2]);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
}
}
}
@@ -143,22 +189,37 @@ void FsfwTestController::handleChangedPoolVariable(gp_id_t globPoolId,
if (verboseLevel >= 1) {
char const *printout = nullptr;
if (storeId == storeId::INVALID_STORE_ADDRESS) {
if (storeId == store_address_t::invalid()) {
printout = "Notification";
} else {
printout = "Snapshot";
}
FSFW_LOGI(
"TestController::handleChangedPoolVariable: {} update from object "
"ID {:#010x} and LPID {}\n",
printout, globPoolId.objectId, globPoolId.localPoolId);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TestController::handleChangedPoolVariable: " << printout
<< " update from object "
"ID 0x"
<< setw(8) << setfill('0') << hex << globPoolId.objectId
<< " and local pool ID " << globPoolId.localPoolId << dec
<< setfill(' ') << endl;
#else
sif::printInfo("TestController::handleChangedPoolVariable: %s update from "
"object ID 0x%08x and "
"local pool ID %lu\n",
printout, globPoolId.objectId, globPoolId.localPoolId);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
if (storeId == storeId::INVALID_STORE_ADDRESS) {
if (storeId == store_address_t::invalid()) {
if (globPoolId.objectId == device0Id) {
PoolReadGuard readHelper(&deviceDataset0.testUint8Var);
FSFW_LOGI("Current test variable 0 (UINT8) value: {}",
static_cast<int>(deviceDataset0.testUint8Var.value));
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Current test variable 0 (UINT8) value: "
<< static_cast<int>(deviceDataset0.testUint8Var.value)
<< std::endl;
#else
sif::printInfo("Current test variable 0 (UINT8) value %d\n",
deviceDataset0.testUint8Var.value);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
}
}
}
+20 -17
View File
@@ -21,9 +21,10 @@
#include "fsfw/pus/Service8FunctionManagement.h"
#include "fsfw/pus/Service9TimeManagement.h"
#include "fsfw/tcdistribution/CCSDSDistributor.h"
#include "fsfw/tcdistribution/PUSDistributor.h"
#include "fsfw/timemanager/TimeStamper.h"
#include "fsfw/tcdistribution/PusDistributor.h"
#include "fsfw/timemanager/CdsShortTimeStamper.h"
#include "fsfw/tmtcpacket/pus/tm.h"
#include "fsfw/tmtcservices/VerificationReporter.h"
#include "fsfw_tests/integration/assemblies/TestAssembly.h"
#include "fsfw_tests/integration/controller/TestController.h"
#include "fsfw_tests/integration/devices/TestCookie.h"
@@ -39,12 +40,13 @@ void ObjectFactory::produceGenericObjects() {
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
new TimeStamper(objects::TIME_STAMPER);
auto* stamperAndReader = new CdsShortTimeStamper(objects::TIME_STAMPER);
new VerificationReporter(nullptr);
auto *ccsdsDistrib =
new CCSDSDistributor(apid::APID, objects::CCSDS_DISTRIBUTOR);
new PUSDistributor(apid::APID, objects::PUS_DISTRIBUTOR,
objects::CCSDS_DISTRIBUTOR);
new TmFunnel(objects::TM_FUNNEL);
new PusDistributor(apid::APID, objects::PUS_DISTRIBUTOR,
ccsdsDistrib);
new TmFunnel(*stamperAndReader, objects::TM_FUNNEL);
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
/* PUS stack */
@@ -56,19 +58,19 @@ void ObjectFactory::produceGenericObjects() {
pus::PUS_SERVICE_2, 3, 10);
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::APID,
pus::PUS_SERVICE_3);
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::APID,
pus::PUS_SERVICE_5, 50);
new Service5EventReporting(PsbParams(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::APID,
pus::PUS_SERVICE_5), 20 , 40);
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT,
apid::APID, pus::PUS_SERVICE_8, 3, 10);
new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::APID,
pus::PUS_SERVICE_9);
new Service17Test(objects::PUS_SERVICE_17_TEST, apid::APID,
pus::PUS_SERVICE_17);
new Service9TimeManagement(PsbParams(objects::PUS_SERVICE_9_TIME_MGMT, apid::APID,
pus::PUS_SERVICE_9));
new Service17Test(PsbParams(objects::PUS_SERVICE_17_TEST, apid::APID,
pus::PUS_SERVICE_17));
new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS,
apid::APID, pus::PUS_SERVICE_20);
#if OBSW_ADD_CORE_COMPONENTS == 1
new Service11TelecommandScheduling<cfg::OBSW_MAX_SCHEDULED_TCS>(
objects::PUS_SERVICE_11_TC_SCHEDULER, apid::APID, pus::PUS_SERVICE_11,
PsbParams(objects::PUS_SERVICE_11_TC_SCHEDULER, apid::APID, pus::PUS_SERVICE_11),
ccsdsDistrib);
#endif
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::APID,
@@ -151,13 +153,14 @@ void Factory::setStaticFrameworkObjectIds() {
// No storage object for now.
TmFunnel::storageDestination = objects::NO_OBJECT;
PusServiceBase::packetSource = objects::PUS_DISTRIBUTOR;
PusServiceBase::packetDestination = objects::TM_FUNNEL;
PusServiceBase::PUS_DISTRIBUTOR = objects::PUS_DISTRIBUTOR;
PusServiceBase::PACKET_DESTINATION = objects::TM_FUNNEL;
CommandingServiceBase::defaultPacketSource = objects::PUS_DISTRIBUTOR;
CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL;
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
VerificationReporter::DEFAULT_REPORTER = objects::TC_VERIFICATOR;
VerificationReporter::DEFAULT_RECEIVER = objects::PUS_SERVICE_1_VERIFICATION;
TmPacketBase::timeStamperId = objects::TIME_STAMPER;
// TmPacketBase::timeStamperId = objects::TIME_STAMPER;
}
+2 -4
View File
@@ -1,8 +1,6 @@
target_sources(${TARGET_NAME} PRIVATE FsfwReaderTask.cpp FsfwExampleTask.cpp
MutexExample.cpp FsfwTestTask.cpp)
if(OBSW_ADD_FMT_TESTS)
target_sources(${TARGET_NAME} PRIVATE
testFmt.cpp
)
if(FSFW_ADD_FMT_TESTS)
target_sources(${TARGET_NAME} PRIVATE testFmt.cpp)
endif()
+70 -22
View File
@@ -3,7 +3,7 @@
#include <fsfw/ipc/CommandMessage.h>
#include <fsfw/ipc/QueueFactory.h>
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tasks/TaskFactory.h>
#include "OBSWConfig.h"
@@ -80,9 +80,15 @@ object_id_t FsfwExampleTask::getSender() {
ReturnValue_t FsfwExampleTask::initialize() {
// Get the dataset of the sender. Will be cached for later checks.
object_id_t sender = getSender();
auto* senderIF = ObjectManager::instance()->get<HasLocalDataPoolIF>(sender);
HasLocalDataPoolIF *senderIF =
ObjectManager::instance()->get<HasLocalDataPoolIF>(sender);
if (senderIF == nullptr) {
FSFW_LOGE("initialize: Sender object invalid\n");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::initialize: Sender object invalid!"
<< std::endl;
#else
sif::printError("FsfwDemoTask::initialize: Sender object invalid!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
@@ -90,7 +96,12 @@ ReturnValue_t FsfwExampleTask::initialize() {
// dataset.
senderSet = new FsfwDemoSet(senderIF);
if (senderSet == nullptr) {
FSFW_LOGE("initialize: Sender dataset invalid\n");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::initialize: Sender dataset invalid!"
<< std::endl;
#else
sif::printError("FsfwDemoTask::initialize: Sender dataset invalid!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
return poolManager.initialize(commandQueue);
@@ -133,7 +144,13 @@ ReturnValue_t FsfwExampleTask::performMonitoringDemo() {
demoSet.variableLimit.read(MutexIF::TimeoutType::WAITING, 20);
if (result != HasReturnvaluesIF::RETURN_OK) {
/* Configuration error */
FSFW_LOGE("DummyObject::performOperation: Could not read variableLimit\n");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DummyObject::performOperation: Could not read variableLimit!"
<< std::endl;
#else
sif::printError(
"DummyObject::performOperation: Could not read variableLimit!\n");
#endif
return result;
}
if (this->getObjectId() == objects::TEST_DUMMY_5) {
@@ -141,7 +158,7 @@ ReturnValue_t FsfwExampleTask::performMonitoringDemo() {
demoSet.variableLimit.value = 0;
}
demoSet.variableLimit.value++;
demoSet.variableLimit.commit(true);
demoSet.variableLimit.commit(20);
monitor.check();
}
return HasReturnvaluesIF::RETURN_OK;
@@ -149,10 +166,18 @@ ReturnValue_t FsfwExampleTask::performMonitoringDemo() {
ReturnValue_t FsfwExampleTask::performSendOperation() {
object_id_t nextRecipient = getNextRecipient();
auto* target = ObjectManager::instance()->get<FsfwExampleTask>(nextRecipient);
FsfwExampleTask *target =
ObjectManager::instance()->get<FsfwExampleTask>(nextRecipient);
if (target == nullptr) {
/* Configuration error */
FSFW_LOGE("performSendOperation: Next recipient does not exist\n");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error
<< "DummyObject::performOperation: Next recipient does not exist!"
<< std::endl;
#else
sif::printError(
"DummyObject::performOperation: Next recipient does not exist!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
@@ -162,20 +187,35 @@ ReturnValue_t FsfwExampleTask::performSendOperation() {
message.setParameter2(this->getMessageQueueId());
/* Send message using own message queue */
ReturnValue_t result = commandQueue->sendMessage(target->getMessageQueueId(), &message);
if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::FULL) {
FSFW_LOGE("performSendOperation: Send failed with {:#06x}\n", result);
ReturnValue_t result =
commandQueue->sendMessage(target->getMessageQueueId(), &message);
if (result != HasReturnvaluesIF::RETURN_OK &&
result != MessageQueueIF::FULL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::performSendOperation: Send failed with "
<< result << std::endl;
#else
sif::printError(
"FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
#endif
}
/* Send message without via MessageQueueSenderIF */
result = MessageQueueSenderIF::sendMessage(target->getMessageQueueId(), &message,
commandQueue->getId());
if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::FULL) {
FSFW_LOGE("performSendOperation: Send failed with {:#06x}\n", result);
result = MessageQueueSenderIF::sendMessage(target->getMessageQueueId(),
&message, commandQueue->getId());
if (result != HasReturnvaluesIF::RETURN_OK &&
result != MessageQueueIF::FULL) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::performSendOperation: Send failed with "
<< result << std::endl;
#else
sif::printError(
"FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
#endif
}
demoSet.variableWrite.value = randomNumber;
result = demoSet.variableWrite.commit(true);
result = demoSet.variableWrite.commit(20);
return result;
}
@@ -185,8 +225,11 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
while (result != MessageQueueIF::EMPTY) {
CommandMessage receivedMessage;
result = commandQueue->receiveMessage(&receivedMessage);
if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::EMPTY) {
FSFW_LOGD("performReceiveOperation: Receive failed with {}\n", result);
if (result != HasReturnvaluesIF::RETURN_OK &&
result != MessageQueueIF::EMPTY) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Receive failed with " << result << std::endl;
#endif
break;
}
if (result != MessageQueueIF::EMPTY) {
@@ -208,10 +251,15 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
return result;
}
if (senderSet->variableRead.value != receivedMessage.getParameter()) {
FSFW_LOGE(
"FsfwDemoTask::performReceiveOperation: Variable {} has wrong value {}, expected {}\n",
senderSet->variableRead.getDataPoolId(), demoSet.variableRead.value,
receivedMessage.getParameter());
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::performReceiveOperation: Variable "
<< std::hex << "0x"
<< senderSet->variableRead.getDataPoolId() << std::dec
<< " has wrong value." << std::endl;
sif::error << "Value: " << demoSet.variableRead.value
<< ", expected: " << receivedMessage.getParameter()
<< std::endl;
#endif
}
}
}
+19 -5
View File
@@ -2,7 +2,7 @@
#include <OBSWConfig.h>
#include <fsfw/datapool/PoolReadGuard.h>
#include <fsfw/serviceinterface.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tasks/TaskFactory.h>
#include <fsfw/timemanager/Stopwatch.h>
@@ -32,11 +32,25 @@ ReturnValue_t FsfwReaderTask::performOperation(uint8_t operationCode) {
uint32_t variable2 = readSet.variable2.value;
uint32_t variable3 = readSet.variable3.value;
#if OBSW_VERBOSE_LEVEL >= 1
if (opDivider.checkAndIncrement() and printoutEnabled) {
FSFW_LOGI(
"FsfwPeriodicTask::performOperation: Reading variables from Demo "
"Object 1,2,3\n1 {} | 2 {} | 3 {}\n",
variable1, variable2, variable3);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "FsfwPeriodicTask::performOperation: Reading variables."
<< std::endl;
sif::info << "Variable read from demo object 1: " << variable1 << std::endl;
sif::info << "Variable read from demo object 2: " << variable2 << std::endl;
sif::info << "Variable read from demo object 3: " << variable3 << std::endl;
#else
sif::printInfo(
"FsfwPeriodicTask::performOperation: Reading variables.\n\r");
sif::printInfo("Variable read from demo object 1: %d\n\r", variable1);
sif::printInfo("Variable read from demo object 2: %d\n\r", variable2);
sif::printInfo("Variable read from demo object 3: %d\n\r", variable3);
#endif
}
#else
if (variable1 and variable2 and variable3) {
};
#endif
return HasReturnvaluesIF::RETURN_OK;
}
+2 -2
View File
@@ -2,13 +2,13 @@
#include <commonConfig.h>
#if OBSW_ADD_FMT_TESTS == 1
#if FSFW_ADD_FMT_TESTS == 1
#include "testFmt.h"
#endif
FsfwTestTask::FsfwTestTask(object_id_t objectId, bool periodicEvent)
: TestTask(objectId), periodicEvent(periodicEvent) {
#if OBSW_ADD_FMT_TESTS == 1
#if FSFW_ADD_FMT_TESTS == 1
fmtTests();
#endif
}
+25 -5
View File
@@ -1,7 +1,7 @@
#include "MutexExample.h"
#include <fsfw/ipc/MutexFactory.h>
#include <fsfw/serviceinterface.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
void MutexExample::example() {
MutexIF *mutex = MutexFactory::instance()->createMutex();
@@ -10,21 +10,41 @@ void MutexExample::example() {
ReturnValue_t result =
mutex->lockMutex(MutexIF::TimeoutType::WAITING, 2 * 60 * 1000);
if (result != HasReturnvaluesIF::RETURN_OK) {
FSFW_LOGET("MutexExample::example: Lock Failed with {}\n", result);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Lock Failed with " << result
<< std::endl;
#else
sif::printError("MutexExample::example: Lock Failed with %hu\n", result);
#endif
}
result = mutex2->lockMutex(MutexIF::TimeoutType::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) {
FSFW_LOGET("MutexExample::example: Lock Failed with {}\n", result);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Lock Failed with " << result
<< std::endl;
#else
sif::printError("MutexExample::example: Lock Failed with %hu\n", result);
#endif
}
result = mutex->unlockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) {
FSFW_LOGET("MutexExample::example: Unlock Failed with {}\n", result);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Unlock Failed with " << result
<< std::endl;
#else
sif::printError("MutexExample::example: Unlock Failed with %hu\n", result);
#endif
}
result = mutex2->unlockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) {
FSFW_LOGET("MutexExample::example: Unlock Failed with {}\n", result);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Unlock Failed with " << result
<< std::endl;
#else
sif::printError("MutexExample::example: Unlock Failed with %hu\n", result);
#endif
}
}
+10 -16
View File
@@ -1,20 +1,14 @@
#include "fsfw/serviceinterface/fmtWrapper.h"
#include "testFmt.h"
void fmtTests() {
sif::initialize();
sif::debug_s(__FILENAME__, __LINE__, "Hello {}", "World\n");
sif::debug_st(__FILENAME__, __LINE__, "Hallo\n");
sif::fdebug(__FILENAME__, __LINE__, "Hello {} {}", "World\n");
sif::fdebug_t(__FILENAME__, __LINE__, "Hallo\n");
FSFW_LOGD("{}", "Hallo\n");
sif::info_t("Hallo\n");
sif::info("Hallo\n");
sif::warning_s(__FILENAME__, __LINE__, "Hello\n");
sif::warning_st(__FILENAME__, __LINE__, "Hello\n");
FSFW_LOGW("Hello World\n");
FSFW_LOGW("{} World\n", "Hello");
uint8_t test0 = 5;
float test1 = 12.0;
uint32_t test2 = 0x00ff11ff;
FSFW_LOGW("Test 0 {} | Test 1 {:.3f} | Test 2 {:#010x}\n", test0, test1, test2);
sif::error_s(__FILENAME__, __LINE__, "Hello\n");
sif::error_st(__FILENAME__, __LINE__, "Hello\n");
// MY_LOG("{}", "test\n");
// sif::finfo_t("Hallo\n");
// sif::finfo("Hallo\n");
// sif::fwarning("Hello\n");
// sif::fwarning_t("Hello\n");
// sif::ferror("Hello\n");
// sif::ferror_t("Hello\n");
}
+181 -1
View File
@@ -1,3 +1,183 @@
#pragma once
#ifndef FSFW_EXAMPLE_HOSTED_TESTFMT_H
#define FSFW_EXAMPLE_HOSTED_TESTFMT_H
#include <fmt/chrono.h>
#include <fmt/color.h>
#include <fmt/compile.h>
#include <fmt/core.h>
#include <array>
#include <cstdint>
#include "fsfw/ipc/MutexFactory.h"
#include "fsfw/ipc/MutexGuard.h"
#include "fsfw/ipc/MutexIF.h"
#include "fsfw/timemanager/Clock.h"
#define __FILENAME_REL__ (((const char *)__FILE__ + SOURCE_PATH_SIZE))
#define __FILENAME__ \
(strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
void fmtTests();
namespace sif {
static std::array<char, 524> PRINT_BUF = {};
static const char INFO_PREFIX[] = "INFO";
static const char DEBUG_PREFIX[] = "DEBUG";
static const char WARNING_PREFIX[] = "WARNING";
static const char ERROR_PREFIX[] = "ERROR";
enum class LogLevel : unsigned int {
DEBUG = 0,
INFO = 1,
WARNING = 2,
ERROR = 3
};
static const char *PREFIX_ARR[4] = {DEBUG_PREFIX, INFO_PREFIX, WARNING_PREFIX,
ERROR_PREFIX};
static const std::array<fmt::color, 4> LOG_COLOR_ARR = {
fmt::color::deep_sky_blue, fmt::color::forest_green, fmt::color::orange_red,
fmt::color::red};
static MutexIF *PRINT_MUTEX = MutexFactory::instance()->createMutex();
static size_t writeTypePrefix(LogLevel level) {
auto idx = static_cast<unsigned int>(level);
const auto result = fmt::format_to_n(
PRINT_BUF.begin(), PRINT_BUF.size() - 1,
fmt::runtime(fmt::format(fg(LOG_COLOR_ARR[idx]), PREFIX_ARR[idx])));
return result.size;
}
template <typename... T>
size_t logTraced(LogLevel level, const char *file, unsigned int line,
bool timed, fmt::format_string<T...> fmt,
T &&...args) noexcept {
try {
MutexGuard mg(PRINT_MUTEX);
size_t bufPos = writeTypePrefix(level);
auto currentIter = PRINT_BUF.begin() + bufPos;
if (timed) {
Clock::TimeOfDay_t logTime;
Clock::getDateAndTime(&logTime);
const auto result =
fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos,
" | {}[l.{}] | {:02}:{:02}:{:02}.{:03} | {}", file,
line, logTime.hour, logTime.minute, logTime.second,
logTime.usecond / 1000, fmt::format(fmt, args...));
*result.out = '\0';
bufPos += result.size;
} else {
const auto result = fmt::format_to_n(
currentIter, PRINT_BUF.size() - 1 - bufPos, " | {}[l.{}] | {}", file,
line, fmt::format(fmt, args...));
*result.out = '\0';
bufPos += result.size;
}
fmt::print(fmt::runtime(PRINT_BUF.data()));
return bufPos;
} catch (const fmt::v8::format_error &e) {
fmt::print("Printing failed with error: {}\n", e.what());
return 0;
}
}
template <typename... T>
size_t log(LogLevel level, bool timed, fmt::format_string<T...> fmt,
T &&...args) noexcept {
try {
MutexGuard mg(PRINT_MUTEX);
size_t bufPos = writeTypePrefix(level);
auto currentIter = PRINT_BUF.begin() + bufPos;
if (timed) {
Clock::TimeOfDay_t logTime;
Clock::getDateAndTime(&logTime);
const auto result = fmt::format_to_n(
currentIter, PRINT_BUF.size() - bufPos,
" | {:02}:{:02}:{:02}.{:03} | {}", logTime.hour, logTime.minute,
logTime.second, logTime.usecond / 1000, fmt::format(fmt, args...));
bufPos += result.size;
}
fmt::print(fmt::runtime(PRINT_BUF.data()));
return bufPos;
} catch (const fmt::v8::format_error &e) {
fmt::print("Printing failed with error: {}\n", e.what());
return 0;
}
}
template <typename... T>
void fdebug(const char *file, unsigned int line, fmt::format_string<T...> fmt,
T &&...args) noexcept {
logTraced(LogLevel::DEBUG, file, line, false, fmt, args...);
}
template <typename... T>
void fdebug_t(const char *file, unsigned int line, fmt::format_string<T...> fmt,
T &&...args) noexcept {
logTraced(LogLevel::DEBUG, file, line, true, fmt, args...);
}
template <typename... T>
void finfo_t(fmt::format_string<T...> fmt, T &&...args) {
log(LogLevel::INFO, true, fmt, args...);
}
template <typename... T> void finfo(fmt::format_string<T...> fmt, T &&...args) {
log(LogLevel::INFO, false, fmt, args...);
}
template <typename... T>
void fwarning(const char *file, unsigned int line, fmt::format_string<T...> fmt,
T &&...args) {
logTraced(LogLevel::WARNING, file, line, false, fmt, args...);
}
template <typename... T>
void fwarning_t(const char *file, unsigned int line,
fmt::format_string<T...> fmt, T &&...args) {
logTraced(LogLevel::WARNING, file, line, true, fmt, args...);
}
template <typename... T>
void ferror(const char *file, unsigned int line, fmt::format_string<T...> fmt,
T &&...args) {
logTraced(LogLevel::ERROR, file, line, false, fmt, args...);
}
template <typename... T>
void ferror_t(const char *file, unsigned int line, fmt::format_string<T...> fmt,
T &&...args) {
logTraced(LogLevel::ERROR, file, line, true, fmt, args...);
}
} // namespace sif
#define FSFW_LOGI(format, ...) finfo(FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGIT(format, ...) finfo_t(FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGD(format, ...) \
sif::fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGDT(format, ...) \
fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGW(format, ...) \
fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGWT(format, ...) \
fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGE(format, ...) \
fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGET(format, ...) \
fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#endif // FSFW_EXAMPLE_HOSTED_TESTFMT_H
+10 -3
View File
@@ -2,12 +2,19 @@
#define MISSION_UTILITY_TASKCREATION_H_
#include <fsfw/objectmanager/SystemObjectIF.h>
#include <fsfw/serviceinterface.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
namespace task {
void printInitError(const char* objName, object_id_t objectId) {
FSFW_LOGW("InitMission: Adding object {} ({:#010x}) failed\n", objName, objectId);
void printInitError(const char *objName, object_id_t objectId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "InitMission: Adding object " << objName << "(" << std::setw(8)
<< std::setfill('0') << std::hex << objectId << std::dec
<< ") failed." << std::endl;
#else
sif::printError("InitMission: Adding object %s (0x%08x) failed.\n", objName,
static_cast<unsigned int>(objectId));
#endif
}
} // namespace task
+35 -19
View File
@@ -1,22 +1,23 @@
#include "TmFunnel.h"
#include <fsfw/ipc/QueueFactory.h>
#include "fsfw/tmtcpacket/pus/tm.h"
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tmtcpacket/pus/tm.h>
object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT;
object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth)
: SystemObject(objectId), messageDepth(messageDepth) {
TmFunnel::TmFunnel(TimeReaderIF& timeReader, object_id_t objectId, uint32_t messageDepth)
: SystemObject(objectId), timeReader(timeReader), messageDepth(messageDepth) {
tmQueue = QueueFactory::instance()->createMessageQueue(
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE);
storageQueue = QueueFactory::instance()->createMessageQueue(
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE);
}
TmFunnel::~TmFunnel() {}
TmFunnel::~TmFunnel() = default;
MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) {
return tmQueue->getId();
@@ -28,6 +29,7 @@ ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
while (status == HasReturnvaluesIF::RETURN_OK) {
status = handlePacket(&currentMessage);
if (status != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "TmFunnel packet handling failed" << std::endl;
break;
}
status = tmQueue->receiveMessage(&currentMessage);
@@ -48,17 +50,21 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) {
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
TmPacketPusC packet(packetData);
packet.setPacketSequenceCount(this->sourceSequenceCount);
sourceSequenceCount++;
sourceSequenceCount =
sourceSequenceCount % SpacePacketBase::LIMIT_SEQUENCE_COUNT;
packet.setErrorControl();
PusTmZeroCopyWriter packet(&timeReader, packetData, size);
result = packet.parseDataWithoutCrcCheck();
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
packet.setSequenceCount(sourceSequenceCount++);
sourceSequenceCount = sourceSequenceCount % ccsds::LIMIT_SEQUENCE_COUNT;
packet.updateErrorControl();
result = tmQueue->sendToDefault(message);
if (result != HasReturnvaluesIF::RETURN_OK) {
tmPool->deleteData(message->getStorageId());
FSFW_LOGET("handlePacket: Error sending to downlink handler\n");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::handlePacket: Error sending TM to downlink handler" << std::endl;
#endif
return result;
}
@@ -66,7 +72,10 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) {
result = storageQueue->sendToDefault(message);
if (result != HasReturnvaluesIF::RETURN_OK) {
tmPool->deleteData(message->getStorageId());
FSFW_LOGET("handlePacket: Error sending to storage handler\n");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::handlePacket: Error sending to storage handler"
<< std::endl;
#endif
return result;
}
}
@@ -76,18 +85,25 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) {
ReturnValue_t TmFunnel::initialize() {
tmPool = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (tmPool == nullptr) {
FSFW_LOGE("{}",
"initialize: TM store not set\n"
"Make sure the tm store is set up properly and implements StorageManagerIF");
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::initialize: TM store not set." << std::endl;
sif::error << "Make sure the tm store is set up properly and implements "
"StorageManagerIF"
<< std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
auto* tmTarget = ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination);
AcceptsTelemetryIF *tmTarget =
ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination);
if (tmTarget == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
FSFW_LOGE("{}",
"initialize: Downlink Destination not set. Make sure the downlink destination "
"object is set up properly and implements AcceptsTelemetryIF\n");
sif::error << "TmFunnel::initialize: Downlink Destination not set."
<< std::endl;
sif::error << "Make sure the downlink destination object is set up "
"properly and implements "
"AcceptsTelemetryIF"
<< std::endl;
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
+8 -6
View File
@@ -7,6 +7,8 @@
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
#include <fsfw/tmtcservices/TmTcMessage.h>
#include "fsfw/timemanager/TimeReaderIF.h"
namespace Factory {
void setStaticFrameworkObjectIds();
}
@@ -25,13 +27,12 @@ class TmFunnel : public AcceptsTelemetryIF,
friend void(Factory::setStaticFrameworkObjectIds)();
public:
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20);
virtual ~TmFunnel();
explicit TmFunnel(TimeReaderIF& timeReader, object_id_t objectId, uint32_t messageDepth = 20);
~TmFunnel() override;
virtual MessageQueueId_t
getReportReceptionQueue(uint8_t virtualChannel = 0) override;
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
virtual ReturnValue_t initialize() override;
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override;
ReturnValue_t performOperation(uint8_t operationCode) override;
ReturnValue_t initialize() override;
protected:
static object_id_t downlinkDestination;
@@ -39,6 +40,7 @@ protected:
private:
uint16_t sourceSequenceCount = 0;
TimeReaderIF& timeReader;
MessageQueueIF *tmQueue = nullptr;
MessageQueueIF *storageQueue = nullptr;
+15 -7
View File
@@ -1,16 +1,24 @@
#include "utility.h"
#include <FSFWConfig.h>
#include <OBSWVersion.h>
#include "fsfw/serviceinterface.h"
#include <fsfw/serviceinterface/ServiceInterface.h>
void utility::commonInitPrint(const char *const os, const char *const board) {
if (os == nullptr or board == nullptr) {
return;
}
fmt::print("-- FSFW Example ({}) v{}.{}.{} --\n", os, FSFW_EXAMPLE_VERSION,
FSFW_EXAMPLE_SUBVERSION, FSFW_EXAMPLE_REVISION);
fmt::print("-- Compiled for {}\n", board);
fmt::print("-- Compiled on {} {}\n", __DATE__, __TIME__);
sif::initialize();
#if FSFW_CPP_OSTREAM_ENABLED == 1
std::cout << "-- FSFW Example (" << os << ") v" << FSFW_EXAMPLE_VERSION << "."
<< FSFW_EXAMPLE_SUBVERSION << "." << FSFW_EXAMPLE_REVISION << " --"
<< std::endl;
std::cout << "-- Compiled for " << board << " --" << std::endl;
std::cout << "-- Compiled on " << __DATE__ << " " << __TIME__ << " --"
<< std::endl;
#else
printf("\n\r-- FSFW Example (%s) v%d.%d.%d --\n", os, FSFW_EXAMPLE_VERSION,
FSFW_EXAMPLE_SUBVERSION, FSFW_EXAMPLE_REVISION);
printf("-- Compiled for %s --\n", board);
printf("-- Compiled on %s %s --\n", __DATE__, __TIME__);
#endif
}