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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -7,9 +7,10 @@
#include <fsfw/timemanager/Stopwatch.h> #include <fsfw/timemanager/Stopwatch.h>
FsfwReaderTask::FsfwReaderTask(object_id_t objectId, bool enablePrintout) FsfwReaderTask::FsfwReaderTask(object_id_t objectId, bool enablePrintout)
: SystemObject(objectId), printoutEnabled(enablePrintout), opDivider(10), : SystemObject(objectId),
readSet(this->getObjectId(), printoutEnabled(enablePrintout),
gp_id_t(objects::TEST_DUMMY_1, FsfwDemoSet::PoolIds::VARIABLE), 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_2, FsfwDemoSet::PoolIds::VARIABLE),
gp_id_t(objects::TEST_DUMMY_3, 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 /* 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 OBSW_VERBOSE_LEVEL >= 1
if (opDivider.checkAndIncrement() and printoutEnabled) { if (opDivider.checkAndIncrement() and printoutEnabled) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "FsfwPeriodicTask::performOperation: Reading variables." sif::info << "FsfwPeriodicTask::performOperation: Reading variables." << std::endl;
<< std::endl;
sif::info << "Variable read from demo object 1: " << variable1 << 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 2: " << variable2 << std::endl;
sif::info << "Variable read from demo object 3: " << variable3 << std::endl; sif::info << "Variable read from demo object 3: " << variable3 << std::endl;
#else #else
sif::printInfo( sif::printInfo("FsfwPeriodicTask::performOperation: Reading variables.\n\r");
"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 1: %d\n\r", variable1);
sif::printInfo("Variable read from demo object 2: %d\n\r", variable2); sif::printInfo("Variable read from demo object 2: %d\n\r", variable2);
sif::printInfo("Variable read from demo object 3: %d\n\r", variable3); sif::printInfo("Variable read from demo object 3: %d\n\r", variable3);

View File

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

View File

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

View File

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

View File

@ -15,8 +15,7 @@
#include "fsfw/timemanager/Clock.h" #include "fsfw/timemanager/Clock.h"
#define __FILENAME_REL__ (((const char *)__FILE__ + SOURCE_PATH_SIZE)) #define __FILENAME_REL__ (((const char *)__FILE__ + SOURCE_PATH_SIZE))
#define __FILENAME__ \ #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
(strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
void fmtTests(); void fmtTests();
@ -29,34 +28,26 @@ static const char DEBUG_PREFIX[] = "DEBUG";
static const char WARNING_PREFIX[] = "WARNING"; static const char WARNING_PREFIX[] = "WARNING";
static const char ERROR_PREFIX[] = "ERROR"; static const char ERROR_PREFIX[] = "ERROR";
enum class LogLevel : unsigned int { enum class LogLevel : unsigned int { DEBUG = 0, INFO = 1, WARNING = 2, ERROR = 3 };
DEBUG = 0,
INFO = 1,
WARNING = 2,
ERROR = 3
};
static const char *PREFIX_ARR[4] = {DEBUG_PREFIX, INFO_PREFIX, WARNING_PREFIX, static const char *PREFIX_ARR[4] = {DEBUG_PREFIX, INFO_PREFIX, WARNING_PREFIX, ERROR_PREFIX};
ERROR_PREFIX};
static const std::array<fmt::color, 4> LOG_COLOR_ARR = { 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::deep_sky_blue, fmt::color::forest_green, fmt::color::orange_red, fmt::color::red};
fmt::color::red};
static MutexIF *PRINT_MUTEX = MutexFactory::instance()->createMutex(); static MutexIF *PRINT_MUTEX = MutexFactory::instance()->createMutex();
static size_t writeTypePrefix(LogLevel level) { static size_t writeTypePrefix(LogLevel level) {
auto idx = static_cast<unsigned int>(level); auto idx = static_cast<unsigned int>(level);
const auto result = fmt::format_to_n( const auto result =
PRINT_BUF.begin(), PRINT_BUF.size() - 1, fmt::format_to_n(PRINT_BUF.begin(), PRINT_BUF.size() - 1,
fmt::runtime(fmt::format(fg(LOG_COLOR_ARR[idx]), PREFIX_ARR[idx]))); fmt::runtime(fmt::format(fg(LOG_COLOR_ARR[idx]), PREFIX_ARR[idx])));
return result.size; return result.size;
} }
template <typename... T> template <typename... T>
size_t logTraced(LogLevel level, const char *file, unsigned int line, size_t logTraced(LogLevel level, const char *file, unsigned int line, bool timed,
bool timed, fmt::format_string<T...> fmt, fmt::format_string<T...> fmt, T &&...args) noexcept {
T &&...args) noexcept {
try { try {
MutexGuard mg(PRINT_MUTEX); MutexGuard mg(PRINT_MUTEX);
size_t bufPos = writeTypePrefix(level); size_t bufPos = writeTypePrefix(level);
@ -64,16 +55,15 @@ size_t logTraced(LogLevel level, const char *file, unsigned int line,
if (timed) { if (timed) {
Clock::TimeOfDay_t logTime; Clock::TimeOfDay_t logTime;
Clock::getDateAndTime(&logTime); Clock::getDateAndTime(&logTime);
const auto result = const auto result = fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos,
fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos, " | {}[l.{}] | {:02}:{:02}:{:02}.{:03} | {}", file, line,
" | {}[l.{}] | {:02}:{:02}:{:02}.{:03} | {}", file, logTime.hour, logTime.minute, logTime.second,
line, logTime.hour, logTime.minute, logTime.second,
logTime.usecond / 1000, fmt::format(fmt, args...)); logTime.usecond / 1000, fmt::format(fmt, args...));
*result.out = '\0'; *result.out = '\0';
bufPos += result.size; bufPos += result.size;
} else { } else {
const auto result = fmt::format_to_n( const auto result =
currentIter, PRINT_BUF.size() - 1 - bufPos, " | {}[l.{}] | {}", file, fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos, " | {}[l.{}] | {}", file,
line, fmt::format(fmt, args...)); line, fmt::format(fmt, args...));
*result.out = '\0'; *result.out = '\0';
bufPos += result.size; bufPos += result.size;
@ -88,8 +78,7 @@ size_t logTraced(LogLevel level, const char *file, unsigned int line,
} }
template <typename... T> template <typename... T>
size_t log(LogLevel level, bool timed, fmt::format_string<T...> fmt, size_t log(LogLevel level, bool timed, fmt::format_string<T...> fmt, T &&...args) noexcept {
T &&...args) noexcept {
try { try {
MutexGuard mg(PRINT_MUTEX); MutexGuard mg(PRINT_MUTEX);
size_t bufPos = writeTypePrefix(level); 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::TimeOfDay_t logTime;
Clock::getDateAndTime(&logTime); Clock::getDateAndTime(&logTime);
const auto result = fmt::format_to_n( const auto result = fmt::format_to_n(
currentIter, PRINT_BUF.size() - bufPos, currentIter, PRINT_BUF.size() - bufPos, " | {:02}:{:02}:{:02}.{:03} | {}", logTime.hour,
" | {:02}:{:02}:{:02}.{:03} | {}", logTime.hour, logTime.minute, logTime.minute, logTime.second, logTime.usecond / 1000, fmt::format(fmt, args...));
logTime.second, logTime.usecond / 1000, fmt::format(fmt, args...));
bufPos += result.size; bufPos += result.size;
} }
fmt::print(fmt::runtime(PRINT_BUF.data())); fmt::print(fmt::runtime(PRINT_BUF.data()));
@ -128,31 +116,28 @@ void finfo_t(fmt::format_string<T...> fmt, T &&...args) {
log(LogLevel::INFO, true, fmt, 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...); log(LogLevel::INFO, false, fmt, args...);
} }
template <typename... T> template <typename... T>
void fwarning(const char *file, unsigned int line, fmt::format_string<T...> fmt, void fwarning(const char *file, unsigned int line, fmt::format_string<T...> fmt, T &&...args) {
T &&...args) {
logTraced(LogLevel::WARNING, file, line, false, fmt, args...); logTraced(LogLevel::WARNING, file, line, false, fmt, args...);
} }
template <typename... T> template <typename... T>
void fwarning_t(const char *file, unsigned int line, void fwarning_t(const char *file, unsigned int line, fmt::format_string<T...> fmt, T &&...args) {
fmt::format_string<T...> fmt, T &&...args) {
logTraced(LogLevel::WARNING, file, line, true, fmt, args...); logTraced(LogLevel::WARNING, file, line, true, fmt, args...);
} }
template <typename... T> template <typename... T>
void ferror(const char *file, unsigned int line, fmt::format_string<T...> fmt, void ferror(const char *file, unsigned int line, fmt::format_string<T...> fmt, T &&...args) {
T &&...args) {
logTraced(LogLevel::ERROR, file, line, false, fmt, args...); logTraced(LogLevel::ERROR, file, line, false, fmt, args...);
} }
template <typename... T> template <typename... T>
void ferror_t(const char *file, unsigned int line, fmt::format_string<T...> fmt, void ferror_t(const char *file, unsigned int line, fmt::format_string<T...> fmt, T &&...args) {
T &&...args) {
logTraced(LogLevel::ERROR, file, line, true, fmt, args...); logTraced(LogLevel::ERROR, file, line, true, fmt, args...);
} }
@ -162,22 +147,16 @@ void ferror_t(const char *file, unsigned int line, fmt::format_string<T...> fmt,
#define FSFW_LOGIT(format, ...) finfo_t(FMT_STRING(format), __VA_ARGS__) #define FSFW_LOGIT(format, ...) finfo_t(FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGD(format, ...) \ #define FSFW_LOGD(format, ...) sif::fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
sif::fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGDT(format, ...) \ #define FSFW_LOGDT(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGW(format, ...) \ #define FSFW_LOGW(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGWT(format, ...) \ #define FSFW_LOGWT(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGE(format, ...) \ #define FSFW_LOGE(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
#define FSFW_LOGET(format, ...) \ #define FSFW_LOGET(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
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). * pool variables (for read and write access respectively).
*/ */
class FsfwDemoSet : public StaticLocalDataSet<3> { class FsfwDemoSet : public StaticLocalDataSet<3> {
public: public:
static constexpr uint32_t DEMO_SET_ID = 0; static constexpr uint32_t DEMO_SET_ID = 0;
enum PoolIds { VARIABLE, VARIABLE_LIMIT }; enum PoolIds { VARIABLE, VARIABLE_LIMIT };
FsfwDemoSet(HasLocalDataPoolIF *hkOwner) FsfwDemoSet(HasLocalDataPoolIF *hkOwner) : StaticLocalDataSet(hkOwner, DEMO_SET_ID) {}
: StaticLocalDataSet(hkOwner, DEMO_SET_ID) {}
lp_var_t<uint32_t> variableRead = lp_var_t<uint32_t>( lp_var_t<uint32_t> variableRead =
sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_READ); 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>( lp_var_t<uint32_t> variableWrite =
sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_WRITE); 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> variableLimit =
lp_var_t<uint16_t>(sid.objectId, PoolIds::VARIABLE_LIMIT, this); 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. * which reads multiple sensor values at once.
*/ */
class CompleteDemoReadSet : public StaticLocalDataSet<3> { class CompleteDemoReadSet : public StaticLocalDataSet<3> {
public: public:
static constexpr uint32_t DEMO_SET_ID = 0; static constexpr uint32_t DEMO_SET_ID = 0;
CompleteDemoReadSet(object_id_t owner, gp_id_t variable1, gp_id_t variable2, CompleteDemoReadSet(object_id_t owner, gp_id_t variable1, gp_id_t variable2, gp_id_t variable3)
gp_id_t variable3)
: StaticLocalDataSet(sid_t(owner, DEMO_SET_ID)), : StaticLocalDataSet(sid_t(owner, DEMO_SET_ID)),
variable1(variable1, this, pool_rwm_t::VAR_READ), variable1(variable1, this, pool_rwm_t::VAR_READ),
variable2(variable2, 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> variable2;
lp_var_t<uint32_t> variable3; lp_var_t<uint32_t> variable3;
private: private:
}; };
#endif /* MISSION_DEMO_DEMODEFINITIONS_H_ */ #endif /* MISSION_DEMO_DEMODEFINITIONS_H_ */

View File

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

View File

@ -8,9 +8,8 @@ namespace task {
void printInitError(const char *objName, object_id_t objectId) { void printInitError(const char *objName, object_id_t objectId) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "InitMission: Adding object " << objName << "(" << std::setw(8) sif::error << "InitMission: Adding object " << objName << "(" << std::setw(8) << std::setfill('0')
<< std::setfill('0') << std::hex << objectId << std::dec << std::hex << objectId << std::dec << ") failed." << std::endl;
<< ") failed." << std::endl;
#else #else
sif::printError("InitMission: Adding object %s (0x%08x) failed.\n", objName, sif::printError("InitMission: Adding object %s (0x%08x) failed.\n", objName,
static_cast<unsigned int>(objectId)); static_cast<unsigned int>(objectId));

View File

@ -1,18 +1,19 @@
#include "TmFunnel.h" #include "TmFunnel.h"
#include <fsfw/ipc/QueueFactory.h> #include <fsfw/ipc/QueueFactory.h>
#include "fsfw/tmtcpacket/pus/tm.h"
#include <fsfw/objectmanager/ObjectManager.h> #include <fsfw/objectmanager/ObjectManager.h>
#include <fsfw/serviceinterface/ServiceInterface.h> #include <fsfw/serviceinterface/ServiceInterface.h>
#include <fsfw/tmtcpacket/pus/tm.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::downlinkDestination = objects::NO_OBJECT;
object_id_t TmFunnel::storageDestination = 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) { : SystemObject(objectId), timeReader(timeReader), messageDepth(messageDepth) {
tmQueue = QueueFactory::instance()->createMessageQueue( tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE); MessageQueueMessage::MAX_MESSAGE_SIZE);
storageQueue = QueueFactory::instance()->createMessageQueue( storageQueue = QueueFactory::instance()->createMessageQueue(
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE); messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE);
} }
@ -45,14 +46,13 @@ ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) { ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) {
uint8_t *packetData = nullptr; uint8_t *packetData = nullptr;
size_t size = 0; size_t size = 0;
ReturnValue_t result = ReturnValue_t result = tmPool->modifyData(message->getStorageId(), &packetData, &size);
tmPool->modifyData(message->getStorageId(), &packetData, &size);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
PusTmZeroCopyWriter packet(timeReader, packetData, size); PusTmZeroCopyWriter packet(timeReader, packetData, size);
result = packet.parseDataWithoutCrcCheck(); result = packet.parseDataWithoutCrcCheck();
if(result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
packet.setSequenceCount(sourceSequenceCount++); packet.setSequenceCount(sourceSequenceCount++);
@ -73,8 +73,7 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage *message) {
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
tmPool->deleteData(message->getStorageId()); tmPool->deleteData(message->getStorageId());
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::handlePacket: Error sending to storage handler" sif::error << "TmFunnel::handlePacket: Error sending to storage handler" << std::endl;
<< std::endl;
#endif #endif
return result; return result;
} }
@ -98,8 +97,7 @@ ReturnValue_t TmFunnel::initialize() {
ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination); ObjectManager::instance()->get<AcceptsTelemetryIF>(downlinkDestination);
if (tmTarget == nullptr) { if (tmTarget == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmFunnel::initialize: Downlink Destination not set." sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl;
<< std::endl;
sif::error << "Make sure the downlink destination object is set up " sif::error << "Make sure the downlink destination object is set up "
"properly and implements " "properly and implements "
"AcceptsTelemetryIF" "AcceptsTelemetryIF"
@ -114,12 +112,12 @@ ReturnValue_t TmFunnel::initialize() {
return SystemObject::initialize(); return SystemObject::initialize();
} }
AcceptsTelemetryIF *storageTarget = auto *storageTarget = ObjectManager::instance()->get<AcceptsTelemetryIF>(storageDestination);
ObjectManager::instance()->get<AcceptsTelemetryIF>(storageDestination);
if (storageTarget != nullptr) { if (storageTarget != nullptr) {
storageQueue->setDefaultDestination( storageQueue->setDefaultDestination(storageTarget->getReportReceptionQueue());
storageTarget->getReportReceptionQueue());
} }
return SystemObject::initialize(); return SystemObject::initialize();
} }
const char *TmFunnel::getName() const { return "TM Funnel"; }

View File

@ -21,26 +21,25 @@ void setStaticFrameworkObjectIds();
* @ingroup utility * @ingroup utility
* @author J. Meier * @author J. Meier
*/ */
class TmFunnel : public AcceptsTelemetryIF, class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject {
public ExecutableObjectIF,
public SystemObject {
friend void(Factory::setStaticFrameworkObjectIds)(); friend void(Factory::setStaticFrameworkObjectIds)();
public: public:
explicit TmFunnel(TimeReaderIF& timeReader, object_id_t objectId, uint32_t messageDepth = 20); explicit TmFunnel(TimeReaderIF &timeReader, object_id_t objectId, uint32_t messageDepth = 20);
const char *getName() const override;
~TmFunnel() override; ~TmFunnel() override;
MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override; MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override;
ReturnValue_t performOperation(uint8_t operationCode) override; ReturnValue_t performOperation(uint8_t operationCode) override;
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
protected: protected:
static object_id_t downlinkDestination; static object_id_t downlinkDestination;
static object_id_t storageDestination; static object_id_t storageDestination;
private: private:
uint16_t sourceSequenceCount = 0; uint16_t sourceSequenceCount = 0;
TimeReaderIF& timeReader; TimeReaderIF &timeReader;
MessageQueueIF *tmQueue = nullptr; MessageQueueIF *tmQueue = nullptr;
MessageQueueIF *storageQueue = nullptr; MessageQueueIF *storageQueue = nullptr;

View File

@ -64,36 +64,29 @@
// Days in February // Days in February
#define _UNIX_TIMESTAMP_FDAY(year) \ #define _UNIX_TIMESTAMP_FDAY(year) \
(((year) % 400) == 0UL \ (((year) % 400) == 0UL ? 29UL \
? 29UL \
: (((year) % 100) == 0UL ? 28UL : (((year) % 4) == 0UL ? 29UL : 28UL))) : (((year) % 100) == 0UL ? 28UL : (((year) % 4) == 0UL ? 29UL : 28UL)))
// Days in the year // Days in the year
#define _UNIX_TIMESTAMP_YDAY(year, month, day) \ #define _UNIX_TIMESTAMP_YDAY(year, month, day) \
(/* January */ day /* February */ + (month >= 2 ? 31UL : 0UL) /* March */ + \ (/* January */ day /* February */ + (month >= 2 ? 31UL : 0UL) /* March */ + \
(month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) /* April */ + \ (month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) /* April */ + \
(month >= 4 ? 31UL : 0UL) /* May */ + \ (month >= 4 ? 31UL : 0UL) /* May */ + (month >= 5 ? 30UL : 0UL) /* June */ + \
(month >= 5 ? 30UL : 0UL) /* June */ + \ (month >= 6 ? 31UL : 0UL) /* July */ + (month >= 7 ? 30UL : 0UL) /* August */ + \
(month >= 6 ? 31UL : 0UL) /* July */ + \ (month >= 8 ? 31UL : 0UL) /* September */ + (month >= 9 ? 31UL : 0UL) /* October */ + \
(month >= 7 ? 30UL : 0UL) /* August */ + \ (month >= 10 ? 30UL : 0UL) /* November */ + (month >= 11 ? 31UL : 0UL) /* December */ + \
(month >= 8 ? 31UL : 0UL) /* September */ + \ (month >= 12 ? 30UL : 0UL))
(month >= 9 ? 31UL : 0UL) /* October */ + \
(month >= 10 ? 30UL : 0UL) /* November */ + \
(month >= 11 ? 31UL : 0UL) /* December */ + (month >= 12 ? 30UL : 0UL))
// get the UNIX timestamp from a digits representation // get the UNIX timestamp from a digits representation
#define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \ #define _UNIX_TIMESTAMP(year, month, day, hour, minute, second) \
(/* time */ second + minute * SEC_PER_MIN + hour * SEC_PER_HOUR + \ (/* time */ second + minute * SEC_PER_MIN + hour * SEC_PER_HOUR + \
/* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * \ /* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY + \
SEC_PER_DAY + \ /* year */ (year - 1970UL) * SEC_PER_YEAR + ((year - 1969UL) / 4UL) * SEC_PER_DAY - \
/* year */ (year - 1970UL) * SEC_PER_YEAR + \ ((year - 1901UL) / 100UL) * SEC_PER_DAY + ((year - 1601UL) / 400UL) * SEC_PER_DAY)
((year - 1969UL) / 4UL) * SEC_PER_DAY - \
((year - 1901UL) / 100UL) * SEC_PER_DAY + \
((year - 1601UL) / 400UL) * SEC_PER_DAY)
// the UNIX timestamp // the UNIX timestamp
#define UNIX_TIMESTAMP \ #define UNIX_TIMESTAMP \
(_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, \ (_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, \
__TIME_HOURS__, __TIME_MINUTES__, __TIME_SECONDS__)) __TIME_MINUTES__, __TIME_SECONDS__))
#endif #endif

View File

@ -10,11 +10,9 @@ void utility::commonInitPrint(const char *const os, const char *const board) {
} }
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
std::cout << "-- FSFW Example (" << os << ") v" << FSFW_EXAMPLE_VERSION << "." std::cout << "-- FSFW Example (" << os << ") v" << FSFW_EXAMPLE_VERSION << "."
<< FSFW_EXAMPLE_SUBVERSION << "." << FSFW_EXAMPLE_REVISION << " --" << FSFW_EXAMPLE_SUBVERSION << "." << FSFW_EXAMPLE_REVISION << " --" << std::endl;
<< std::endl;
std::cout << "-- Compiled for " << board << " --" << std::endl; std::cout << "-- Compiled for " << board << " --" << std::endl;
std::cout << "-- Compiled on " << __DATE__ << " " << __TIME__ << " --" std::cout << "-- Compiled on " << __DATE__ << " " << __TIME__ << " --" << std::endl;
<< std::endl;
#else #else
printf("\n\r-- FSFW Example (%s) v%d.%d.%d --\n", os, FSFW_EXAMPLE_VERSION, printf("\n\r-- FSFW Example (%s) v%d.%d.%d --\n", os, FSFW_EXAMPLE_VERSION,
FSFW_EXAMPLE_SUBVERSION, FSFW_EXAMPLE_REVISION); FSFW_EXAMPLE_SUBVERSION, FSFW_EXAMPLE_REVISION);

View File

@ -3,8 +3,7 @@
#include "OBSWConfig.h" #include "OBSWConfig.h"
#include "stm32h7xx_nucleo.h" #include "stm32h7xx_nucleo.h"
STM32TestTask::STM32TestTask(object_id_t objectId, bool enablePrintout, STM32TestTask::STM32TestTask(object_id_t objectId, bool enablePrintout, bool blinkyLed)
bool blinkyLed)
: TestTask(objectId), blinkyLed(blinkyLed) { : TestTask(objectId), blinkyLed(blinkyLed) {
BSP_LED_Init(LED1); BSP_LED_Init(LED1);
BSP_LED_Init(LED2); BSP_LED_Init(LED2);

View File

@ -5,14 +5,13 @@
#include "fsfw_tests/integration/task/TestTask.h" #include "fsfw_tests/integration/task/TestTask.h"
class STM32TestTask : public TestTask { class STM32TestTask : public TestTask {
public: public:
STM32TestTask(object_id_t objectId, bool enablePrintout, STM32TestTask(object_id_t objectId, bool enablePrintout, bool blinkyLed = true);
bool blinkyLed = true);
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
ReturnValue_t performPeriodicAction() override; ReturnValue_t performPeriodicAction() override;
private: private:
SpiComIF *spiComIF = nullptr; SpiComIF *spiComIF = nullptr;
SpiTest *spiTest = nullptr; SpiTest *spiTest = nullptr;

View File

@ -1,6 +1,5 @@
#include "TmTcLwIpUdpBridge.h" #include "TmTcLwIpUdpBridge.h"
#include <fsfw/ipc/MutexGuard.h> #include <fsfw/ipc/MutexGuard.h>
#include <fsfw/serialize/EndianConverter.h> #include <fsfw/serialize/EndianConverter.h>
#include <fsfw/serviceinterface/ServiceInterface.h> #include <fsfw/serviceinterface/ServiceInterface.h>
@ -8,10 +7,8 @@
#include "app_ethernet.h" #include "app_ethernet.h"
#include "udp_config.h" #include "udp_config.h"
TmTcLwIpUdpBridge::TmTcLwIpUdpBridge(object_id_t objectId, TmTcLwIpUdpBridge::TmTcLwIpUdpBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor,
object_id_t ccsdsPacketDistributor, object_id_t tmStoreId, object_id_t tcStoreId)
object_id_t tmStoreId,
object_id_t tcStoreId)
: TmTcBridge(objectId, ccsdsPacketDistributor, tmStoreId, tcStoreId) { : TmTcBridge(objectId, ccsdsPacketDistributor, tmStoreId, tcStoreId) {
TmTcLwIpUdpBridge::lastAdd.addr = IPADDR_TYPE_ANY; TmTcLwIpUdpBridge::lastAdd.addr = IPADDR_TYPE_ANY;
} }
@ -40,8 +37,7 @@ ReturnValue_t TmTcLwIpUdpBridge::udp_server_init() {
if (err == ERR_OK) { if (err == ERR_OK) {
/* Set a receive callback for the upcb */ /* Set a receive callback for the upcb */
udp_recv(TmTcLwIpUdpBridge::upcb, &udp_server_receive_callback, udp_recv(TmTcLwIpUdpBridge::upcb, &udp_server_receive_callback, (void *)this);
(void *)this);
return RETURN_OK; return RETURN_OK;
} else { } else {
udp_remove(TmTcLwIpUdpBridge::upcb); udp_remove(TmTcLwIpUdpBridge::upcb);
@ -64,15 +60,13 @@ ReturnValue_t TmTcLwIpUdpBridge::performOperation(uint8_t operationCode) {
int ipAddress4 = ipAddress & 0xFF; int ipAddress4 = ipAddress & 0xFF;
#if OBSW_VERBOSE_LEVEL == 1 #if OBSW_VERBOSE_LEVEL == 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TmTcLwIpUdpBridge: Client IP Address " << std::dec sif::info << "TmTcLwIpUdpBridge: Client IP Address " << std::dec << ipAddress4 << "."
<< ipAddress4 << "." << ipAddress3 << "." << ipAddress2 << "." << ipAddress3 << "." << ipAddress2 << "." << ipAddress1 << std::endl;
<< ipAddress1 << std::endl;
uint16_t portSwapped = EndianConverter::convertBigEndian(lastPort); uint16_t portSwapped = EndianConverter::convertBigEndian(lastPort);
sif::info << "TmTcLwIpUdpBridge: Client IP Port " << (int)portSwapped sif::info << "TmTcLwIpUdpBridge: Client IP Port " << (int)portSwapped << std::endl;
<< std::endl;
#else #else
sif::printInfo("TmTcLwIpUdpBridge: Client IP Address %d.%d.%d.%d\n", sif::printInfo("TmTcLwIpUdpBridge: Client IP Address %d.%d.%d.%d\n", ipAddress4, ipAddress3,
ipAddress4, ipAddress3, ipAddress2, ipAddress1); ipAddress2, ipAddress1);
uint16_t portSwapped = EndianConverter::convertBigEndian(lastPort); uint16_t portSwapped = EndianConverter::convertBigEndian(lastPort);
sif::printInfo("TmTcLwIpUdpBridge: Client IP Port: %d\n", portSwapped); sif::printInfo("TmTcLwIpUdpBridge: Client IP Port: %d\n", portSwapped);
#endif #endif
@ -86,8 +80,7 @@ ReturnValue_t TmTcLwIpUdpBridge::performOperation(uint8_t operationCode) {
ReturnValue_t TmTcLwIpUdpBridge::sendTm(const uint8_t *data, size_t dataLen) { ReturnValue_t TmTcLwIpUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
struct pbuf *p_tx = pbuf_alloc(PBUF_TRANSPORT, dataLen, PBUF_RAM); struct pbuf *p_tx = pbuf_alloc(PBUF_TRANSPORT, dataLen, PBUF_RAM);
if ((p_tx != nullptr) && (lastAdd.addr != IPADDR_TYPE_ANY) && if ((p_tx != nullptr) && (lastAdd.addr != IPADDR_TYPE_ANY) && (upcb != nullptr)) {
(upcb != nullptr)) {
/* copy data to pbuf */ /* copy data to pbuf */
err_t err = pbuf_take(p_tx, (const char *)data, dataLen); err_t err = pbuf_take(p_tx, (const char *)data, dataLen);
if (err != ERR_OK) { if (err != ERR_OK) {
@ -115,19 +108,17 @@ ReturnValue_t TmTcLwIpUdpBridge::sendTm(const uint8_t *data, size_t dataLen) {
return RETURN_OK; return RETURN_OK;
} }
void TmTcLwIpUdpBridge::udp_server_receive_callback(void *arg, void TmTcLwIpUdpBridge::udp_server_receive_callback(void *arg, struct udp_pcb *upcb_,
struct udp_pcb *upcb_, struct pbuf *p, const ip_addr_t *addr,
struct pbuf *p,
const ip_addr_t *addr,
u16_t port) { u16_t port) {
auto udpBridge = reinterpret_cast<TmTcLwIpUdpBridge *>(arg); auto udpBridge = reinterpret_cast<TmTcLwIpUdpBridge *>(arg);
if (udpBridge == nullptr) { if (udpBridge == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning sif::warning << "TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid UDP bridge!"
<< "TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid UDP bridge!"
<< std::endl; << std::endl;
#else #else
sif::printWarning("TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid " sif::printWarning(
"TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid "
"UDP bridge!\n"); "UDP bridge!\n");
#endif #endif
} }
@ -159,8 +150,8 @@ void TmTcLwIpUdpBridge::udp_server_receive_callback(void *arg,
#endif #endif
store_address_t storeId; store_address_t storeId;
ReturnValue_t returnValue = udpBridge->tcStore->addData( ReturnValue_t returnValue =
&storeId, reinterpret_cast<uint8_t *>(p->payload), p->len); udpBridge->tcStore->addData(&storeId, reinterpret_cast<uint8_t *>(p->payload), p->len);
if (returnValue != RETURN_OK) { if (returnValue != RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "UDP Server: Data storage failed" << std::endl; sif::warning << "UDP Server: Data storage failed" << std::endl;

View File

@ -1,12 +1,12 @@
#ifndef BSP_STM32_RTEMS_NETWORKING_TMTCUDPBRIDGE_H_ #ifndef BSP_STM32_RTEMS_NETWORKING_TMTCUDPBRIDGE_H_
#define BSP_STM32_RTEMS_NETWORKING_TMTCUDPBRIDGE_H_ #define BSP_STM32_RTEMS_NETWORKING_TMTCUDPBRIDGE_H_
#include "fsfw/tmtcservices/TmTcBridge.h"
#include "commonConfig.h"
#include <lwip/ip_addr.h> #include <lwip/ip_addr.h>
#include <lwip/udp.h> #include <lwip/udp.h>
#include "commonConfig.h"
#include "fsfw/tmtcservices/TmTcBridge.h"
/** /**
* This bridge is used to forward TMTC packets received via LwIP UDP to the * This bridge is used to forward TMTC packets received via LwIP UDP to the
* internal software bus. * internal software bus.
@ -14,9 +14,9 @@
class TmTcLwIpUdpBridge : public TmTcBridge { class TmTcLwIpUdpBridge : public TmTcBridge {
friend class UdpTcLwIpPollingTask; friend class UdpTcLwIpPollingTask;
public: public:
TmTcLwIpUdpBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor, TmTcLwIpUdpBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor, object_id_t tmStoreId,
object_id_t tmStoreId, object_id_t tcStoreId); object_id_t tcStoreId);
~TmTcLwIpUdpBridge() override; ~TmTcLwIpUdpBridge() override;
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
@ -45,9 +45,8 @@ public:
* @param addr Source address which will be bound to TmTcUdpBridge::lastAdd * @param addr Source address which will be bound to TmTcUdpBridge::lastAdd
* @param port * @param port
*/ */
static void udp_server_receive_callback(void *arg, struct udp_pcb *upcb_, static void udp_server_receive_callback(void *arg, struct udp_pcb *upcb_, struct pbuf *p,
struct pbuf *p, const ip_addr_t *addr, const ip_addr_t *addr, u16_t port);
u16_t port);
/** /**
* Check whether the communication link is up. * Check whether the communication link is up.
@ -56,7 +55,7 @@ public:
*/ */
[[nodiscard]] bool comLinkUp() const; [[nodiscard]] bool comLinkUp() const;
private: private:
struct udp_pcb *upcb = nullptr; struct udp_pcb *upcb = nullptr;
ip_addr_t lastAdd{}; ip_addr_t lastAdd{};
u16_t lastPort = 0; u16_t lastPort = 0;

View File

@ -10,11 +10,9 @@
#include "lwip/timeouts.h" #include "lwip/timeouts.h"
#include "networking.h" #include "networking.h"
UdpTcLwIpPollingTask::UdpTcLwIpPollingTask(object_id_t objectId, UdpTcLwIpPollingTask::UdpTcLwIpPollingTask(object_id_t objectId, object_id_t bridgeId,
object_id_t bridgeId,
struct netif *gnetif) struct netif *gnetif)
: SystemObject(objectId), periodicHandleCounter(0), bridgeId(bridgeId), : SystemObject(objectId), periodicHandleCounter(0), bridgeId(bridgeId), gnetif(gnetif) {}
gnetif(gnetif) {}
UdpTcLwIpPollingTask::~UdpTcLwIpPollingTask() = default; UdpTcLwIpPollingTask::~UdpTcLwIpPollingTask() = default;
@ -47,8 +45,7 @@ ReturnValue_t UdpTcLwIpPollingTask::performOperation(uint8_t operationCode) {
/* In case ethernet cable is disconnected */ /* In case ethernet cable is disconnected */
if (not networking::getEthCableConnected() and udpBridge->comLinkUp()) { if (not networking::getEthCableConnected() and udpBridge->comLinkUp()) {
udpBridge->physicalConnectStatusChange(false); udpBridge->physicalConnectStatusChange(false);
} else if (networking::getEthCableConnected() and } else if (networking::getEthCableConnected() and not udpBridge->comLinkUp()) {
not udpBridge->comLinkUp()) {
udpBridge->physicalConnectStatusChange(true); udpBridge->physicalConnectStatusChange(true);
} }
} }

View File

@ -14,9 +14,8 @@ class TmTcLwIpUdpBridge;
class UdpTcLwIpPollingTask : public SystemObject, class UdpTcLwIpPollingTask : public SystemObject,
public ExecutableObjectIF, public ExecutableObjectIF,
public HasReturnvaluesIF { public HasReturnvaluesIF {
public: public:
UdpTcLwIpPollingTask(object_id_t objectId, object_id_t bridgeId, UdpTcLwIpPollingTask(object_id_t objectId, object_id_t bridgeId, struct netif *gnetif);
struct netif *gnetif);
~UdpTcLwIpPollingTask() override; ~UdpTcLwIpPollingTask() override;
ReturnValue_t initialize() override; ReturnValue_t initialize() override;
@ -28,7 +27,7 @@ public:
*/ */
ReturnValue_t performOperation(uint8_t operationCode) override; ReturnValue_t performOperation(uint8_t operationCode) override;
private: private:
static const uint8_t PERIODIC_HANDLE_TRIGGER = 5; static const uint8_t PERIODIC_HANDLE_TRIGGER = 5;
uint8_t periodicHandleCounter; uint8_t periodicHandleCounter;
object_id_t bridgeId = 0; object_id_t bridgeId = 0;

View File

@ -107,8 +107,7 @@ void handle_dhcp_start(struct netif *netif) {
void handle_dhcp_wait(struct netif *netif, struct dhcp **dhcp) { void handle_dhcp_wait(struct netif *netif, struct dhcp **dhcp) {
if (dhcp_supplied_address(netif)) { if (dhcp_supplied_address(netif)) {
DHCP_state = DHCP_ADDRESS_ASSIGNED; DHCP_state = DHCP_ADDRESS_ASSIGNED;
printf("IP address assigned by a DHCP server: %s\n\r", printf("IP address assigned by a DHCP server: %s\n\r", ip4addr_ntoa(netif_ip4_addr(netif)));
ip4addr_ntoa(netif_ip4_addr(netif)));
printf("Listener port: %d\n\r", UDP_SERVER_PORT); printf("Listener port: %d\n\r", UDP_SERVER_PORT);
#if OBSW_ETHERNET_TMTC_COMMANDING == 1 #if OBSW_ETHERNET_TMTC_COMMANDING == 1
#if OBSW_ETHERNET_USE_LED1_LED2 == 1 #if OBSW_ETHERNET_USE_LED1_LED2 == 1
@ -117,8 +116,8 @@ void handle_dhcp_wait(struct netif *netif, struct dhcp **dhcp) {
#endif #endif
#endif #endif
} else { } else {
*dhcp = static_cast<struct dhcp *>(netif_get_client_data( *dhcp =
netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP)); static_cast<struct dhcp *>(netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP));
/* DHCP timeout */ /* DHCP timeout */
if ((*dhcp)->tries > MAX_DHCP_TRIES) { if ((*dhcp)->tries > MAX_DHCP_TRIES) {

View File

@ -47,8 +47,8 @@ void handle_status_change(struct netif *netif, bool link_up) {
#else #else
uint8_t iptxt[20]; uint8_t iptxt[20];
sprintf((char *)iptxt, "%s", ip4addr_ntoa(netif_ip4_addr(netif))); sprintf((char *)iptxt, "%s", ip4addr_ntoa(netif_ip4_addr(netif)));
printf("\rNetwork cable connected. Static IP address: %s | Port: %d\n\r", printf("\rNetwork cable connected. Static IP address: %s | Port: %d\n\r", iptxt,
iptxt, UDP_SERVER_PORT); UDP_SERVER_PORT);
#if OBSW_ETHERNET_USE_LED1_LED2 == 1 #if OBSW_ETHERNET_USE_LED1_LED2 == 1
BSP_LED_On(LED1); BSP_LED_On(LED1);
BSP_LED_Off(LED2); BSP_LED_Off(LED2);

View File

@ -44,17 +44,18 @@
*/ */
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "stm32h7xx_hal.h"
#include "lwip/opt.h"
#include "lwip/timeouts.h"
#include "lwip/netif.h"
#include "netif/etharp.h"
#include "ethernetif.h" #include "ethernetif.h"
#include "lan8742.h"
#include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h>
#include "fsfw/FSFW.h" #include "fsfw/FSFW.h"
#include "lan8742.h"
#include "lwip/netif.h"
#include "lwip/opt.h"
#include "lwip/timeouts.h"
#include "netif/etharp.h"
#include "stm32h7xx_hal.h"
#ifdef FSFW_OSAL_RTEMS #ifdef FSFW_OSAL_RTEMS
#include <rtems.h> #include <rtems.h>
@ -70,7 +71,7 @@
#define ETH_RX_BUFFER_SIZE 1536U #define ETH_RX_BUFFER_SIZE 1536U
#define ETH_RX_BUFFER_CNT 12U #define ETH_RX_BUFFER_CNT 12U
#define ETH_TX_BUFFER_MAX ((ETH_TX_DESC_CNT) * 2U) #define ETH_TX_BUFFER_MAX ((ETH_TX_DESC_CNT)*2U)
#define DMA_DESCRIPTOR_ALIGNMENT 0x20 #define DMA_DESCRIPTOR_ALIGNMENT 0x20
@ -93,49 +94,47 @@ stack they will return back to DMA after been processed by the stack.
2.b. Rx Buffers must have the same size: ETH_RX_BUFFER_SIZE, this value must 2.b. Rx Buffers must have the same size: ETH_RX_BUFFER_SIZE, this value must
passed to ETH DMA in the init field (EthHandle.Init.RxBuffLen) passed to ETH DMA in the init field (EthHandle.Init.RxBuffLen)
*/ */
typedef enum typedef enum { RX_ALLOC_OK = 0x00, RX_ALLOC_ERROR = 0x01 } RxAllocStatusTypeDef;
{
RX_ALLOC_OK = 0x00,
RX_ALLOC_ERROR = 0x01
} RxAllocStatusTypeDef;
typedef struct typedef struct {
{
struct pbuf_custom pbuf_custom; struct pbuf_custom pbuf_custom;
uint8_t buff[(ETH_RX_BUFFER_SIZE + 31) & ~31] __ALIGNED(32); uint8_t buff[(ETH_RX_BUFFER_SIZE + 31) & ~31] __ALIGNED(32);
} RxBuff_t; } RxBuff_t;
#if defined(__ICCARM__) /*!< IAR Compiler */ #if defined(__ICCARM__) /*!< IAR Compiler */
#pragma location=0x30000000 #pragma location = 0x30000000
ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */ ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */
#pragma location=0x30000200 #pragma location = 0x30000200
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */ ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */
#elif defined(__CC_ARM) /* MDK ARM Compiler */ #elif defined(__CC_ARM) /* MDK ARM Compiler */
__attribute__((section(".RxDecripSection"))) ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */ __attribute__((section(".RxDecripSection")))
__attribute__((section(".TxDecripSection"))) ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */ ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]; /* Ethernet Rx DMA Descriptors */
__attribute__((section(".TxDecripSection")))
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */
#elif defined(__GNUC__) /* GNU Compiler */ #elif defined(__GNUC__) /* GNU Compiler */
#ifdef FSFW_OSAL_RTEMS #ifdef FSFW_OSAL_RTEMS
/* Put into special RTEMS section and align correctly */ /* Put into special RTEMS section and align correctly */
ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__(( ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]
section(".bsp_nocache"), __attribute__((section(".bsp_nocache"),
__aligned__(DMA_DESCRIPTOR_ALIGNMENT))); /* Ethernet Rx DMA Descriptors */ __aligned__(DMA_DESCRIPTOR_ALIGNMENT))); /* Ethernet Rx DMA Descriptors */
/* Put into special RTEMS section and align correctly */ /* Put into special RTEMS section and align correctly */
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__(( ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]
section(".bsp_nocache"), __attribute__((section(".bsp_nocache"),
__aligned__(DMA_DESCRIPTOR_ALIGNMENT))); /* Ethernet Tx DMA Descriptors */ __aligned__(DMA_DESCRIPTOR_ALIGNMENT))); /* Ethernet Tx DMA Descriptors */
/* Ethernet Receive Buffers. Just place somewhere is BSS instead of explicitely /* Ethernet Receive Buffers. Just place somewhere is BSS instead of explicitely
* placing it */ * placing it */
uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_RX_BUFFER_SIZE]; uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_RX_BUFFER_SIZE];
#elif defined FSFW_OSAL_FREERTOS #elif defined FSFW_OSAL_FREERTOS
ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".RxDecripSection"))); /* Ethernet Rx DMA Descriptors */ ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__((section(".TxDecripSection"))); /* Ethernet Tx DMA Descriptors */ __attribute__((section(".RxDecripSection"))); /* Ethernet Rx DMA Descriptors */
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]
__attribute__((section(".TxDecripSection"))); /* Ethernet Tx DMA Descriptors */
#endif /* FSFW_OSAL_RTEMS */ #endif /* FSFW_OSAL_RTEMS */
@ -144,14 +143,14 @@ ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__((section(".TxDecr
/* Memory Pool Declaration */ /* Memory Pool Declaration */
LWIP_MEMPOOL_DECLARE(RX_POOL, ETH_RX_BUFFER_CNT, sizeof(RxBuff_t), "Zero-copy RX PBUF pool"); LWIP_MEMPOOL_DECLARE(RX_POOL, ETH_RX_BUFFER_CNT, sizeof(RxBuff_t), "Zero-copy RX PBUF pool");
#if defined ( __ICCARM__ ) /*!< IAR Compiler */ #if defined(__ICCARM__) /*!< IAR Compiler */
#pragma location = 0x30000400 #pragma location = 0x30000400
extern u8_t memp_memory_RX_POOL_base[]; extern u8_t memp_memory_RX_POOL_base[];
#elif defined ( __CC_ARM ) /* MDK ARM Compiler */ #elif defined(__CC_ARM) /* MDK ARM Compiler */
__attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[]; __attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[];
#elif defined ( __GNUC__ ) /* GNU Compiler */ #elif defined(__GNUC__) /* GNU Compiler */
__attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[]; __attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[];
#endif #endif
@ -170,17 +169,14 @@ ETH_TxPacketConfig TxConfig;
u32_t sys_now(void); u32_t sys_now(void);
extern void Error_Handler(void); extern void Error_Handler(void);
int32_t ETH_PHY_IO_Init(void); int32_t ETH_PHY_IO_Init(void);
int32_t ETH_PHY_IO_DeInit (void); int32_t ETH_PHY_IO_DeInit(void);
int32_t ETH_PHY_IO_ReadReg(uint32_t DevAddr, uint32_t RegAddr, uint32_t *pRegVal); int32_t ETH_PHY_IO_ReadReg(uint32_t DevAddr, uint32_t RegAddr, uint32_t *pRegVal);
int32_t ETH_PHY_IO_WriteReg(uint32_t DevAddr, uint32_t RegAddr, uint32_t RegVal); int32_t ETH_PHY_IO_WriteReg(uint32_t DevAddr, uint32_t RegAddr, uint32_t RegVal);
int32_t ETH_PHY_IO_GetTick(void); int32_t ETH_PHY_IO_GetTick(void);
lan8742_Object_t LAN8742; lan8742_Object_t LAN8742;
lan8742_IOCtx_t LAN8742_IOCtx = {ETH_PHY_IO_Init, lan8742_IOCtx_t LAN8742_IOCtx = {ETH_PHY_IO_Init, ETH_PHY_IO_DeInit, ETH_PHY_IO_WriteReg,
ETH_PHY_IO_DeInit, ETH_PHY_IO_ReadReg, ETH_PHY_IO_GetTick};
ETH_PHY_IO_WriteReg,
ETH_PHY_IO_ReadReg,
ETH_PHY_IO_GetTick};
/* Private functions ---------------------------------------------------------*/ /* Private functions ---------------------------------------------------------*/
void pbuf_free_custom(struct pbuf *p); void pbuf_free_custom(struct pbuf *p);
@ -195,7 +191,8 @@ void pbuf_free_custom(struct pbuf *p);
* for this ethernetif * for this ethernetif
*/ */
static void low_level_init(struct netif *netif) { static void low_level_init(struct netif *netif) {
uint8_t macaddress[6]= {ETH_MAC_ADDR0, ETH_MAC_ADDR1, ETH_MAC_ADDR2, ETH_MAC_ADDR3, ETH_MAC_ADDR4, ETH_MAC_ADDR5}; uint8_t macaddress[6] = {ETH_MAC_ADDR0, ETH_MAC_ADDR1, ETH_MAC_ADDR2,
ETH_MAC_ADDR3, ETH_MAC_ADDR4, ETH_MAC_ADDR5};
EthHandle.Instance = ETH; EthHandle.Instance = ETH;
EthHandle.Init.MACAddr = macaddress; EthHandle.Init.MACAddr = macaddress;
@ -229,7 +226,7 @@ static void low_level_init(struct netif *netif) {
LWIP_MEMPOOL_INIT(RX_POOL); LWIP_MEMPOOL_INIT(RX_POOL);
/* Set Tx packet config common parameters */ /* Set Tx packet config common parameters */
memset(&TxConfig, 0 , sizeof(ETH_TxPacketConfig)); memset(&TxConfig, 0, sizeof(ETH_TxPacketConfig));
TxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CSUM | ETH_TX_PACKETS_FEATURES_CRCPAD; TxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CSUM | ETH_TX_PACKETS_FEATURES_CRCPAD;
TxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC; TxConfig.ChecksumCtrl = ETH_CHECKSUM_IPHDR_PAYLOAD_INSERT_PHDR_CALC;
TxConfig.CRCPadCtrl = ETH_CRC_PAD_INSERT; TxConfig.CRCPadCtrl = ETH_CRC_PAD_INSERT;
@ -265,23 +262,19 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p) {
err_t errval = ERR_OK; err_t errval = ERR_OK;
ETH_BufferTypeDef Txbuffer[ETH_TX_DESC_CNT] = {0}; ETH_BufferTypeDef Txbuffer[ETH_TX_DESC_CNT] = {0};
memset(Txbuffer, 0 , ETH_TX_DESC_CNT*sizeof(ETH_BufferTypeDef)); memset(Txbuffer, 0, ETH_TX_DESC_CNT * sizeof(ETH_BufferTypeDef));
for(q = p; q != NULL; q = q->next) for (q = p; q != NULL; q = q->next) {
{ if (i >= ETH_TX_DESC_CNT) return ERR_IF;
if(i >= ETH_TX_DESC_CNT)
return ERR_IF;
Txbuffer[i].buffer = q->payload; Txbuffer[i].buffer = q->payload;
Txbuffer[i].len = q->len; Txbuffer[i].len = q->len;
if(i>0) if (i > 0) {
{ Txbuffer[i - 1].next = &Txbuffer[i];
Txbuffer[i-1].next = &Txbuffer[i];
} }
if(q->next == NULL) if (q->next == NULL) {
{
Txbuffer[i].next = NULL; Txbuffer[i].next = NULL;
} }
@ -294,8 +287,7 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p) {
HAL_StatusTypeDef ret = HAL_ETH_Transmit(&EthHandle, &TxConfig, ETH_DMA_TRANSMIT_TIMEOUT); HAL_StatusTypeDef ret = HAL_ETH_Transmit(&EthHandle, &TxConfig, ETH_DMA_TRANSMIT_TIMEOUT);
if (ret != HAL_OK) { if (ret != HAL_OK) {
printf("low_level_output: Could not transmit ethernet packet, code %d!\n\r", printf("low_level_output: Could not transmit ethernet packet, code %d!\n\r", ret);
ret);
} }
return errval; return errval;
} }
@ -311,8 +303,7 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p) {
static struct pbuf *low_level_input(struct netif *netif) { static struct pbuf *low_level_input(struct netif *netif) {
struct pbuf *p = NULL; struct pbuf *p = NULL;
if(RxAllocStatus == RX_ALLOC_OK) if (RxAllocStatus == RX_ALLOC_OK) {
{
HAL_ETH_ReadData(&EthHandle, (void **)&p); HAL_ETH_ReadData(&EthHandle, (void **)&p);
} }
@ -331,19 +322,15 @@ static struct pbuf *low_level_input(struct netif *netif) {
void ethernetif_input(struct netif *netif) { void ethernetif_input(struct netif *netif) {
struct pbuf *p = NULL; struct pbuf *p = NULL;
do do {
{ p = low_level_input(netif);
p = low_level_input( netif ); if (p != NULL) {
if (p != NULL) if (netif->input(p, netif) != ERR_OK) {
{
if (netif->input( p, netif) != ERR_OK )
{
pbuf_free(p); pbuf_free(p);
} }
} }
} while(p!=NULL); } while (p != NULL);
} }
/** /**
@ -388,12 +375,11 @@ err_t ethernetif_init(struct netif *netif) {
* @retval None * @retval None
*/ */
void pbuf_free_custom(struct pbuf *p) { void pbuf_free_custom(struct pbuf *p) {
struct pbuf_custom* custom_pbuf = (struct pbuf_custom*)p; struct pbuf_custom *custom_pbuf = (struct pbuf_custom *)p;
LWIP_MEMPOOL_FREE(RX_POOL, custom_pbuf); LWIP_MEMPOOL_FREE(RX_POOL, custom_pbuf);
/* If the Rx Buffer Pool was exhausted, signal the ethernetif_input task to /* If the Rx Buffer Pool was exhausted, signal the ethernetif_input task to
* call HAL_ETH_GetRxDataBuffer to rebuild the Rx descriptors. */ * call HAL_ETH_GetRxDataBuffer to rebuild the Rx descriptors. */
if (RxAllocStatus == RX_ALLOC_ERROR) if (RxAllocStatus == RX_ALLOC_ERROR) {
{
RxAllocStatus = RX_ALLOC_OK; RxAllocStatus = RX_ALLOC_OK;
} }
} }
@ -505,10 +491,8 @@ int32_t ETH_PHY_IO_DeInit(void) { return 0; }
* @param pRegVal: pointer to hold the register value * @param pRegVal: pointer to hold the register value
* @retval 0 if OK -1 if Error * @retval 0 if OK -1 if Error
*/ */
int32_t ETH_PHY_IO_ReadReg(uint32_t DevAddr, uint32_t RegAddr, int32_t ETH_PHY_IO_ReadReg(uint32_t DevAddr, uint32_t RegAddr, uint32_t *pRegVal) {
uint32_t *pRegVal) { if (HAL_ETH_ReadPHYRegister(&EthHandle, DevAddr, RegAddr, pRegVal) != HAL_OK) {
if (HAL_ETH_ReadPHYRegister(&EthHandle, DevAddr, RegAddr, pRegVal) !=
HAL_OK) {
return -1; return -1;
} }
@ -522,10 +506,8 @@ int32_t ETH_PHY_IO_ReadReg(uint32_t DevAddr, uint32_t RegAddr,
* @param RegVal: Value to be written * @param RegVal: Value to be written
* @retval 0 if OK -1 if Error * @retval 0 if OK -1 if Error
*/ */
int32_t ETH_PHY_IO_WriteReg(uint32_t DevAddr, uint32_t RegAddr, int32_t ETH_PHY_IO_WriteReg(uint32_t DevAddr, uint32_t RegAddr, uint32_t RegVal) {
uint32_t RegVal) { if (HAL_ETH_WritePHYRegister(&EthHandle, DevAddr, RegAddr, RegVal) != HAL_OK) {
if (HAL_ETH_WritePHYRegister(&EthHandle, DevAddr, RegAddr, RegVal) !=
HAL_OK) {
return -1; return -1;
} }
@ -549,16 +531,12 @@ void ethernet_link_check_state(struct netif *netif) {
PHYLinkState = LAN8742_GetLinkState(&LAN8742); PHYLinkState = LAN8742_GetLinkState(&LAN8742);
if(netif_is_link_up(netif) && (PHYLinkState <= LAN8742_STATUS_LINK_DOWN)) if (netif_is_link_up(netif) && (PHYLinkState <= LAN8742_STATUS_LINK_DOWN)) {
{
HAL_ETH_Stop_IT(&EthHandle); HAL_ETH_Stop_IT(&EthHandle);
netif_set_down(netif); netif_set_down(netif);
netif_set_link_down(netif); netif_set_link_down(netif);
} } else if (!netif_is_link_up(netif) && (PHYLinkState > LAN8742_STATUS_LINK_DOWN)) {
else if(!netif_is_link_up(netif) && (PHYLinkState > LAN8742_STATUS_LINK_DOWN)) switch (PHYLinkState) {
{
switch (PHYLinkState)
{
case LAN8742_STATUS_100MBITS_FULLDUPLEX: case LAN8742_STATUS_100MBITS_FULLDUPLEX:
duplex = ETH_FULLDUPLEX_MODE; duplex = ETH_FULLDUPLEX_MODE;
speed = ETH_SPEED_100M; speed = ETH_SPEED_100M;
@ -583,8 +561,7 @@ void ethernet_link_check_state(struct netif *netif) {
break; break;
} }
if(linkchanged) if (linkchanged) {
{
/* Get MAC Config MAC */ /* Get MAC Config MAC */
HAL_ETH_GetMACConfig(&EthHandle, &MACConf); HAL_ETH_GetMACConfig(&EthHandle, &MACConf);
MACConf.DuplexMode = duplex; MACConf.DuplexMode = duplex;
@ -597,11 +574,9 @@ void ethernet_link_check_state(struct netif *netif) {
} }
} }
void HAL_ETH_RxAllocateCallback(uint8_t **buff) void HAL_ETH_RxAllocateCallback(uint8_t **buff) {
{
struct pbuf_custom *p = LWIP_MEMPOOL_ALLOC(RX_POOL); struct pbuf_custom *p = LWIP_MEMPOOL_ALLOC(RX_POOL);
if (p) if (p) {
{
/* Get the buff from the struct pbuf address. */ /* Get the buff from the struct pbuf address. */
*buff = (uint8_t *)p + offsetof(RxBuff_t, buff); *buff = (uint8_t *)p + offsetof(RxBuff_t, buff);
p->custom_free_function = pbuf_free_custom; p->custom_free_function = pbuf_free_custom;
@ -609,16 +584,13 @@ void HAL_ETH_RxAllocateCallback(uint8_t **buff)
* This must be performed whenever a buffer's allocated because it may be * This must be performed whenever a buffer's allocated because it may be
* changed by lwIP or the app, e.g., pbuf_free decrements ref. */ * changed by lwIP or the app, e.g., pbuf_free decrements ref. */
pbuf_alloced_custom(PBUF_RAW, 0, PBUF_REF, p, *buff, ETH_RX_BUFFER_SIZE); pbuf_alloced_custom(PBUF_RAW, 0, PBUF_REF, p, *buff, ETH_RX_BUFFER_SIZE);
} } else {
else
{
RxAllocStatus = RX_ALLOC_ERROR; RxAllocStatus = RX_ALLOC_ERROR;
*buff = NULL; *buff = NULL;
} }
} }
void HAL_ETH_RxLinkCallback(void **pStart, void **pEnd, uint8_t *buff, uint16_t Length) void HAL_ETH_RxLinkCallback(void **pStart, void **pEnd, uint8_t *buff, uint16_t Length) {
{
struct pbuf **ppStart = (struct pbuf **)pStart; struct pbuf **ppStart = (struct pbuf **)pStart;
struct pbuf **ppEnd = (struct pbuf **)pEnd; struct pbuf **ppEnd = (struct pbuf **)pEnd;
struct pbuf *p = NULL; struct pbuf *p = NULL;
@ -630,22 +602,18 @@ void HAL_ETH_RxLinkCallback(void **pStart, void **pEnd, uint8_t *buff, uint16_t
p->len = Length; p->len = Length;
/* Chain the buffer. */ /* Chain the buffer. */
if (!*ppStart) if (!*ppStart) {
{
/* The first buffer of the packet. */ /* The first buffer of the packet. */
*ppStart = p; *ppStart = p;
} } else {
else
{
/* Chain the buffer to the end of the packet. */ /* Chain the buffer to the end of the packet. */
(*ppEnd)->next = p; (*ppEnd)->next = p;
} }
*ppEnd = p; *ppEnd = p;
/* Update the total length of all the buffers of the chain. Each pbuf in the chain should have its tot_len /* Update the total length of all the buffers of the chain. Each pbuf in the chain should have its
* set to its own length, plus the length of all the following pbufs in the chain. */ * tot_len set to its own length, plus the length of all the following pbufs in the chain. */
for (p = *ppStart; p != NULL; p = p->next) for (p = *ppStart; p != NULL; p = p->next) {
{
p->tot_len += Length; p->tot_len += Length;
} }
@ -653,10 +621,7 @@ void HAL_ETH_RxLinkCallback(void **pStart, void **pEnd, uint8_t *buff, uint16_t
SCB_InvalidateDCache_by_Addr((uint32_t *)buff, Length); SCB_InvalidateDCache_by_Addr((uint32_t *)buff, Length);
} }
void HAL_ETH_TxFreeCallback(uint32_t * buff) void HAL_ETH_TxFreeCallback(uint32_t *buff) { pbuf_free((struct pbuf *)buff); }
{
pbuf_free((struct pbuf *)buff);
}
ETH_HandleTypeDef *getEthernetHandle() { return &EthHandle; } ETH_HandleTypeDef *getEthernetHandle() { return &EthHandle; }

View File

@ -4,14 +4,11 @@
bool ethernetCableConnected = false; bool ethernetCableConnected = false;
void networking::setEthCableConnected(bool status) { void networking::setEthCableConnected(bool status) { ethernetCableConnected = status; }
ethernetCableConnected = status;
}
bool networking::getEthCableConnected() { return ethernetCableConnected; } bool networking::getEthCableConnected() { return ethernetCableConnected; }
void networking::setLwipAddresses(ip_addr_t *ipaddr, ip_addr_t *netmask, void networking::setLwipAddresses(ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw) {
ip_addr_t *gw) {
IP4_ADDR(ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3); IP4_ADDR(ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
IP4_ADDR(netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3); IP4_ADDR(netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
IP4_ADDR(gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3); IP4_ADDR(gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);