This commit is contained in:
Robin Müller 2022-08-08 12:32:06 +02:00
parent d2b15ee4fa
commit 5792aff5e3
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
32 changed files with 476 additions and 657 deletions

View File

@ -6,8 +6,8 @@
namespace CLASS_ID {
enum commonClassIds : uint8_t {
COMMON_CLASS_ID_START = FW_CLASS_ID_COUNT,
DUMMY_HANDLER, // DDH
COMMON_CLASS_ID_END // [EXPORT] : [END]
DUMMY_HANDLER, // DDH
COMMON_CLASS_ID_END // [EXPORT] : [END]
};
}

View File

@ -9,12 +9,9 @@
ReturnValue_t pst::pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence) {
uint32_t length = thisSequence->getPeriodMs();
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0,
FsfwExampleTask::OpCodes::SEND_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0,
FsfwExampleTask::OpCodes::SEND_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0,
FsfwExampleTask::OpCodes::SEND_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0, FsfwExampleTask::OpCodes::SEND_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0, FsfwExampleTask::OpCodes::SEND_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0, FsfwExampleTask::OpCodes::SEND_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0.2,
FsfwExampleTask::OpCodes::RECEIVE_RAND_NUM);
@ -23,22 +20,17 @@ ReturnValue_t pst::pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence) {
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0.2,
FsfwExampleTask::OpCodes::RECEIVE_RAND_NUM);
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0.5,
FsfwExampleTask::OpCodes::DELAY_SHORT);
thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0.5,
FsfwExampleTask::OpCodes::DELAY_SHORT);
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0.5,
FsfwExampleTask::OpCodes::DELAY_SHORT);
thisSequence->addSlot(objects::TEST_DUMMY_1, length * 0.5, FsfwExampleTask::OpCodes::DELAY_SHORT);
thisSequence->addSlot(objects::TEST_DUMMY_2, length * 0.5, FsfwExampleTask::OpCodes::DELAY_SHORT);
thisSequence->addSlot(objects::TEST_DUMMY_3, length * 0.5, FsfwExampleTask::OpCodes::DELAY_SHORT);
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_OK;
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!"
<< std::endl;
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!" << std::endl;
#else
sif::printError(
"pst::pollingSequenceInitFunction: Initialization errors!\n");
sif::printError("pst::pollingSequenceInitFunction: Initialization errors!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -47,40 +39,28 @@ ReturnValue_t pst::pollingSequenceExamples(FixedTimeslotTaskIF *thisSequence) {
ReturnValue_t pst::pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence) {
uint32_t length = thisSequence->getPeriodMs();
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0,
DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0,
DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0, DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0, DeviceHandlerIF::PERFORM_OPERATION);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.3 * length,
DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.3 * length,
DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.3 * length, DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.3 * length, DeviceHandlerIF::SEND_WRITE);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.45 * length,
DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.45 * length,
DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.45 * length, DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.45 * length, DeviceHandlerIF::GET_WRITE);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.6 * length,
DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.6 * length,
DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.6 * length, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.6 * length, DeviceHandlerIF::SEND_READ);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.8 * length,
DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.8 * length,
DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.8 * length, DeviceHandlerIF::GET_READ);
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.8 * length, DeviceHandlerIF::GET_READ);
if (thisSequence->checkSequence() == HasReturnvaluesIF::RETURN_OK) {
return HasReturnvaluesIF::RETURN_OK;
} else {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "pst::pollingSequenceTestFunction: Initialization errors!"
<< std::endl;
sif::error << "pst::pollingSequenceTestFunction: Initialization errors!" << std::endl;
#else
sif::printError(
"pst::pollingSequenceTestFunction: Initialization errors!\n");
sif::printError("pst::pollingSequenceTestFunction: Initialization errors!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}

View File

@ -2,21 +2,22 @@
#include <fsfw/datapool/PoolReadGuard.h>
FsfwTestController::FsfwTestController(object_id_t objectId,
object_id_t device0, object_id_t device1,
uint8_t verboseLevel)
: TestController(objectId, objects::NO_OBJECT, 5), device0Id(device0),
device1Id(device1), deviceDataset0(device0), deviceDataset1(device1) {}
FsfwTestController::FsfwTestController(object_id_t objectId, object_id_t device0,
object_id_t device1, uint8_t verboseLevel)
: TestController(objectId, objects::NO_OBJECT, 5),
device0Id(device0),
device1Id(device1),
deviceDataset0(device0),
deviceDataset1(device1) {}
FsfwTestController::~FsfwTestController() {}
ReturnValue_t
FsfwTestController::handleCommandMessage(CommandMessage *message) {
ReturnValue_t FsfwTestController::handleCommandMessage(CommandMessage *message) {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t FsfwTestController::initializeLocalDataPool(
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
ReturnValue_t FsfwTestController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
return HasReturnvaluesIF::RETURN_OK;
}
@ -27,36 +28,35 @@ void FsfwTestController::performControlOperation() {
return;
}
switch (currentTraceType) {
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;
case (NONE): {
break;
}
PoolReadGuard readHelper(&deviceDataset0.testUint8Var);
case (TRACE_DEV_0_UINT8): {
if (traceCounter == 0) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Tracing device 0 variable 0 (UINT8), current value: "
<< static_cast<int>(deviceDataset0.testUint8Var.value)
<< std::endl;
sif::info << "Tracing finished" << std::endl;
#else
sif::printInfo("Tracing device 0 variable 0 (UINT8), current value: %d\n",
deviceDataset0.testUint8Var.value);
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;
}
traceCounter--;
break;
}
case (TRACE_DEV_0_VECTOR): {
break;
}
}
}
}
@ -68,14 +68,12 @@ ReturnValue_t FsfwTestController::initializeAfterTaskCreation() {
return result;
}
HasLocalDataPoolIF *device0 =
ObjectManager::instance()->get<HasLocalDataPoolIF>(
deviceDataset0.getCreatorObjectId());
ObjectManager::instance()->get<HasLocalDataPoolIF>(deviceDataset0.getCreatorObjectId());
if (device0 == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning
<< "TestController::initializeAfterTaskCreation: Test device handler 0 "
"handle invalid!"
<< std::endl;
sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 0 "
"handle invalid!"
<< std::endl;
#else
sif::printWarning(
"TestController::initializeAfterTaskCreation: Test device handler 0 "
@ -83,25 +81,22 @@ ReturnValue_t FsfwTestController::initializeAfterTaskCreation() {
#endif
return ObjectManagerIF::CHILD_INIT_FAILED;
}
ProvidesDataPoolSubscriptionIF *subscriptionIF =
device0->getSubscriptionInterface();
ProvidesDataPoolSubscriptionIF *subscriptionIF = device0->getSubscriptionInterface();
if (subscriptionIF != nullptr) {
/* For DEVICE_0, we only subscribe for notifications */
subscriptionIF->subscribeForSetUpdateMessage(td::TEST_SET_ID, getObjectId(),
getCommandQueue(), false);
subscriptionIF->subscribeForVariableUpdateMessage(
td::PoolIds::TEST_UINT8_ID, getObjectId(), getCommandQueue(), false);
subscriptionIF->subscribeForSetUpdateMessage(td::TEST_SET_ID, getObjectId(), getCommandQueue(),
false);
subscriptionIF->subscribeForVariableUpdateMessage(td::PoolIds::TEST_UINT8_ID, getObjectId(),
getCommandQueue(), false);
}
HasLocalDataPoolIF *device1 =
ObjectManager::instance()->get<HasLocalDataPoolIF>(
deviceDataset0.getCreatorObjectId());
ObjectManager::instance()->get<HasLocalDataPoolIF>(deviceDataset0.getCreatorObjectId());
if (device1 == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning
<< "TestController::initializeAfterTaskCreation: Test device handler 1 "
"handle invalid!"
<< std::endl;
sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 1 "
"handle invalid!"
<< std::endl;
#else
sif::printWarning(
"TestController::initializeAfterTaskCreation: Test device handler 1 "
@ -112,26 +107,22 @@ ReturnValue_t FsfwTestController::initializeAfterTaskCreation() {
subscriptionIF = device1->getSubscriptionInterface();
if (subscriptionIF != nullptr) {
/* For DEVICE_1, we will subscribe for snapshots */
subscriptionIF->subscribeForSetUpdateMessage(td::TEST_SET_ID, getObjectId(),
getCommandQueue(), true);
subscriptionIF->subscribeForVariableUpdateMessage(
td::PoolIds::TEST_UINT8_ID, getObjectId(), getCommandQueue(), true);
subscriptionIF->subscribeForSetUpdateMessage(td::TEST_SET_ID, getObjectId(), getCommandQueue(),
true);
subscriptionIF->subscribeForVariableUpdateMessage(td::PoolIds::TEST_UINT8_ID, getObjectId(),
getCommandQueue(), true);
}
return result;
}
LocalPoolDataSetBase *FsfwTestController::getDataSetHandle(sid_t sid) {
return nullptr;
}
LocalPoolDataSetBase *FsfwTestController::getDataSetHandle(sid_t sid) { return nullptr; }
ReturnValue_t FsfwTestController::checkModeCommand(Mode_t mode,
Submode_t submode,
ReturnValue_t FsfwTestController::checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) {
return HasReturnvaluesIF::RETURN_OK;
}
void FsfwTestController::handleChangedDataset(sid_t sid,
store_address_t storeId,
void FsfwTestController::handleChangedDataset(sid_t sid, store_address_t storeId,
bool *clearMessage) {
using namespace std;
@ -146,9 +137,8 @@ void FsfwTestController::handleChangedDataset(sid_t sid,
sif::info << "FsfwTestController::handleChangedDataset: " << printout
<< " update"
"from object ID "
<< setw(8) << setfill('0') << hex << sid.objectId
<< " and set ID " << sid.ownerSetId << dec << setfill(' ')
<< endl;
<< setw(8) << setfill('0') << hex << sid.objectId << " and set ID " << sid.ownerSetId
<< dec << setfill(' ') << endl;
#else
sif::printInfo(
"FsfwTestController::handleChangedPoolVariable: %s update from"
@ -164,11 +154,11 @@ void FsfwTestController::handleChangedDataset(sid_t sid,
floatVec[1] = deviceDataset0.testFloat3Vec.value[1];
floatVec[2] = deviceDataset0.testFloat3Vec.value[2];
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Current float vector (3) values: [" << floatVec[0] << ", "
<< floatVec[1] << ", " << floatVec[2] << "]" << std::endl;
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]);
sif::printInfo("Current float vector (3) values: [%f, %f, %f]\n", floatVec[0], floatVec[1],
floatVec[2]);
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
}
}
@ -182,8 +172,7 @@ void FsfwTestController::handleChangedDataset(sid_t sid,
}
}
void FsfwTestController::handleChangedPoolVariable(gp_id_t globPoolId,
store_address_t storeId,
void FsfwTestController::handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId,
bool *clearMessage) {
using namespace std;
@ -199,14 +188,14 @@ void FsfwTestController::handleChangedPoolVariable(gp_id_t globPoolId,
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;
<< 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);
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 == store_address_t::invalid()) {
@ -214,8 +203,7 @@ void FsfwTestController::handleChangedPoolVariable(gp_id_t globPoolId,
PoolReadGuard readHelper(&deviceDataset0.testUint8Var);
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Current test variable 0 (UINT8) value: "
<< static_cast<int>(deviceDataset0.testUint8Var.value)
<< std::endl;
<< static_cast<int>(deviceDataset0.testUint8Var.value) << std::endl;
#else
sif::printInfo("Current test variable 0 (UINT8) value %d\n",
deviceDataset0.testUint8Var.value);

View File

@ -5,9 +5,9 @@
#include "fsfw_tests/integration/controller/TestController.h"
class FsfwTestController : public TestController {
public:
FsfwTestController(object_id_t objectId, object_id_t device0,
object_id_t device1, uint8_t verboseLevel = 0);
public:
FsfwTestController(object_id_t objectId, object_id_t device0, object_id_t device1,
uint8_t verboseLevel = 0);
virtual ~FsfwTestController();
ReturnValue_t handleCommandMessage(CommandMessage *message) override;
@ -16,7 +16,7 @@ public:
*/
void performControlOperation() override;
private:
private:
object_id_t device0Id;
object_id_t device1Id;
testdevice::TestDataSet deviceDataset0;
@ -31,13 +31,11 @@ private:
TraceTypes currentTraceType = TraceTypes::NONE;
ReturnValue_t initializeAfterTaskCreation() override;
void handleChangedDataset(sid_t sid, store_address_t storeId,
bool *clearMessage) override;
void handleChangedDataset(sid_t sid, store_address_t storeId, bool *clearMessage) override;
void handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId,
bool *clearMessage) override;
ReturnValue_t
initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode) override;

View File

@ -40,34 +40,29 @@ void ObjectFactory::produceGenericObjects() {
new EventManager(objects::EVENT_MANAGER);
new HealthTable(objects::HEALTH_TABLE);
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
auto* stamperAndReader = new CdsShortTimeStamper(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,
ccsdsDistrib);
auto *ccsdsDistrib = new CcsdsDistributor(apid::APID, objects::CCSDS_DISTRIBUTOR);
new PusDistributor(apid::APID, objects::PUS_DISTRIBUTOR, ccsdsDistrib);
new TmFunnel(*stamperAndReader, objects::TM_FUNNEL);
#endif /* OBSW_ADD_CORE_COMPONENTS == 1 */
/* PUS stack */
#if OBSW_ADD_PUS_STACK == 1
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION,
apid::APID, pus::PUS_SERVICE_1,
objects::TM_FUNNEL, 5);
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, apid::APID,
pus::PUS_SERVICE_2, 3, 10);
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::APID,
pus::PUS_SERVICE_3);
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(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);
new Service1TelecommandVerification(objects::PUS_SERVICE_1_VERIFICATION, apid::APID,
pus::PUS_SERVICE_1, objects::TM_FUNNEL, 5);
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, apid::APID, pus::PUS_SERVICE_2, 3,
10);
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::APID, pus::PUS_SERVICE_3);
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(
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>(
PsbParams(objects::PUS_SERVICE_11_TC_SCHEDULER, apid::APID, pus::PUS_SERVICE_11),
@ -100,22 +95,17 @@ void ObjectFactory::produceGenericObjects() {
/* Demo device handler object */
size_t expectedMaxReplyLen = 64;
CookieIF *testCookie =
new TestCookie(static_cast<address_t>(testdevice::DeviceIndex::DEVICE_0),
expectedMaxReplyLen);
CookieIF *testCookie = new TestCookie(static_cast<address_t>(testdevice::DeviceIndex::DEVICE_0),
expectedMaxReplyLen);
new TestEchoComIF(objects::TEST_ECHO_COM_IF);
new TestDevice(objects::TEST_DEVICE_HANDLER_0, objects::TEST_ECHO_COM_IF,
testCookie, testdevice::DeviceIndex::DEVICE_0,
enableInfoPrintout);
testCookie =
new TestCookie(static_cast<address_t>(testdevice::DeviceIndex::DEVICE_1),
expectedMaxReplyLen);
new TestDevice(objects::TEST_DEVICE_HANDLER_1, objects::TEST_ECHO_COM_IF,
testCookie, testdevice::DeviceIndex::DEVICE_1,
enableInfoPrintout);
new TestDevice(objects::TEST_DEVICE_HANDLER_0, objects::TEST_ECHO_COM_IF, testCookie,
testdevice::DeviceIndex::DEVICE_0, enableInfoPrintout);
testCookie = new TestCookie(static_cast<address_t>(testdevice::DeviceIndex::DEVICE_1),
expectedMaxReplyLen);
new TestDevice(objects::TEST_DEVICE_HANDLER_1, objects::TEST_ECHO_COM_IF, testCookie,
testdevice::DeviceIndex::DEVICE_1, enableInfoPrintout);
new TestAssembly(objects::TEST_ASSEMBLY, objects::NO_OBJECT,
objects::TEST_DEVICE_HANDLER_0,
new TestAssembly(objects::TEST_ASSEMBLY, objects::NO_OBJECT, objects::TEST_DEVICE_HANDLER_0,
objects::TEST_DEVICE_HANDLER_1);
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */

View File

@ -11,6 +11,6 @@ namespace ObjectFactory {
*/
void produceGenericObjects();
} // namespace ObjectFactory
} // namespace ObjectFactory
#endif /* MISSION_CORE_GENERICFACTORY_H_ */

View File

@ -11,11 +11,11 @@
#include "objects/systemObjectList.h"
FsfwExampleTask::FsfwExampleTask(object_id_t objectId)
: SystemObject(objectId), poolManager(this, nullptr), demoSet(this),
monitor(objectId, MONITOR_ID,
gp_id_t(objectId, FsfwDemoSet::VARIABLE_LIMIT), 30, 10) {
commandQueue = QueueFactory::instance()->createMessageQueue(
10, CommandMessage::MAX_MESSAGE_SIZE);
: SystemObject(objectId),
poolManager(this, nullptr),
demoSet(this),
monitor(objectId, MONITOR_ID, gp_id_t(objectId, FsfwDemoSet::VARIABLE_LIMIT), 30, 10) {
commandQueue = QueueFactory::instance()->createMessageQueue(10, CommandMessage::MAX_MESSAGE_SIZE);
}
FsfwExampleTask::~FsfwExampleTask() {}
@ -47,45 +47,43 @@ ReturnValue_t FsfwExampleTask::performOperation(uint8_t operationCode) {
object_id_t FsfwExampleTask::getNextRecipient() {
switch (this->getObjectId()) {
case (objects::TEST_DUMMY_1): {
return objects::TEST_DUMMY_2;
}
case (objects::TEST_DUMMY_2): {
return objects::TEST_DUMMY_3;
}
case (objects::TEST_DUMMY_3): {
return objects::TEST_DUMMY_1;
}
default:
return objects::TEST_DUMMY_1;
case (objects::TEST_DUMMY_1): {
return objects::TEST_DUMMY_2;
}
case (objects::TEST_DUMMY_2): {
return objects::TEST_DUMMY_3;
}
case (objects::TEST_DUMMY_3): {
return objects::TEST_DUMMY_1;
}
default:
return objects::TEST_DUMMY_1;
}
}
object_id_t FsfwExampleTask::getSender() {
switch (this->getObjectId()) {
case (objects::TEST_DUMMY_1): {
return objects::TEST_DUMMY_3;
}
case (objects::TEST_DUMMY_2): {
return objects::TEST_DUMMY_1;
}
case (objects::TEST_DUMMY_3): {
return objects::TEST_DUMMY_2;
}
default:
return objects::TEST_DUMMY_1;
case (objects::TEST_DUMMY_1): {
return objects::TEST_DUMMY_3;
}
case (objects::TEST_DUMMY_2): {
return objects::TEST_DUMMY_1;
}
case (objects::TEST_DUMMY_3): {
return objects::TEST_DUMMY_2;
}
default:
return objects::TEST_DUMMY_1;
}
}
ReturnValue_t FsfwExampleTask::initialize() {
// Get the dataset of the sender. Will be cached for later checks.
object_id_t sender = getSender();
HasLocalDataPoolIF *senderIF =
ObjectManager::instance()->get<HasLocalDataPoolIF>(sender);
HasLocalDataPoolIF *senderIF = ObjectManager::instance()->get<HasLocalDataPoolIF>(sender);
if (senderIF == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::initialize: Sender object invalid!"
<< std::endl;
sif::error << "FsfwDemoTask::initialize: Sender object invalid!" << std::endl;
#else
sif::printError("FsfwDemoTask::initialize: Sender object invalid!\n");
#endif
@ -97,8 +95,7 @@ ReturnValue_t FsfwExampleTask::initialize() {
senderSet = new FsfwDemoSet(senderIF);
if (senderSet == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "FsfwDemoTask::initialize: Sender dataset invalid!"
<< std::endl;
sif::error << "FsfwDemoTask::initialize: Sender dataset invalid!" << std::endl;
#else
sif::printError("FsfwDemoTask::initialize: Sender dataset invalid!\n");
#endif
@ -111,45 +108,31 @@ ReturnValue_t FsfwExampleTask::initializeAfterTaskCreation() {
return poolManager.initializeAfterTaskCreation();
}
object_id_t FsfwExampleTask::getObjectId() const {
return SystemObject::getObjectId();
}
object_id_t FsfwExampleTask::getObjectId() const { return SystemObject::getObjectId(); }
MessageQueueId_t FsfwExampleTask::getMessageQueueId() {
return commandQueue->getId();
}
MessageQueueId_t FsfwExampleTask::getMessageQueueId() { return commandQueue->getId(); }
void FsfwExampleTask::setTaskIF(PeriodicTaskIF *task) { this->task = task; }
LocalPoolDataSetBase *FsfwExampleTask::getDataSetHandle(sid_t sid) {
return &demoSet;
}
LocalPoolDataSetBase *FsfwExampleTask::getDataSetHandle(sid_t sid) { return &demoSet; }
uint32_t FsfwExampleTask::getPeriodicOperationFrequency() const {
return task->getPeriodMs();
}
uint32_t FsfwExampleTask::getPeriodicOperationFrequency() const { return task->getPeriodMs(); }
ReturnValue_t
FsfwExampleTask::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE,
new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE_LIMIT,
new PoolEntry<uint16_t>({0}));
ReturnValue_t FsfwExampleTask::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) {
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE, new PoolEntry<uint32_t>({0}));
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE_LIMIT, new PoolEntry<uint16_t>({0}));
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t FsfwExampleTask::performMonitoringDemo() {
ReturnValue_t result =
demoSet.variableLimit.read(MutexIF::TimeoutType::WAITING, 20);
ReturnValue_t result = demoSet.variableLimit.read(MutexIF::TimeoutType::WAITING, 20);
if (result != HasReturnvaluesIF::RETURN_OK) {
/* Configuration error */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "DummyObject::performOperation: Could not read variableLimit!"
<< std::endl;
sif::error << "DummyObject::performOperation: Could not read variableLimit!" << std::endl;
#else
sif::printError(
"DummyObject::performOperation: Could not read variableLimit!\n");
sif::printError("DummyObject::performOperation: Could not read variableLimit!\n");
#endif
return result;
}
@ -166,17 +149,13 @@ ReturnValue_t FsfwExampleTask::performMonitoringDemo() {
ReturnValue_t FsfwExampleTask::performSendOperation() {
object_id_t nextRecipient = getNextRecipient();
FsfwExampleTask *target =
ObjectManager::instance()->get<FsfwExampleTask>(nextRecipient);
FsfwExampleTask *target = ObjectManager::instance()->get<FsfwExampleTask>(nextRecipient);
if (target == nullptr) {
/* Configuration error */
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error
<< "DummyObject::performOperation: Next recipient does not exist!"
<< std::endl;
sif::error << "DummyObject::performOperation: Next recipient does not exist!" << std::endl;
#else
sif::printError(
"DummyObject::performOperation: Next recipient does not exist!\n");
sif::printError("DummyObject::performOperation: Next recipient does not exist!\n");
#endif
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -187,30 +166,23 @@ 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) {
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;
sif::error << "FsfwDemoTask::performSendOperation: Send failed with " << result << std::endl;
#else
sif::printError(
"FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
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) {
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;
sif::error << "FsfwDemoTask::performSendOperation: Send failed with " << result << std::endl;
#else
sif::printError(
"FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
sif::printError("FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
#endif
}
@ -225,8 +197,7 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
while (result != MessageQueueIF::EMPTY) {
CommandMessage receivedMessage;
result = commandQueue->receiveMessage(&receivedMessage);
if (result != HasReturnvaluesIF::RETURN_OK &&
result != MessageQueueIF::EMPTY) {
if (result != HasReturnvaluesIF::RETURN_OK && result != MessageQueueIF::EMPTY) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Receive failed with " << result << std::endl;
#endif
@ -236,9 +207,8 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
#if FSFW_CPP_OSTREAM_ENABLED == 1
#if OBSW_VERBOSE_LEVEL >= 2
sif::debug << "Message Received by " << getObjectId() << " from Queue "
<< receivedMessage.getSender() << " ObjectId "
<< receivedMessage.getParameter() << " Queue "
<< receivedMessage.getParameter2() << std::endl;
<< receivedMessage.getSender() << " ObjectId " << receivedMessage.getParameter()
<< " Queue " << receivedMessage.getParameter2() << std::endl;
#endif
#endif
@ -252,13 +222,11 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
}
if (senderSet->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()
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
}
}
@ -266,10 +234,6 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
return result;
}
MessageQueueId_t FsfwExampleTask::getCommandQueue() const {
return commandQueue->getId();
}
MessageQueueId_t FsfwExampleTask::getCommandQueue() const { return commandQueue->getId(); }
LocalDataPoolManager *FsfwExampleTask::getHkManagerHandle() {
return &poolManager;
}
LocalDataPoolManager *FsfwExampleTask::getHkManagerHandle() { return &poolManager; }

View File

@ -24,10 +24,8 @@ class PeriodicTaskIF;
* value directly from the sender via the local data pool interface.
* If the timing is set up correctly, the values will always be the same.
*/
class FsfwExampleTask : public ExecutableObjectIF,
public SystemObject,
public HasLocalDataPoolIF {
public:
class FsfwExampleTask : public ExecutableObjectIF, public SystemObject, public HasLocalDataPoolIF {
public:
enum OpCodes { SEND_RAND_NUM, RECEIVE_RAND_NUM, DELAY_SHORT };
static constexpr uint8_t MONITOR_ID = 2;
@ -80,7 +78,7 @@ public:
MessageQueueId_t getMessageQueueId();
private:
private:
LocalDataPoolManager poolManager;
FsfwDemoSet *senderSet = nullptr;
FsfwDemoSet demoSet;
@ -92,9 +90,8 @@ private:
MessageQueueId_t getCommandQueue() const override;
LocalPoolDataSetBase *getDataSetHandle(sid_t sid) override;
uint32_t getPeriodicOperationFrequency() const override;
ReturnValue_t
initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
ReturnValue_t initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
LocalDataPoolManager &poolManager) override;
LocalDataPoolManager *getHkManagerHandle() override;
object_id_t getNextRecipient();

View File

@ -7,9 +7,10 @@
#include <fsfw/timemanager/Stopwatch.h>
FsfwReaderTask::FsfwReaderTask(object_id_t objectId, bool enablePrintout)
: SystemObject(objectId), printoutEnabled(enablePrintout), opDivider(10),
readSet(this->getObjectId(),
gp_id_t(objects::TEST_DUMMY_1, FsfwDemoSet::PoolIds::VARIABLE),
: SystemObject(objectId),
printoutEnabled(enablePrintout),
opDivider(10),
readSet(this->getObjectId(), gp_id_t(objects::TEST_DUMMY_1, FsfwDemoSet::PoolIds::VARIABLE),
gp_id_t(objects::TEST_DUMMY_2, FsfwDemoSet::PoolIds::VARIABLE),
gp_id_t(objects::TEST_DUMMY_3, FsfwDemoSet::PoolIds::VARIABLE)) {
/* Special protection for set reading because each variable is read from a
@ -35,14 +36,12 @@ ReturnValue_t FsfwReaderTask::performOperation(uint8_t operationCode) {
#if OBSW_VERBOSE_LEVEL >= 1
if (opDivider.checkAndIncrement() and printoutEnabled) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "FsfwPeriodicTask::performOperation: Reading variables."
<< std::endl;
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("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);

View File

@ -8,14 +8,14 @@
#include "testdefinitions/demoDefinitions.h"
class FsfwReaderTask : public ExecutableObjectIF, public SystemObject {
public:
public:
FsfwReaderTask(object_id_t objectId, bool enablePrintout);
~FsfwReaderTask() override;
ReturnValue_t initializeAfterTaskCreation() override;
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
private:
private:
bool printoutEnabled = false;
PeriodicOperationDivider opDivider;
CompleteDemoReadSet readSet;

View File

@ -6,16 +6,15 @@
#include "fsfw_tests/integration/task/TestTask.h"
class FsfwTestTask : public TestTask {
public:
public:
FsfwTestTask(object_id_t objectId, bool periodicEvent);
ReturnValue_t performPeriodicAction() override;
private:
private:
bool periodicEvent = false;
static constexpr uint8_t subsystemId = SUBSYSTEM_ID::TEST_TASK_ID;
static constexpr Event TEST_EVENT =
event::makeEvent(subsystemId, 0, severity::INFO);
static constexpr Event TEST_EVENT = event::makeEvent(subsystemId, 0, severity::INFO);
};
#endif /* EXAMPLE_COMMON_EXAMPLE_TEST_FSFWTESTTASK_H_ */

View File

@ -7,12 +7,10 @@ void MutexExample::example() {
MutexIF *mutex = MutexFactory::instance()->createMutex();
MutexIF *mutex2 = MutexFactory::instance()->createMutex();
ReturnValue_t result =
mutex->lockMutex(MutexIF::TimeoutType::WAITING, 2 * 60 * 1000);
ReturnValue_t result = mutex->lockMutex(MutexIF::TimeoutType::WAITING, 2 * 60 * 1000);
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Lock Failed with " << result
<< std::endl;
sif::error << "MutexExample::example: Lock Failed with " << result << std::endl;
#else
sif::printError("MutexExample::example: Lock Failed with %hu\n", result);
#endif
@ -21,8 +19,7 @@ void MutexExample::example() {
result = mutex2->lockMutex(MutexIF::TimeoutType::BLOCKING);
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Lock Failed with " << result
<< std::endl;
sif::error << "MutexExample::example: Lock Failed with " << result << std::endl;
#else
sif::printError("MutexExample::example: Lock Failed with %hu\n", result);
#endif
@ -31,8 +28,7 @@ void MutexExample::example() {
result = mutex->unlockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Unlock Failed with " << result
<< std::endl;
sif::error << "MutexExample::example: Unlock Failed with " << result << std::endl;
#else
sif::printError("MutexExample::example: Unlock Failed with %hu\n", result);
#endif
@ -41,8 +37,7 @@ void MutexExample::example() {
result = mutex2->unlockMutex();
if (result != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "MutexExample::example: Unlock Failed with " << result
<< std::endl;
sif::error << "MutexExample::example: Unlock Failed with " << result << std::endl;
#else
sif::printError("MutexExample::example: Unlock Failed with %hu\n", result);
#endif

View File

@ -15,8 +15,7 @@
#include "fsfw/timemanager/Clock.h"
#define __FILENAME_REL__ (((const char *)__FILE__ + SOURCE_PATH_SIZE))
#define __FILENAME__ \
(strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
void fmtTests();
@ -29,34 +28,26 @@ 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
};
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 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};
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])));
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 {
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);
@ -64,17 +55,16 @@ size_t logTraced(LogLevel level, const char *file, unsigned int line,
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...));
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...));
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;
}
@ -88,8 +78,7 @@ size_t logTraced(LogLevel level, const char *file, unsigned int line,
}
template <typename... T>
size_t log(LogLevel level, bool timed, fmt::format_string<T...> fmt,
T &&...args) noexcept {
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);
@ -98,9 +87,8 @@ size_t log(LogLevel level, bool timed, fmt::format_string<T...> fmt,
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...));
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()));
@ -128,56 +116,47 @@ 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) {
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) {
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) {
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) {
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) {
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
} // 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_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_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_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_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_LOGE(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGET(format, ...) \
fdebug_t(__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
#endif // FSFW_EXAMPLE_HOSTED_TESTFMT_H

View File

@ -12,22 +12,21 @@
* pool variables (for read and write access respectively).
*/
class FsfwDemoSet : public StaticLocalDataSet<3> {
public:
public:
static constexpr uint32_t DEMO_SET_ID = 0;
enum PoolIds { VARIABLE, VARIABLE_LIMIT };
FsfwDemoSet(HasLocalDataPoolIF *hkOwner)
: StaticLocalDataSet(hkOwner, DEMO_SET_ID) {}
FsfwDemoSet(HasLocalDataPoolIF *hkOwner) : StaticLocalDataSet(hkOwner, DEMO_SET_ID) {}
lp_var_t<uint32_t> variableRead = lp_var_t<uint32_t>(
sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_READ);
lp_var_t<uint32_t> variableWrite = lp_var_t<uint32_t>(
sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_WRITE);
lp_var_t<uint32_t> variableRead =
lp_var_t<uint32_t>(sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_READ);
lp_var_t<uint32_t> variableWrite =
lp_var_t<uint32_t>(sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_WRITE);
lp_var_t<uint16_t> variableLimit =
lp_var_t<uint16_t>(sid.objectId, PoolIds::VARIABLE_LIMIT, this);
private:
private:
};
/**
@ -36,11 +35,10 @@ private:
* which reads multiple sensor values at once.
*/
class CompleteDemoReadSet : public StaticLocalDataSet<3> {
public:
public:
static constexpr uint32_t DEMO_SET_ID = 0;
CompleteDemoReadSet(object_id_t owner, gp_id_t variable1, gp_id_t variable2,
gp_id_t variable3)
CompleteDemoReadSet(object_id_t owner, gp_id_t variable1, gp_id_t variable2, gp_id_t variable3)
: StaticLocalDataSet(sid_t(owner, DEMO_SET_ID)),
variable1(variable1, this, pool_rwm_t::VAR_READ),
variable2(variable2, this, pool_rwm_t::VAR_READ),
@ -50,7 +48,7 @@ public:
lp_var_t<uint32_t> variable2;
lp_var_t<uint32_t> variable3;
private:
private:
};
#endif /* MISSION_DEMO_DEMODEFINITIONS_H_ */

View File

@ -9,7 +9,7 @@
#define MISSION_UTILITY_PUSPACKETCREATOR_H_
class PusPacketCreator {
public:
public:
static void createPusPacketAndPrint();
};

View File

@ -8,15 +8,14 @@ namespace task {
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;
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
} // namespace task
#endif /* MISSION_UTILITY_TASKCREATION_H_ */

View File

@ -1,18 +1,19 @@
#include "TmFunnel.h"
#include <fsfw/ipc/QueueFactory.h>
#include "fsfw/tmtcpacket/pus/tm.h"
#include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tmtcpacket/pus/tm.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(TimeReaderIF& timeReader, object_id_t objectId, uint32_t 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);
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
MessageQueueMessage::MAX_MESSAGE_SIZE);
storageQueue = QueueFactory::instance()->createMessageQueue(
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE);
}
@ -45,14 +46,13 @@ ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) {
uint8_t *packetData = nullptr;
size_t size = 0;
ReturnValue_t result =
tmPool->modifyData(