apply auto-formatter
This commit is contained in:
parent
c2a9db8ac8
commit
c88a534e1c
@ -1,22 +1,17 @@
|
|||||||
#include "pollingsequence/pollingSequenceFactory.h"
|
|
||||||
#include "objects/systemObjectList.h"
|
|
||||||
|
|
||||||
#include "example/test/FsfwExampleTask.h"
|
|
||||||
|
|
||||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
#include <fsfw/tasks/FixedTimeslotTaskIF.h>
|
||||||
|
|
||||||
|
#include "example/test/FsfwExampleTask.h"
|
||||||
|
#include "objects/systemObjectList.h"
|
||||||
|
#include "pollingsequence/pollingSequenceFactory.h"
|
||||||
|
|
||||||
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);
|
||||||
@ -25,17 +20,13 @@ 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!" << std::endl;
|
sif::error << "pst::pollingSequenceInitFunction: Initialization errors!" << std::endl;
|
||||||
#else
|
#else
|
||||||
@ -54,10 +45,8 @@ ReturnValue_t pst::pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence) {
|
|||||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.3 * length, DeviceHandlerIF::SEND_WRITE);
|
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.3 * length, DeviceHandlerIF::SEND_WRITE);
|
||||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.3 * length, DeviceHandlerIF::SEND_WRITE);
|
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_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, DeviceHandlerIF::SEND_READ);
|
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_0, 0.6 * length, DeviceHandlerIF::SEND_READ);
|
||||||
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.6 * length, DeviceHandlerIF::SEND_READ);
|
thisSequence->addSlot(objects::TEST_DEVICE_HANDLER_1, 0.6 * length, DeviceHandlerIF::SEND_READ);
|
||||||
@ -67,8 +56,7 @@ ReturnValue_t pst::pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence) {
|
|||||||
|
|
||||||
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!" << std::endl;
|
sif::error << "pst::pollingSequenceTestFunction: Initialization errors!" << std::endl;
|
||||||
#else
|
#else
|
||||||
@ -77,7 +65,3 @@ ReturnValue_t pst::pollingSequenceDevices(FixedTimeslotTaskIF *thisSequence) {
|
|||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,5 +14,4 @@ enum commonSubsystemId: uint8_t {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* COMMON_CONFIG_COMMONSUBSYSTEMIDS_H_ */
|
#endif /* COMMON_CONFIG_COMMONSUBSYSTEMIDS_H_ */
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#ifndef COMMON_COMMONSYSTEMOBJECTS_H_
|
#ifndef COMMON_COMMONSYSTEMOBJECTS_H_
|
||||||
#define COMMON_COMMONSYSTEMOBJECTS_H_
|
#define COMMON_COMMONSYSTEMOBJECTS_H_
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <fsfw/objectmanager/frameworkObjects.h>
|
#include <fsfw/objectmanager/frameworkObjects.h>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
namespace objects {
|
namespace objects {
|
||||||
enum commonObjects : object_id_t {
|
enum commonObjects : object_id_t {
|
||||||
|
|
||||||
@ -35,6 +36,4 @@ enum commonObjects: object_id_t {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* COMMON_COMMONSYSTEMOBJECTS_H_ */
|
#endif /* COMMON_COMMONSYSTEMOBJECTS_H_ */
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
#include <fsfw/datapool/PoolReadGuard.h>
|
|
||||||
#include "FsfwTestController.h"
|
#include "FsfwTestController.h"
|
||||||
|
|
||||||
|
#include <fsfw/datapool/PoolReadGuard.h>
|
||||||
|
|
||||||
FsfwTestController::FsfwTestController(object_id_t objectId, object_id_t device0,
|
FsfwTestController::FsfwTestController(object_id_t objectId, object_id_t device0,
|
||||||
object_id_t device1, uint8_t verboseLevel):
|
object_id_t device1, uint8_t verboseLevel)
|
||||||
TestController(objectId, objects::NO_OBJECT, 5), device0Id(device0),
|
: TestController(objectId, objects::NO_OBJECT, 5),
|
||||||
device1Id(device1), deviceDataset0(device0), deviceDataset1(device1) {
|
device0Id(device0),
|
||||||
}
|
device1Id(device1),
|
||||||
|
deviceDataset0(device0),
|
||||||
|
deviceDataset1(device1) {}
|
||||||
|
|
||||||
FsfwTestController::~FsfwTestController() {
|
FsfwTestController::~FsfwTestController() {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t FsfwTestController::handleCommandMessage(CommandMessage* message) {
|
ReturnValue_t FsfwTestController::handleCommandMessage(CommandMessage* message) {
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
@ -44,8 +45,8 @@ 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) << std::endl;
|
<< static_cast<int>(deviceDataset0.testUint8Var.value) << 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);
|
||||||
@ -56,7 +57,6 @@ void FsfwTestController::performControlOperation() {
|
|||||||
case (TRACE_DEV_0_VECTOR): {
|
case (TRACE_DEV_0_VECTOR): {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -67,14 +67,16 @@ ReturnValue_t FsfwTestController::initializeAfterTaskCreation() {
|
|||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
HasLocalDataPoolIF* device0 = ObjectManager::instance()->get<HasLocalDataPoolIF>(
|
HasLocalDataPoolIF* device0 =
|
||||||
deviceDataset0.getCreatorObjectId());
|
ObjectManager::instance()->get<HasLocalDataPoolIF>(deviceDataset0.getCreatorObjectId());
|
||||||
if (device0 == nullptr) {
|
if (device0 == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 0 "
|
sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 0 "
|
||||||
"handle invalid!" << std::endl;
|
"handle invalid!"
|
||||||
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("TestController::initializeAfterTaskCreation: Test device handler 0 "
|
sif::printWarning(
|
||||||
|
"TestController::initializeAfterTaskCreation: Test device handler 0 "
|
||||||
"handle invalid!");
|
"handle invalid!");
|
||||||
#endif
|
#endif
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
@ -82,21 +84,22 @@ ReturnValue_t FsfwTestController::initializeAfterTaskCreation() {
|
|||||||
ProvidesDataPoolSubscriptionIF* subscriptionIF = device0->getSubscriptionInterface();
|
ProvidesDataPoolSubscriptionIF* subscriptionIF = 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 << "TestController::initializeAfterTaskCreation: Test device handler 1 "
|
sif::warning << "TestController::initializeAfterTaskCreation: Test device handler 1 "
|
||||||
"handle invalid!" << std::endl;
|
"handle invalid!"
|
||||||
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("TestController::initializeAfterTaskCreation: Test device handler 1 "
|
sif::printWarning(
|
||||||
|
"TestController::initializeAfterTaskCreation: Test device handler 1 "
|
||||||
"handle invalid!");
|
"handle invalid!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -104,18 +107,15 @@ 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, Submode_t submode,
|
ReturnValue_t FsfwTestController::checkModeCommand(Mode_t mode, Submode_t submode,
|
||||||
uint32_t* msToReachTheMode) {
|
uint32_t* msToReachTheMode) {
|
||||||
@ -130,17 +130,20 @@ void FsfwTestController::handleChangedDataset(sid_t sid, store_address_t storeId
|
|||||||
char const* printout = nullptr;
|
char const* printout = nullptr;
|
||||||
if (storeId == storeId::INVALID_STORE_ADDRESS) {
|
if (storeId == storeId::INVALID_STORE_ADDRESS) {
|
||||||
printout = "Notification";
|
printout = "Notification";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
printout = "Snapshot";
|
printout = "Snapshot";
|
||||||
}
|
}
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "FsfwTestController::handleChangedDataset: " << printout << " update"
|
sif::info << "FsfwTestController::handleChangedDataset: " << printout
|
||||||
"from object ID " << setw(8) << setfill('0') << hex << sid.objectId <<
|
<< " update"
|
||||||
" and set ID " << sid.ownerSetId << dec << setfill(' ') << endl;
|
"from object ID "
|
||||||
|
<< setw(8) << setfill('0') << hex << sid.objectId << " and set ID " << sid.ownerSetId
|
||||||
|
<< dec << setfill(' ') << endl;
|
||||||
#else
|
#else
|
||||||
sif::printInfo("FsfwTestController::handleChangedPoolVariable: %s update from"
|
sif::printInfo(
|
||||||
"object ID 0x%08x and set ID %lu\n", printout, sid.objectId, sid.ownerSetId);
|
"FsfwTestController::handleChangedPoolVariable: %s update from"
|
||||||
|
"object ID 0x%08x and set ID %lu\n",
|
||||||
|
printout, sid.objectId, sid.ownerSetId);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (storeId == storeId::INVALID_STORE_ADDRESS) {
|
if (storeId == storeId::INVALID_STORE_ADDRESS) {
|
||||||
@ -151,11 +154,11 @@ void FsfwTestController::handleChangedDataset(sid_t sid, store_address_t storeId
|
|||||||
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 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,33 +174,35 @@ void FsfwTestController::handleChangedDataset(sid_t sid, store_address_t storeId
|
|||||||
|
|
||||||
void FsfwTestController::handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId,
|
void FsfwTestController::handleChangedPoolVariable(gp_id_t globPoolId, store_address_t storeId,
|
||||||
bool* clearMessage) {
|
bool* clearMessage) {
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
if (verboseLevel >= 1) {
|
if (verboseLevel >= 1) {
|
||||||
char const* printout = nullptr;
|
char const* printout = nullptr;
|
||||||
if (storeId == storeId::INVALID_STORE_ADDRESS) {
|
if (storeId == storeId::INVALID_STORE_ADDRESS) {
|
||||||
printout = "Notification";
|
printout = "Notification";
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
printout = "Snapshot";
|
printout = "Snapshot";
|
||||||
}
|
}
|
||||||
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::info << "TestController::handleChangedPoolVariable: " << printout << " update from object "
|
sif::info << "TestController::handleChangedPoolVariable: " << printout
|
||||||
"ID 0x" << setw(8) << setfill('0') << hex << globPoolId.objectId <<
|
<< " update from object "
|
||||||
" and local pool ID " << globPoolId.localPoolId << dec << setfill(' ') << endl;
|
"ID 0x"
|
||||||
|
<< setw(8) << setfill('0') << hex << globPoolId.objectId << " and local pool ID "
|
||||||
|
<< globPoolId.localPoolId << dec << setfill(' ') << endl;
|
||||||
#else
|
#else
|
||||||
sif::printInfo("TestController::handleChangedPoolVariable: %s update from object ID 0x%08x and "
|
sif::printInfo(
|
||||||
"local pool ID %lu\n", printout, globPoolId.objectId, globPoolId.localPoolId);
|
"TestController::handleChangedPoolVariable: %s update from object ID 0x%08x and "
|
||||||
|
"local pool ID %lu\n",
|
||||||
|
printout, globPoolId.objectId, globPoolId.localPoolId);
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
|
||||||
if (storeId == storeId::INVALID_STORE_ADDRESS) {
|
if (storeId == storeId::INVALID_STORE_ADDRESS) {
|
||||||
if (globPoolId.objectId == device0Id) {
|
if (globPoolId.objectId == device0Id) {
|
||||||
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: " << static_cast<int>(
|
sif::info << "Current test variable 0 (UINT8) value: "
|
||||||
deviceDataset0.testUint8Var.value) << std::endl;
|
<< static_cast<int>(deviceDataset0.testUint8Var.value) << 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);
|
||||||
@ -213,5 +218,3 @@ void FsfwTestController::handleChangedPoolVariable(gp_id_t globPoolId, store_add
|
|||||||
currentTraceType = TraceTypes::TRACE_DEV_0_UINT8;
|
currentTraceType = TraceTypes::TRACE_DEV_0_UINT8;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ 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;
|
||||||
@ -28,16 +27,11 @@ private:
|
|||||||
uint8_t traceCycles = 5;
|
uint8_t traceCycles = 5;
|
||||||
uint8_t traceCounter = traceCycles;
|
uint8_t traceCounter = traceCycles;
|
||||||
|
|
||||||
enum TraceTypes {
|
enum TraceTypes { NONE, TRACE_DEV_0_UINT8, TRACE_DEV_0_VECTOR };
|
||||||
NONE,
|
|
||||||
TRACE_DEV_0_UINT8,
|
|
||||||
TRACE_DEV_0_VECTOR
|
|
||||||
};
|
|
||||||
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 initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
@ -45,9 +39,6 @@ private:
|
|||||||
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,
|
||||||
uint32_t* msToReachTheMode) override;
|
uint32_t* msToReachTheMode) override;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* EXAMPLE_COMMON_EXAMPLE_CONTROLLER_FSFWTESTCONTROLLER_H_ */
|
#endif /* EXAMPLE_COMMON_EXAMPLE_CONTROLLER_FSFWTESTCONTROLLER_H_ */
|
||||||
|
@ -1,22 +1,10 @@
|
|||||||
#include "GenericFactory.h"
|
#include "GenericFactory.h"
|
||||||
|
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "fsfw/FSFW.h"
|
|
||||||
#include "tmtc/apid.h"
|
|
||||||
#include "tmtc/pusIds.h"
|
|
||||||
#include "objects/systemObjectList.h"
|
|
||||||
|
|
||||||
#include "example/utility/TmFunnel.h"
|
|
||||||
#include "example/test/FsfwExampleTask.h"
|
#include "example/test/FsfwExampleTask.h"
|
||||||
#include "example/test/FsfwReaderTask.h"
|
#include "example/test/FsfwReaderTask.h"
|
||||||
|
#include "example/utility/TmFunnel.h"
|
||||||
#include "fsfw_tests/internal/InternalUnitTester.h"
|
#include "fsfw/FSFW.h"
|
||||||
#include "fsfw_tests/integration/assemblies/TestAssembly.h"
|
|
||||||
#include "fsfw_tests/integration/devices/TestCookie.h"
|
|
||||||
#include "fsfw_tests/integration/devices/TestDeviceHandler.h"
|
|
||||||
#include "fsfw_tests/integration/devices/TestEchoComIF.h"
|
|
||||||
#include "fsfw_tests/integration/controller/TestController.h"
|
|
||||||
|
|
||||||
#include "fsfw/devicehandlers/CookieIF.h"
|
#include "fsfw/devicehandlers/CookieIF.h"
|
||||||
#include "fsfw/events/EventManager.h"
|
#include "fsfw/events/EventManager.h"
|
||||||
#include "fsfw/health/HealthTable.h"
|
#include "fsfw/health/HealthTable.h"
|
||||||
@ -34,8 +22,15 @@
|
|||||||
#include "fsfw/tcdistribution/PUSDistributor.h"
|
#include "fsfw/tcdistribution/PUSDistributor.h"
|
||||||
#include "fsfw/timemanager/TimeStamper.h"
|
#include "fsfw/timemanager/TimeStamper.h"
|
||||||
#include "fsfw/tmtcpacket/pus/tm.h"
|
#include "fsfw/tmtcpacket/pus/tm.h"
|
||||||
|
#include "fsfw_tests/integration/assemblies/TestAssembly.h"
|
||||||
|
#include "fsfw_tests/integration/controller/TestController.h"
|
||||||
|
#include "fsfw_tests/integration/devices/TestCookie.h"
|
||||||
|
#include "fsfw_tests/integration/devices/TestDeviceHandler.h"
|
||||||
|
#include "fsfw_tests/integration/devices/TestEchoComIF.h"
|
||||||
|
#include "fsfw_tests/internal/InternalUnitTester.h"
|
||||||
|
#include "objects/systemObjectList.h"
|
||||||
|
#include "tmtc/apid.h"
|
||||||
|
#include "tmtc/pusIds.h"
|
||||||
|
|
||||||
void ObjectFactory::produceGenericObjects() {
|
void ObjectFactory::produceGenericObjects() {
|
||||||
#if OBSW_ADD_CORE_COMPONENTS == 1
|
#if OBSW_ADD_CORE_COMPONENTS == 1
|
||||||
@ -45,30 +40,27 @@ void ObjectFactory::produceGenericObjects() {
|
|||||||
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
|
new InternalErrorReporter(objects::INTERNAL_ERROR_REPORTER);
|
||||||
new TimeStamper(objects::TIME_STAMPER);
|
new TimeStamper(objects::TIME_STAMPER);
|
||||||
new CCSDSDistributor(apid::APID, objects::CCSDS_DISTRIBUTOR);
|
new CCSDSDistributor(apid::APID, objects::CCSDS_DISTRIBUTOR);
|
||||||
new PUSDistributor(apid::APID, objects::PUS_DISTRIBUTOR,
|
new PUSDistributor(apid::APID, objects::PUS_DISTRIBUTOR, objects::CCSDS_DISTRIBUTOR);
|
||||||
objects::CCSDS_DISTRIBUTOR);
|
|
||||||
new TmFunnel(objects::TM_FUNNEL);
|
new TmFunnel(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, objects::TM_FUNNEL, 5);
|
pus::PUS_SERVICE_1, objects::TM_FUNNEL, 5);
|
||||||
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS,
|
new Service2DeviceAccess(objects::PUS_SERVICE_2_DEVICE_ACCESS, apid::APID, pus::PUS_SERVICE_2, 3,
|
||||||
apid::APID, pus::PUS_SERVICE_2, 3, 10);
|
10);
|
||||||
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::APID, pus::PUS_SERVICE_3);
|
new Service3Housekeeping(objects::PUS_SERVICE_3_HOUSEKEEPING, apid::APID, pus::PUS_SERVICE_3);
|
||||||
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING,
|
new Service5EventReporting(objects::PUS_SERVICE_5_EVENT_REPORTING, apid::APID, pus::PUS_SERVICE_5,
|
||||||
apid::APID, pus::PUS_SERVICE_5, 50);
|
50);
|
||||||
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT,
|
new Service8FunctionManagement(objects::PUS_SERVICE_8_FUNCTION_MGMT, apid::APID,
|
||||||
apid::APID, pus::PUS_SERVICE_8, 3, 10);
|
pus::PUS_SERVICE_8, 3, 10);
|
||||||
new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::APID,
|
new Service9TimeManagement(objects::PUS_SERVICE_9_TIME_MGMT, apid::APID, pus::PUS_SERVICE_9);
|
||||||
pus::PUS_SERVICE_9);
|
new Service17Test(objects::PUS_SERVICE_17_TEST, apid::APID, pus::PUS_SERVICE_17);
|
||||||
new Service17Test(objects::PUS_SERVICE_17_TEST, apid::APID,
|
|
||||||
pus::PUS_SERVICE_17);
|
|
||||||
new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::APID,
|
new Service20ParameterManagement(objects::PUS_SERVICE_20_PARAMETERS, apid::APID,
|
||||||
pus::PUS_SERVICE_20);
|
pus::PUS_SERVICE_20);
|
||||||
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT,
|
new CService200ModeCommanding(objects::PUS_SERVICE_200_MODE_MGMT, apid::APID,
|
||||||
apid::APID, pus::PUS_SERVICE_200);
|
pus::PUS_SERVICE_200);
|
||||||
#endif /* OBSW_ADD_PUS_STACK == 1 */
|
#endif /* OBSW_ADD_PUS_STACK == 1 */
|
||||||
|
|
||||||
#if OBSW_ADD_TASK_EXAMPLE == 1
|
#if OBSW_ADD_TASK_EXAMPLE == 1
|
||||||
@ -77,7 +69,6 @@ void ObjectFactory::produceGenericObjects() {
|
|||||||
new FsfwExampleTask(objects::TEST_DUMMY_2);
|
new FsfwExampleTask(objects::TEST_DUMMY_2);
|
||||||
new FsfwExampleTask(objects::TEST_DUMMY_3);
|
new FsfwExampleTask(objects::TEST_DUMMY_3);
|
||||||
|
|
||||||
|
|
||||||
bool enablePrintout = false;
|
bool enablePrintout = false;
|
||||||
#if OBSW_TASK_EXAMPLE_PRINTOUT == 1
|
#if OBSW_TASK_EXAMPLE_PRINTOUT == 1
|
||||||
enablePrintout = true;
|
enablePrintout = true;
|
||||||
@ -95,8 +86,8 @@ void ObjectFactory::produceGenericObjects() {
|
|||||||
|
|
||||||
/* Demo device handler object */
|
/* Demo device handler object */
|
||||||
size_t expectedMaxReplyLen = 64;
|
size_t expectedMaxReplyLen = 64;
|
||||||
CookieIF* testCookie = new TestCookie(
|
CookieIF* testCookie = new TestCookie(static_cast<address_t>(testdevice::DeviceIndex::DEVICE_0),
|
||||||
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, testCookie,
|
new TestDevice(objects::TEST_DEVICE_HANDLER_0, objects::TEST_ECHO_COM_IF, testCookie,
|
||||||
testdevice::DeviceIndex::DEVICE_0, enableInfoPrintout);
|
testdevice::DeviceIndex::DEVICE_0, enableInfoPrintout);
|
||||||
@ -110,7 +101,6 @@ void ObjectFactory::produceGenericObjects() {
|
|||||||
|
|
||||||
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
|
#endif /* OBSW_ADD_DEVICE_HANDLER_DEMO == 1 */
|
||||||
|
|
||||||
|
|
||||||
/* Demo controller object */
|
/* Demo controller object */
|
||||||
#if OBSW_ADD_CONTROLLER_DEMO == 1
|
#if OBSW_ADD_CONTROLLER_DEMO == 1
|
||||||
|
|
||||||
@ -153,7 +143,4 @@ void Factory::setStaticFrameworkObjectIds() {
|
|||||||
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
|
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
|
||||||
|
|
||||||
TmPacketBase::timeStamperId = objects::TIME_STAMPER;
|
TmPacketBase::timeStamperId = objects::TIME_STAMPER;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,6 @@ namespace ObjectFactory {
|
|||||||
*/
|
*/
|
||||||
void produceGenericObjects();
|
void produceGenericObjects();
|
||||||
|
|
||||||
}
|
} // namespace ObjectFactory
|
||||||
|
|
||||||
|
|
||||||
#endif /* MISSION_CORE_GENERICFACTORY_H_ */
|
#endif /* MISSION_CORE_GENERICFACTORY_H_ */
|
||||||
|
@ -7,6 +7,4 @@
|
|||||||
//
|
//
|
||||||
//};
|
//};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* EXAMPLE_COMMON_DEVICES_TESTDEVICEHANDLER_H_ */
|
#endif /* EXAMPLE_COMMON_DEVICES_TESTDEVICEHANDLER_H_ */
|
||||||
|
@ -1,25 +1,24 @@
|
|||||||
#include "FsfwExampleTask.h"
|
#include "FsfwExampleTask.h"
|
||||||
|
|
||||||
|
#include <fsfw/ipc/CommandMessage.h>
|
||||||
|
#include <fsfw/ipc/QueueFactory.h>
|
||||||
|
#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
|
#include <fsfw/tasks/TaskFactory.h>
|
||||||
|
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "commonSystemObjects.h"
|
#include "commonSystemObjects.h"
|
||||||
#include "objects/systemObjectList.h"
|
#include "objects/systemObjectList.h"
|
||||||
|
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
FsfwExampleTask::FsfwExampleTask(object_id_t objectId)
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
: SystemObject(objectId),
|
||||||
#include <fsfw/tasks/TaskFactory.h>
|
poolManager(this, nullptr),
|
||||||
#include <fsfw/ipc/QueueFactory.h>
|
demoSet(this),
|
||||||
#include <fsfw/ipc/CommandMessage.h>
|
monitor(objectId, MONITOR_ID, gp_id_t(objectId, FsfwDemoSet::VARIABLE_LIMIT), 30, 10) {
|
||||||
|
commandQueue = QueueFactory::instance()->createMessageQueue(10, CommandMessage::MAX_MESSAGE_SIZE);
|
||||||
|
|
||||||
FsfwExampleTask::FsfwExampleTask(object_id_t objectId): SystemObject(objectId),
|
|
||||||
poolManager(this, nullptr), demoSet(this),
|
|
||||||
monitor(objectId, MONITOR_ID, gp_id_t(objectId, FsfwDemoSet::VARIABLE_LIMIT), 30, 10)
|
|
||||||
{
|
|
||||||
commandQueue = QueueFactory::instance()->createMessageQueue(10,
|
|
||||||
CommandMessage::MAX_MESSAGE_SIZE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FsfwExampleTask::~FsfwExampleTask() {
|
FsfwExampleTask::~FsfwExampleTask() {}
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t FsfwExampleTask::performOperation(uint8_t operationCode) {
|
ReturnValue_t FsfwExampleTask::performOperation(uint8_t operationCode) {
|
||||||
if (operationCode == OpCodes::DELAY_SHORT) {
|
if (operationCode == OpCodes::DELAY_SHORT) {
|
||||||
@ -39,10 +38,8 @@ ReturnValue_t FsfwExampleTask::performOperation(uint8_t operationCode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (operationCode == OpCodes::RECEIVE_RAND_NUM) {
|
if (operationCode == OpCodes::RECEIVE_RAND_NUM) {
|
||||||
result = performReceiveOperation();
|
result = performReceiveOperation();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -80,7 +77,6 @@ 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();
|
||||||
@ -111,36 +107,25 @@ 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){
|
void FsfwExampleTask::setTaskIF(PeriodicTaskIF* task) { this->task = 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 FsfwExampleTask::initializeLocalDataPool(
|
ReturnValue_t FsfwExampleTask::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
localpool::DataPool &localDataPoolMap, LocalDataPoolManager &poolManager) {
|
LocalDataPoolManager& poolManager) {
|
||||||
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE, new PoolEntry<uint32_t>({0}));
|
localDataPoolMap.emplace(FsfwDemoSet::PoolIds::VARIABLE, 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 = demoSet.variableLimit.read(
|
ReturnValue_t result = demoSet.variableLimit.read(MutexIF::TimeoutType::WAITING, 20);
|
||||||
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
|
||||||
@ -174,7 +159,6 @@ ReturnValue_t FsfwExampleTask::performSendOperation() {
|
|||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t randomNumber = rand() % 100;
|
uint32_t randomNumber = rand() % 100;
|
||||||
CommandMessage message;
|
CommandMessage message;
|
||||||
message.setParameter(randomNumber);
|
message.setParameter(randomNumber);
|
||||||
@ -182,11 +166,9 @@ ReturnValue_t FsfwExampleTask::performSendOperation() {
|
|||||||
|
|
||||||
/* Send message using own message queue */
|
/* Send message using own message queue */
|
||||||
ReturnValue_t result = commandQueue->sendMessage(target->getMessageQueueId(), &message);
|
ReturnValue_t result = commandQueue->sendMessage(target->getMessageQueueId(), &message);
|
||||||
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 " << result <<
|
sif::error << "FsfwDemoTask::performSendOperation: Send failed with " << result << std::endl;
|
||||||
std::endl;
|
|
||||||
#else
|
#else
|
||||||
sif::printError("FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
|
sif::printError("FsfwDemoTask::performSendOperation: Send failed with %hu\n", result);
|
||||||
#endif
|
#endif
|
||||||
@ -195,8 +177,7 @@ ReturnValue_t FsfwExampleTask::performSendOperation() {
|
|||||||
/* Send message without via MessageQueueSenderIF */
|
/* Send message without via MessageQueueSenderIF */
|
||||||
result = MessageQueueSenderIF::sendMessage(target->getMessageQueueId(), &message,
|
result = MessageQueueSenderIF::sendMessage(target->getMessageQueueId(), &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 " << result << std::endl;
|
sif::error << "FsfwDemoTask::performSendOperation: Send failed with " << result << std::endl;
|
||||||
#else
|
#else
|
||||||
@ -215,8 +196,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
|
||||||
@ -225,9 +205,9 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
|
|||||||
if (result != MessageQueueIF::EMPTY) {
|
if (result != MessageQueueIF::EMPTY) {
|
||||||
#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.getParameter() <<
|
<< receivedMessage.getSender() << " ObjectId " << receivedMessage.getParameter()
|
||||||
" Queue " << receivedMessage.getParameter2() << std::endl;
|
<< " Queue " << receivedMessage.getParameter2() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -235,30 +215,24 @@ ReturnValue_t FsfwExampleTask::performReceiveOperation() {
|
|||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = senderSet->variableRead.read(MutexIF::TimeoutType::WAITING,
|
result = senderSet->variableRead.read(MutexIF::TimeoutType::WAITING, 20);
|
||||||
20);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
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 " << std::hex <<
|
sif::error << "FsfwDemoTask::performReceiveOperation: Variable " << std::hex << "0x"
|
||||||
"0x" << senderSet->variableRead.getDataPoolId() << std::dec <<
|
<< senderSet->variableRead.getDataPoolId() << std::dec << " has wrong value."
|
||||||
" has wrong value." << std::endl;
|
<< std::endl;
|
||||||
sif::error << "Value: " << demoSet.variableRead.value << ", expected: " <<
|
sif::error << "Value: " << demoSet.variableRead.value
|
||||||
receivedMessage.getParameter() << std::endl;
|
<< ", expected: " << receivedMessage.getParameter() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
#ifndef MISSION_DEMO_FSFWDEMOTASK_H_
|
#ifndef MISSION_DEMO_FSFWDEMOTASK_H_
|
||||||
#define MISSION_DEMO_FSFWDEMOTASK_H_
|
#define MISSION_DEMO_FSFWDEMOTASK_H_
|
||||||
|
|
||||||
#include "testdefinitions/demoDefinitions.h"
|
|
||||||
|
|
||||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
|
||||||
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
||||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
|
||||||
#include <fsfw/ipc/MessageQueueIF.h>
|
#include <fsfw/ipc/MessageQueueIF.h>
|
||||||
#include <fsfw/monitoring/AbsLimitMonitor.h>
|
#include <fsfw/monitoring/AbsLimitMonitor.h>
|
||||||
|
#include <fsfw/objectmanager/SystemObject.h>
|
||||||
|
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||||
|
|
||||||
|
#include "testdefinitions/demoDefinitions.h"
|
||||||
|
|
||||||
class PeriodicTaskIF;
|
class PeriodicTaskIF;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This demo set shows the local data pool functionality and fixed
|
* @brief This demo set shows the local data pool functionality and fixed
|
||||||
* timeslot capabilities of the FSFW.
|
* timeslot capabilities of the FSFW.
|
||||||
@ -25,16 +24,9 @@ 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:
|
class FsfwExampleTask : public ExecutableObjectIF, public SystemObject, public HasLocalDataPoolIF {
|
||||||
public ExecutableObjectIF,
|
|
||||||
public SystemObject,
|
|
||||||
public HasLocalDataPoolIF {
|
|
||||||
public:
|
public:
|
||||||
enum OpCodes {
|
enum OpCodes { SEND_RAND_NUM, RECEIVE_RAND_NUM, DELAY_SHORT };
|
||||||
SEND_RAND_NUM,
|
|
||||||
RECEIVE_RAND_NUM,
|
|
||||||
DELAY_SHORT
|
|
||||||
};
|
|
||||||
|
|
||||||
static constexpr uint8_t MONITOR_ID = 2;
|
static constexpr uint8_t MONITOR_ID = 2;
|
||||||
|
|
||||||
@ -86,7 +78,6 @@ public:
|
|||||||
|
|
||||||
MessageQueueId_t getMessageQueueId();
|
MessageQueueId_t getMessageQueueId();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LocalDataPoolManager poolManager;
|
LocalDataPoolManager poolManager;
|
||||||
FsfwDemoSet* senderSet = nullptr;
|
FsfwDemoSet* senderSet = nullptr;
|
||||||
@ -99,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 initializeLocalDataPool(
|
ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
localpool::DataPool& localDataPoolMap,
|
|
||||||
LocalDataPoolManager& poolManager) override;
|
LocalDataPoolManager& poolManager) override;
|
||||||
LocalDataPoolManager* getHkManagerHandle() override;
|
LocalDataPoolManager* getHkManagerHandle() override;
|
||||||
|
|
||||||
|
@ -1,25 +1,23 @@
|
|||||||
#include "FsfwReaderTask.h"
|
#include "FsfwReaderTask.h"
|
||||||
|
|
||||||
|
#include <OBSWConfig.h>
|
||||||
#include <fsfw/datapool/PoolReadGuard.h>
|
#include <fsfw/datapool/PoolReadGuard.h>
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
#include <fsfw/tasks/TaskFactory.h>
|
#include <fsfw/tasks/TaskFactory.h>
|
||||||
#include <fsfw/timemanager/Stopwatch.h>
|
#include <fsfw/timemanager/Stopwatch.h>
|
||||||
|
|
||||||
#include <OBSWConfig.h>
|
FsfwReaderTask::FsfwReaderTask(object_id_t objectId, bool enablePrintout)
|
||||||
|
: SystemObject(objectId),
|
||||||
|
printoutEnabled(enablePrintout),
|
||||||
FsfwReaderTask::FsfwReaderTask(object_id_t objectId, bool enablePrintout):
|
opDivider(10),
|
||||||
SystemObject(objectId), printoutEnabled(enablePrintout), opDivider(10),
|
readSet(this->getObjectId(), gp_id_t(objects::TEST_DUMMY_1, FsfwDemoSet::PoolIds::VARIABLE),
|
||||||
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 different pool */
|
/* Special protection for set reading because each variable is read from a different pool */
|
||||||
readSet.setReadCommitProtectionBehaviour(true);
|
readSet.setReadCommitProtectionBehaviour(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
FsfwReaderTask::~FsfwReaderTask() {
|
FsfwReaderTask::~FsfwReaderTask() {}
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t FsfwReaderTask::initializeAfterTaskCreation() {
|
ReturnValue_t FsfwReaderTask::initializeAfterTaskCreation() {
|
||||||
/* Give other task some time to set up local data pools. */
|
/* Give other task some time to set up local data pools. */
|
||||||
@ -49,7 +47,8 @@ ReturnValue_t FsfwReaderTask::performOperation(uint8_t operationCode) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if(variable1 and variable2 and variable3) {};
|
if (variable1 and variable2 and variable3) {
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef MISSION_DEMO_FSFWPERIODICTASK_H_
|
#ifndef MISSION_DEMO_FSFWPERIODICTASK_H_
|
||||||
#define MISSION_DEMO_FSFWPERIODICTASK_H_
|
#define MISSION_DEMO_FSFWPERIODICTASK_H_
|
||||||
|
|
||||||
#include "testdefinitions/demoDefinitions.h"
|
|
||||||
|
|
||||||
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
|
#include <fsfw/globalfunctions/PeriodicOperationDivider.h>
|
||||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
#include <fsfw/objectmanager/SystemObject.h>
|
||||||
|
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||||
|
|
||||||
|
#include "testdefinitions/demoDefinitions.h"
|
||||||
|
|
||||||
class FsfwReaderTask : public ExecutableObjectIF, public SystemObject {
|
class FsfwReaderTask : public ExecutableObjectIF, public SystemObject {
|
||||||
public:
|
public:
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
#include "FsfwTestTask.h"
|
#include "FsfwTestTask.h"
|
||||||
|
|
||||||
FsfwTestTask::FsfwTestTask(object_id_t objectId, bool periodicEvent):
|
FsfwTestTask::FsfwTestTask(object_id_t objectId, bool periodicEvent)
|
||||||
TestTask(objectId), periodicEvent(periodicEvent) {
|
: TestTask(objectId), periodicEvent(periodicEvent) {}
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t FsfwTestTask::performPeriodicAction() {
|
ReturnValue_t FsfwTestTask::performPeriodicAction() {
|
||||||
if (periodicEvent) {
|
if (periodicEvent) {
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
#ifndef EXAMPLE_COMMON_EXAMPLE_TEST_FSFWTESTTASK_H_
|
#ifndef EXAMPLE_COMMON_EXAMPLE_TEST_FSFWTESTTASK_H_
|
||||||
#define EXAMPLE_COMMON_EXAMPLE_TEST_FSFWTESTTASK_H_
|
#define EXAMPLE_COMMON_EXAMPLE_TEST_FSFWTESTTASK_H_
|
||||||
|
|
||||||
#include "fsfw_tests/integration/task/TestTask.h"
|
|
||||||
|
|
||||||
#include "fsfw/events/Event.h"
|
|
||||||
#include "events/subsystemIdRanges.h"
|
#include "events/subsystemIdRanges.h"
|
||||||
|
#include "fsfw/events/Event.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 = event::makeEvent(subsystemId, 0, severity::INFO);
|
static constexpr Event TEST_EVENT = event::makeEvent(subsystemId, 0, severity::INFO);
|
||||||
|
@ -3,13 +3,11 @@
|
|||||||
#include <fsfw/ipc/MutexFactory.h>
|
#include <fsfw/ipc/MutexFactory.h>
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
|
|
||||||
|
|
||||||
void MutexExample::example() {
|
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 = mutex->lockMutex(MutexIF::TimeoutType::WAITING,
|
ReturnValue_t result = mutex->lockMutex(MutexIF::TimeoutType::WAITING, 2 * 60 * 1000);
|
||||||
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 << std::endl;
|
sif::error << "MutexExample::example: Lock Failed with " << result << std::endl;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#ifndef MISSION_DEMO_DEMODEFINITIONS_H_
|
#ifndef MISSION_DEMO_DEMODEFINITIONS_H_
|
||||||
#define MISSION_DEMO_DEMODEFINITIONS_H_
|
#define MISSION_DEMO_DEMODEFINITIONS_H_
|
||||||
|
|
||||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
|
||||||
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
#include <fsfw/datapoollocal/LocalPoolVariable.h>
|
||||||
|
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This demo set showcases the local data pool functionality of the
|
* @brief This demo set showcases the local data pool functionality of the
|
||||||
@ -13,25 +13,20 @@
|
|||||||
*/
|
*/
|
||||||
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 {
|
enum PoolIds { VARIABLE, VARIABLE_LIMIT };
|
||||||
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>(sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_READ);
|
||||||
|
lp_var_t<uint32_t> variableWrite =
|
||||||
|
lp_var_t<uint32_t>(sid.objectId, PoolIds::VARIABLE, this, pool_rwm_t::VAR_WRITE);
|
||||||
|
lp_var_t<uint16_t> variableLimit =
|
||||||
|
lp_var_t<uint16_t>(sid.objectId, PoolIds::VARIABLE_LIMIT, this);
|
||||||
|
|
||||||
lp_var_t<uint32_t> variableRead = lp_var_t<uint32_t>(sid.objectId,
|
|
||||||
PoolIds::VARIABLE, this, pool_rwm_t::VAR_READ);
|
|
||||||
lp_var_t<uint32_t> variableWrite = lp_var_t<uint32_t>(sid.objectId,
|
|
||||||
PoolIds::VARIABLE, this, pool_rwm_t::VAR_WRITE);
|
|
||||||
lp_var_t<uint16_t> variableLimit = lp_var_t<uint16_t>(sid.objectId,
|
|
||||||
PoolIds::VARIABLE_LIMIT, this);
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,21 +38,17 @@ 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,
|
CompleteDemoReadSet(object_id_t owner, gp_id_t variable1, gp_id_t variable2, gp_id_t variable3)
|
||||||
gp_id_t variable2, 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),
|
||||||
variable3(variable3, this, pool_rwm_t::VAR_READ) {}
|
variable3(variable3, this, pool_rwm_t::VAR_READ) {}
|
||||||
|
|
||||||
|
|
||||||
lp_var_t<uint32_t> variable1;
|
lp_var_t<uint32_t> variable1;
|
||||||
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_ */
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
#include <fsfw/tmtcpacket/pus/tc.h>
|
|
||||||
#include <fsfw/tmtcpacket/pus/tm.h>
|
|
||||||
#include <fsfw/globalfunctions/arrayprinter.h>
|
#include <fsfw/globalfunctions/arrayprinter.h>
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
|
#include <fsfw/tmtcpacket/pus/tc.h>
|
||||||
|
#include <fsfw/tmtcpacket/pus/tm.h>
|
||||||
#include <mission/utility/PusPacketCreator.h>
|
#include <mission/utility/PusPacketCreator.h>
|
||||||
|
|
||||||
void PusPacketCreator::createPusPacketAndPrint() {
|
void PusPacketCreator::createPusPacketAndPrint() {
|
||||||
// TODO: use TC packet stored here instead..
|
// TODO: use TC packet stored here instead..
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,14 @@ 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 << "("
|
sif::error << "InitMission: Adding object " << objName << "(" << std::setw(8) << std::setfill('0')
|
||||||
<< std::setw(8) << std::setfill('0') << std::hex << objectId
|
<< std::hex << objectId << std::dec << ") failed." << std::endl;
|
||||||
<< std::dec << ") failed." << std::endl;
|
|
||||||
#else
|
#else
|
||||||
sif::printError("InitMission: Adding object %s (0x%08x) failed.\n",
|
sif::printError("InitMission: Adding object %s (0x%08x) failed.\n", objName,
|
||||||
objName, static_cast<unsigned int>(objectId));
|
static_cast<unsigned int>(objectId));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} // namespace task
|
||||||
|
|
||||||
#endif /* MISSION_UTILITY_TASKCREATION_H_ */
|
#endif /* MISSION_UTILITY_TASKCREATION_H_ */
|
||||||
|
@ -2,22 +2,21 @@
|
|||||||
|
|
||||||
#include <fsfw/ipc/QueueFactory.h>
|
#include <fsfw/ipc/QueueFactory.h>
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
#include <fsfw/tmtcpacket/pus/tm.h>
|
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
|
#include <fsfw/tmtcpacket/pus/tm.h>
|
||||||
|
|
||||||
object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT;
|
object_id_t TmFunnel::downlinkDestination = objects::NO_OBJECT;
|
||||||
object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
|
object_id_t TmFunnel::storageDestination = objects::NO_OBJECT;
|
||||||
|
|
||||||
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth):
|
TmFunnel::TmFunnel(object_id_t objectId, uint32_t messageDepth)
|
||||||
SystemObject(objectId), messageDepth(messageDepth) {
|
: SystemObject(objectId), messageDepth(messageDepth) {
|
||||||
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
|
tmQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
|
||||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||||
storageQueue = QueueFactory::instance()->createMessageQueue(messageDepth,
|
storageQueue = QueueFactory::instance()->createMessageQueue(
|
||||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
messageDepth, MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TmFunnel::~TmFunnel() {
|
TmFunnel::~TmFunnel() {}
|
||||||
}
|
|
||||||
|
|
||||||
MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) {
|
MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) {
|
||||||
return tmQueue->getId();
|
return tmQueue->getId();
|
||||||
@ -26,8 +25,7 @@ MessageQueueId_t TmFunnel::getReportReceptionQueue(uint8_t virtualChannel) {
|
|||||||
ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
|
ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
|
||||||
TmTcMessage currentMessage;
|
TmTcMessage currentMessage;
|
||||||
ReturnValue_t status = tmQueue->receiveMessage(¤tMessage);
|
ReturnValue_t status = tmQueue->receiveMessage(¤tMessage);
|
||||||
while(status == HasReturnvaluesIF::RETURN_OK)
|
while (status == HasReturnvaluesIF::RETURN_OK) {
|
||||||
{
|
|
||||||
status = handlePacket(¤tMessage);
|
status = handlePacket(¤tMessage);
|
||||||
if (status != HasReturnvaluesIF::RETURN_OK) {
|
if (status != HasReturnvaluesIF::RETURN_OK) {
|
||||||
break;
|
break;
|
||||||
@ -37,8 +35,7 @@ ReturnValue_t TmFunnel::performOperation(uint8_t operationCode) {
|
|||||||
|
|
||||||
if (status == MessageQueueIF::EMPTY) {
|
if (status == MessageQueueIF::EMPTY) {
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -46,16 +43,14 @@ 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 = tmPool->modifyData(message->getStorageId(),
|
ReturnValue_t result = tmPool->modifyData(message->getStorageId(), &packetData, &size);
|
||||||
&packetData, &size);
|
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
TmPacketPusC packet(packetData);
|
TmPacketPusC packet(packetData);
|
||||||
packet.setPacketSequenceCount(this->sourceSequenceCount);
|
packet.setPacketSequenceCount(this->sourceSequenceCount);
|
||||||
sourceSequenceCount++;
|
sourceSequenceCount++;
|
||||||
sourceSequenceCount = sourceSequenceCount %
|
sourceSequenceCount = sourceSequenceCount % SpacePacketBase::LIMIT_SEQUENCE_COUNT;
|
||||||
SpacePacketBase::LIMIT_SEQUENCE_COUNT;
|
|
||||||
packet.setErrorControl();
|
packet.setErrorControl();
|
||||||
|
|
||||||
result = tmQueue->sendToDefault(message);
|
result = tmQueue->sendToDefault(message);
|
||||||
@ -81,24 +76,24 @@ ReturnValue_t TmFunnel::handlePacket(TmTcMessage* message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t TmFunnel::initialize() {
|
ReturnValue_t TmFunnel::initialize() {
|
||||||
|
|
||||||
tmPool = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
|
tmPool = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
|
||||||
if (tmPool == nullptr) {
|
if (tmPool == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "TmFunnel::initialize: TM store not set." << std::endl;
|
sif::error << "TmFunnel::initialize: TM store not set." << std::endl;
|
||||||
sif::error << "Make sure the tm store is set up properly and implements StorageManagerIF" <<
|
sif::error << "Make sure the tm store is set up properly and implements StorageManagerIF"
|
||||||
std::endl;
|
<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
AcceptsTelemetryIF* tmTarget = ObjectManager::instance()->
|
AcceptsTelemetryIF* tmTarget =
|
||||||
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." << std::endl;
|
sif::error << "TmFunnel::initialize: Downlink Destination not set." << std::endl;
|
||||||
sif::error << "Make sure the downlink destination object is set up properly and implements "
|
sif::error << "Make sure the downlink destination object is set up properly and implements "
|
||||||
"AcceptsTelemetryIF" << std::endl;
|
"AcceptsTelemetryIF"
|
||||||
|
<< std::endl;
|
||||||
#endif
|
#endif
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
@ -109,11 +104,10 @@ ReturnValue_t TmFunnel::initialize() {
|
|||||||
return SystemObject::initialize();
|
return SystemObject::initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
AcceptsTelemetryIF* storageTarget = ObjectManager::instance()->
|
AcceptsTelemetryIF* storageTarget =
|
||||||
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();
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#ifndef MISSION_UTILITY_TMFUNNEL_H_
|
#ifndef MISSION_UTILITY_TMFUNNEL_H_
|
||||||
#define MISSION_UTILITY_TMFUNNEL_H_
|
#define MISSION_UTILITY_TMFUNNEL_H_
|
||||||
|
|
||||||
|
#include <fsfw/ipc/MessageQueueIF.h>
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
#include <fsfw/objectmanager/SystemObject.h>
|
||||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||||
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
|
#include <fsfw/tmtcservices/AcceptsTelemetryIF.h>
|
||||||
#include <fsfw/ipc/MessageQueueIF.h>
|
|
||||||
#include <fsfw/tmtcservices/TmTcMessage.h>
|
#include <fsfw/tmtcservices/TmTcMessage.h>
|
||||||
|
|
||||||
namespace Factory {
|
namespace Factory {
|
||||||
@ -19,17 +19,14 @@ void setStaticFrameworkObjectIds();
|
|||||||
* @ingroup utility
|
* @ingroup utility
|
||||||
* @author J. Meier
|
* @author J. Meier
|
||||||
*/
|
*/
|
||||||
class TmFunnel:
|
class TmFunnel : public AcceptsTelemetryIF, public ExecutableObjectIF, public SystemObject {
|
||||||
public AcceptsTelemetryIF,
|
|
||||||
public ExecutableObjectIF,
|
|
||||||
public SystemObject {
|
|
||||||
friend void(Factory::setStaticFrameworkObjectIds)();
|
friend void(Factory::setStaticFrameworkObjectIds)();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20);
|
TmFunnel(object_id_t objectId, uint32_t messageDepth = 20);
|
||||||
virtual ~TmFunnel();
|
virtual ~TmFunnel();
|
||||||
|
|
||||||
virtual MessageQueueId_t getReportReceptionQueue(
|
virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override;
|
||||||
uint8_t virtualChannel = 0) override;
|
|
||||||
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
||||||
virtual ReturnValue_t initialize() override;
|
virtual ReturnValue_t initialize() override;
|
||||||
|
|
||||||
|
@ -5,14 +5,17 @@
|
|||||||
* Authors:
|
* Authors:
|
||||||
*
|
*
|
||||||
* Assembled from the code released on Stackoverflow by:
|
* Assembled from the code released on Stackoverflow by:
|
||||||
* Dennis (instructable.com/member/nqtronix) | https://stackoverflow.com/questions/23032002/c-c-how-to-get-integer-unix-timestamp-of-build-time-not-string
|
* Dennis (instructable.com/member/nqtronix) |
|
||||||
|
* https://stackoverflow.com/questions/23032002/c-c-how-to-get-integer-unix-timestamp-of-build-time-not-string
|
||||||
* and
|
* and
|
||||||
* Alexis Wilke | https://stackoverflow.com/questions/10538444/do-you-know-of-a-c-macro-to-compute-unix-time-and-date
|
* Alexis Wilke |
|
||||||
|
* https://stackoverflow.com/questions/10538444/do-you-know-of-a-c-macro-to-compute-unix-time-and-date
|
||||||
*
|
*
|
||||||
* Assembled by Jean Rabault
|
* Assembled by Jean Rabault
|
||||||
*
|
*
|
||||||
* UNIX_TIMESTAMP gives the UNIX timestamp (unsigned long integer of seconds since 1st Jan 1970) of compilation from macros using the compiler defined __TIME__ macro.
|
* UNIX_TIMESTAMP gives the UNIX timestamp (unsigned long integer of seconds since 1st Jan 1970) of
|
||||||
* This should include Gregorian calendar leap days, in particular the 29ths of February, 100 and 400 years modulo leaps.
|
* compilation from macros using the compiler defined __TIME__ macro. This should include Gregorian
|
||||||
|
* calendar leap days, in particular the 29ths of February, 100 and 400 years modulo leaps.
|
||||||
*
|
*
|
||||||
* Careful: __TIME__ is the local time of the computer, NOT the UTC time in general!
|
* Careful: __TIME__ is the local time of the computer, NOT the UTC time in general!
|
||||||
*
|
*
|
||||||
@ -34,18 +37,20 @@
|
|||||||
#define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i) * 10 + str[i + 3] - '0')
|
#define CONV_STR2DEC_4(str, i) (CONV_STR2DEC_3(str, i) * 10 + str[i + 3] - '0')
|
||||||
|
|
||||||
// Custom "glue logic" to convert the month name to a usable number
|
// Custom "glue logic" to convert the month name to a usable number
|
||||||
#define GET_MONTH(str, i) (str[i]=='J' && str[i+1]=='a' && str[i+2]=='n' ? 1 : \
|
#define GET_MONTH(str, i) \
|
||||||
str[i]=='F' && str[i+1]=='e' && str[i+2]=='b' ? 2 : \
|
(str[i] == 'J' && str[i + 1] == 'a' && str[i + 2] == 'n' ? 1 \
|
||||||
str[i]=='M' && str[i+1]=='a' && str[i+2]=='r' ? 3 : \
|
: str[i] == 'F' && str[i + 1] == 'e' && str[i + 2] == 'b' ? 2 \
|
||||||
str[i]=='A' && str[i+1]=='p' && str[i+2]=='r' ? 4 : \
|
: str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'r' ? 3 \
|
||||||
str[i]=='M' && str[i+1]=='a' && str[i+2]=='y' ? 5 : \
|
: str[i] == 'A' && str[i + 1] == 'p' && str[i + 2] == 'r' ? 4 \
|
||||||
str[i]=='J' && str[i+1]=='u' && str[i+2]=='n' ? 6 : \
|
: str[i] == 'M' && str[i + 1] == 'a' && str[i + 2] == 'y' ? 5 \
|
||||||
str[i]=='J' && str[i+1]=='u' && str[i+2]=='l' ? 7 : \
|
: str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'n' ? 6 \
|
||||||
str[i]=='A' && str[i+1]=='u' && str[i+2]=='g' ? 8 : \
|
: str[i] == 'J' && str[i + 1] == 'u' && str[i + 2] == 'l' ? 7 \
|
||||||
str[i]=='S' && str[i+1]=='e' && str[i+2]=='p' ? 9 : \
|
: str[i] == 'A' && str[i + 1] == 'u' && str[i + 2] == 'g' ? 8 \
|
||||||
str[i]=='O' && str[i+1]=='c' && str[i+2]=='t' ? 10 : \
|
: str[i] == 'S' && str[i + 1] == 'e' && str[i + 2] == 'p' ? 9 \
|
||||||
str[i]=='N' && str[i+1]=='o' && str[i+2]=='v' ? 11 : \
|
: str[i] == 'O' && str[i + 1] == 'c' && str[i + 2] == 't' ? 10 \
|
||||||
str[i]=='D' && str[i+1]=='e' && str[i+2]=='c' ? 12 : 0)
|
: str[i] == 'N' && str[i + 1] == 'o' && str[i + 2] == 'v' ? 11 \
|
||||||
|
: str[i] == 'D' && str[i + 1] == 'e' && str[i + 2] == 'c' ? 12 \
|
||||||
|
: 0)
|
||||||
|
|
||||||
// extract the information from the time string given by __TIME__ and __DATE__
|
// extract the information from the time string given by __TIME__ and __DATE__
|
||||||
#define __TIME_SECONDS__ CONV_STR2DEC_2(__TIME__, 6)
|
#define __TIME_SECONDS__ CONV_STR2DEC_2(__TIME__, 6)
|
||||||
@ -57,41 +62,29 @@
|
|||||||
|
|
||||||
// Days in February
|
// Days in February
|
||||||
#define _UNIX_TIMESTAMP_FDAY(year) \
|
#define _UNIX_TIMESTAMP_FDAY(year) \
|
||||||
(((year) % 400) == 0UL ? 29UL : \
|
(((year) % 400) == 0UL ? 29UL \
|
||||||
(((year) % 100) == 0UL ? 28UL : \
|
: (((year) % 100) == 0UL ? 28UL : (((year) % 4) == 0UL ? 29UL : 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 \
|
(month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) /* April */ + \
|
||||||
/* February */ + (month >= 2 ? 31UL : 0UL) \
|
(month >= 4 ? 31UL : 0UL) /* May */ + (month >= 5 ? 30UL : 0UL) /* June */ + \
|
||||||
/* March */ + (month >= 3 ? _UNIX_TIMESTAMP_FDAY(year) : 0UL) \
|
(month >= 6 ? 31UL : 0UL) /* July */ + (month >= 7 ? 30UL : 0UL) /* August */ + \
|
||||||
/* April */ + (month >= 4 ? 31UL : 0UL) \
|
(month >= 8 ? 31UL : 0UL) /* September */ + (month >= 9 ? 31UL : 0UL) /* October */ + \
|
||||||
/* May */ + (month >= 5 ? 30UL : 0UL) \
|
(month >= 10 ? 30UL : 0UL) /* November */ + (month >= 11 ? 31UL : 0UL) /* December */ + \
|
||||||
/* June */ + (month >= 6 ? 31UL : 0UL) \
|
(month >= 12 ? 30UL : 0UL))
|
||||||
/* July */ + (month >= 7 ? 30UL : 0UL) \
|
|
||||||
/* August */ + (month >= 8 ? 31UL : 0UL) \
|
|
||||||
/* September */+ (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 \
|
(/* time */ second + minute * SEC_PER_MIN + hour * SEC_PER_HOUR + \
|
||||||
+ minute * SEC_PER_MIN \
|
/* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY + \
|
||||||
+ hour * SEC_PER_HOUR \
|
/* year */ (year - 1970UL) * SEC_PER_YEAR + ((year - 1969UL) / 4UL) * SEC_PER_DAY - \
|
||||||
+ /* year day (month + day) */ (_UNIX_TIMESTAMP_YDAY(year, month, day) - 1) * SEC_PER_DAY \
|
((year - 1901UL) / 100UL) * SEC_PER_DAY + ((year - 1601UL) / 400UL) * SEC_PER_DAY)
|
||||||
+ /* year */ (year - 1970UL) * SEC_PER_YEAR \
|
|
||||||
+ ((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 (_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, __TIME_MINUTES__, __TIME_SECONDS__))
|
#define UNIX_TIMESTAMP \
|
||||||
|
(_UNIX_TIMESTAMP(__TIME_YEARS__, __TIME_MONTH__, __TIME_DAYS__, __TIME_HOURS__, \
|
||||||
|
__TIME_MINUTES__, __TIME_SECONDS__))
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "utility.h"
|
#include "utility.h"
|
||||||
|
|
||||||
#include <FSFWConfig.h>
|
#include <FSFWConfig.h>
|
||||||
#include <OBSWVersion.h>
|
#include <OBSWVersion.h>
|
||||||
|
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
|
|
||||||
void utility::commonInitPrint(const char* const os, const char* const board) {
|
void utility::commonInitPrint(const char* const os, const char* const board) {
|
||||||
@ -9,8 +9,8 @@ void utility::commonInitPrint(const char *const os, const char* const board) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#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 << " --" << std::endl;
|
<< FSFW_EXAMPLE_SUBVERSION << "." << FSFW_EXAMPLE_REVISION << " --" << std::endl;
|
||||||
std::cout << "-- Compiled for " << board << " --" << std::endl;
|
std::cout << "-- Compiled for " << board << " --" << std::endl;
|
||||||
std::cout << "-- Compiled on " << __DATE__ << " " << __TIME__ << " --" << std::endl;
|
std::cout << "-- Compiled on " << __DATE__ << " " << __TIME__ << " --" << std::endl;
|
||||||
#else
|
#else
|
||||||
|
@ -7,5 +7,4 @@ void commonInitPrint(const char *const os, const char* const board);
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* COMMON_UTILITY_UTILITY_H_ */
|
#endif /* COMMON_UTILITY_UTILITY_H_ */
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
#include "STM32TestTask.h"
|
#include "STM32TestTask.h"
|
||||||
#include "stm32h7xx_nucleo.h"
|
|
||||||
#include "OBSWConfig.h"
|
|
||||||
|
|
||||||
STM32TestTask::STM32TestTask(object_id_t objectId, bool enablePrintout,
|
#include "OBSWConfig.h"
|
||||||
bool blinkyLed): TestTask(objectId), blinkyLed(blinkyLed) {
|
#include "stm32h7xx_nucleo.h"
|
||||||
|
|
||||||
|
STM32TestTask::STM32TestTask(object_id_t objectId, bool enablePrintout, bool blinkyLed)
|
||||||
|
: TestTask(objectId), blinkyLed(blinkyLed) {
|
||||||
BSP_LED_Init(LED1);
|
BSP_LED_Init(LED1);
|
||||||
BSP_LED_Init(LED2);
|
BSP_LED_Init(LED2);
|
||||||
BSP_LED_Init(LED3);
|
BSP_LED_Init(LED3);
|
||||||
@ -27,7 +28,6 @@ ReturnValue_t STM32TestTask::initialize() {
|
|||||||
if (testSpi) {
|
if (testSpi) {
|
||||||
spiComIF = new SpiComIF(objects::SPI_COM_IF);
|
spiComIF = new SpiComIF(objects::SPI_COM_IF);
|
||||||
spiTest = new SpiTest(*spiComIF);
|
spiTest = new SpiTest(*spiComIF);
|
||||||
|
|
||||||
}
|
}
|
||||||
return TestTask::initialize();
|
return TestTask::initialize();
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,13 @@ public:
|
|||||||
|
|
||||||
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;
|
||||||
|
|
||||||
bool blinkyLed = false;
|
bool blinkyLed = false;
|
||||||
bool testSpi = true;
|
bool testSpi = true;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* BSP_STM32_BOARDTEST_STM32TESTTASK_H_ */
|
#endif /* BSP_STM32_BOARDTEST_STM32TESTTASK_H_ */
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
#include "TmTcLwIpUdpBridge.h"
|
#include "TmTcLwIpUdpBridge.h"
|
||||||
#include "udp_config.h"
|
|
||||||
|
#include <OBSWConfig.h>
|
||||||
|
#include <fsfw/ipc/MutexGuard.h>
|
||||||
|
#include <fsfw/serialize/EndianConverter.h>
|
||||||
|
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||||
|
|
||||||
#include "app_ethernet.h"
|
#include "app_ethernet.h"
|
||||||
#include "ethernetif.h"
|
#include "ethernetif.h"
|
||||||
#include <OBSWConfig.h>
|
#include "udp_config.h"
|
||||||
|
|
||||||
#include <fsfw/ipc/MutexGuard.h>
|
TmTcLwIpUdpBridge::TmTcLwIpUdpBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor,
|
||||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
object_id_t tmStoreId, object_id_t tcStoreId)
|
||||||
#include <fsfw/serialize/EndianConverter.h>
|
: TmTcBridge(objectId, ccsdsPacketDistributor, tmStoreId, tcStoreId) {
|
||||||
|
|
||||||
|
|
||||||
TmTcLwIpUdpBridge::TmTcLwIpUdpBridge(object_id_t objectId,
|
|
||||||
object_id_t ccsdsPacketDistributor, object_id_t tmStoreId,
|
|
||||||
object_id_t tcStoreId):
|
|
||||||
TmTcBridge(objectId, ccsdsPacketDistributor, tmStoreId, tcStoreId) {
|
|
||||||
TmTcLwIpUdpBridge::lastAdd.addr = IPADDR_TYPE_ANY;
|
TmTcLwIpUdpBridge::lastAdd.addr = IPADDR_TYPE_ANY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,21 +31,16 @@ ReturnValue_t TmTcLwIpUdpBridge::udp_server_init(void) {
|
|||||||
err_t err;
|
err_t err;
|
||||||
/* Create a new UDP control block */
|
/* Create a new UDP control block */
|
||||||
TmTcLwIpUdpBridge::upcb = udp_new();
|
TmTcLwIpUdpBridge::upcb = udp_new();
|
||||||
if (TmTcLwIpUdpBridge::upcb)
|
if (TmTcLwIpUdpBridge::upcb) {
|
||||||
{
|
|
||||||
/* Bind the upcb to the UDP_PORT port */
|
/* Bind the upcb to the UDP_PORT port */
|
||||||
/* Using IP_ADDR_ANY allow the upcb to be used by any local interface */
|
/* Using IP_ADDR_ANY allow the upcb to be used by any local interface */
|
||||||
err = udp_bind(TmTcLwIpUdpBridge::upcb, IP_ADDR_ANY, UDP_SERVER_PORT);
|
err = udp_bind(TmTcLwIpUdpBridge::upcb, IP_ADDR_ANY, UDP_SERVER_PORT);
|
||||||
|
|
||||||
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);
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
@ -67,15 +61,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 "
|
sif::info << "TmTcLwIpUdpBridge: Client IP Port " << (int)portSwapped << std::endl;
|
||||||
<< (int)portSwapped << 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
|
||||||
@ -111,23 +103,21 @@ ReturnValue_t TmTcLwIpUdpBridge::sendTm(const uint8_t * data, size_t dataLen) {
|
|||||||
|
|
||||||
/* free the UDP connection, so we can accept new clients */
|
/* free the UDP connection, so we can accept new clients */
|
||||||
udp_disconnect(TmTcLwIpUdpBridge::upcb);
|
udp_disconnect(TmTcLwIpUdpBridge::upcb);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
}
|
}
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TmTcLwIpUdpBridge::udp_server_receive_callback(void* arg, struct udp_pcb* upcb_,
|
||||||
void TmTcLwIpUdpBridge::udp_server_receive_callback(void* arg,
|
struct pbuf* p, const ip_addr_t* addr,
|
||||||
struct udp_pcb* upcb_, struct pbuf* p, const ip_addr_t* addr,
|
|
||||||
u16_t port) {
|
u16_t port) {
|
||||||
struct pbuf* p_tx = nullptr;
|
struct pbuf* p_tx = nullptr;
|
||||||
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 << "TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid UDP bridge!" <<
|
sif::warning << "TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid UDP bridge!"
|
||||||
std::endl;
|
<< std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid UDP bridge!\n");
|
sif::printWarning("TmTcLwIpUdpBridge::udp_server_receive_callback: Invalid UDP bridge!\n");
|
||||||
#endif
|
#endif
|
||||||
@ -135,8 +125,7 @@ void TmTcLwIpUdpBridge::udp_server_receive_callback(void* arg,
|
|||||||
/* allocate pbuf from RAM*/
|
/* allocate pbuf from RAM*/
|
||||||
p_tx = pbuf_alloc(PBUF_TRANSPORT, p->len, PBUF_RAM);
|
p_tx = pbuf_alloc(PBUF_TRANSPORT, p->len, PBUF_RAM);
|
||||||
|
|
||||||
if(p_tx != NULL)
|
if (p_tx != NULL) {
|
||||||
{
|
|
||||||
if (udpBridge != nullptr) {
|
if (udpBridge != nullptr) {
|
||||||
MutexGuard lg(udpBridge->bridgeLock);
|
MutexGuard lg(udpBridge->bridgeLock);
|
||||||
udpBridge->upcb = upcb_;
|
udpBridge->upcb = upcb_;
|
||||||
@ -161,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(&storeId,
|
ReturnValue_t returnValue =
|
||||||
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;
|
||||||
@ -171,8 +160,7 @@ void TmTcLwIpUdpBridge::udp_server_receive_callback(void* arg,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
TmTcMessage message(storeId);
|
TmTcMessage message(storeId);
|
||||||
if (udpBridge->tmTcReceptionQueue->sendToDefault(&message)
|
if (udpBridge->tmTcReceptionQueue->sendToDefault(&message) != RETURN_OK) {
|
||||||
!= RETURN_OK) {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "TmTcLwIpUdpBridgw::udp_server_receive_callback:"
|
sif::warning << "TmTcLwIpUdpBridgw::udp_server_receive_callback:"
|
||||||
<< " Sending message to queue failed" << std::endl;
|
<< " Sending message to queue failed" << std::endl;
|
||||||
@ -185,9 +173,7 @@ void TmTcLwIpUdpBridge::udp_server_receive_callback(void* arg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Caller must ensure thread-safety */
|
/* Caller must ensure thread-safety */
|
||||||
bool TmTcLwIpUdpBridge::comLinkUp() const {
|
bool TmTcLwIpUdpBridge::comLinkUp() const { return communicationLinkUp; }
|
||||||
return communicationLinkUp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Caller must ensure thread-safety */
|
/* Caller must ensure thread-safety */
|
||||||
void TmTcLwIpUdpBridge::physicalConnectStatusChange(bool connect) {
|
void TmTcLwIpUdpBridge::physicalConnectStatusChange(bool connect) {
|
||||||
@ -195,8 +181,7 @@ void TmTcLwIpUdpBridge::physicalConnectStatusChange(bool connect) {
|
|||||||
/* Physical connection does not mean there is a recipient to send packets too.
|
/* Physical connection does not mean there is a recipient to send packets too.
|
||||||
This will be done by the receive callback! */
|
This will be done by the receive callback! */
|
||||||
physicalConnection = true;
|
physicalConnection = true;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
physicalConnection = false;
|
physicalConnection = false;
|
||||||
/* If there is no physical connection, we can't send anything back */
|
/* If there is no physical connection, we can't send anything back */
|
||||||
registerCommDisconnect();
|
registerCommDisconnect();
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
#define BSP_STM32_RTEMS_NETWORKING_TMTCUDPBRIDGE_H_
|
#define BSP_STM32_RTEMS_NETWORKING_TMTCUDPBRIDGE_H_
|
||||||
|
|
||||||
#include <fsfw/tmtcservices/TmTcBridge.h>
|
#include <fsfw/tmtcservices/TmTcBridge.h>
|
||||||
|
|
||||||
#include <lwip/udp.h>
|
|
||||||
#include <lwip/ip_addr.h>
|
#include <lwip/ip_addr.h>
|
||||||
|
#include <lwip/udp.h>
|
||||||
|
|
||||||
#define TCPIP_RECV_WIRETAPPING 0
|
#define TCPIP_RECV_WIRETAPPING 0
|
||||||
|
|
||||||
@ -13,9 +12,9 @@
|
|||||||
*/
|
*/
|
||||||
class TmTcLwIpUdpBridge : public TmTcBridge {
|
class TmTcLwIpUdpBridge : public TmTcBridge {
|
||||||
friend class UdpTcLwIpPollingTask;
|
friend class UdpTcLwIpPollingTask;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TmTcLwIpUdpBridge(object_id_t objectId,
|
TmTcLwIpUdpBridge(object_id_t objectId, object_id_t ccsdsPacketDistributor, object_id_t tmStoreId,
|
||||||
object_id_t ccsdsPacketDistributor, object_id_t tmStoreId,
|
|
||||||
object_id_t tcStoreId);
|
object_id_t tcStoreId);
|
||||||
virtual ~TmTcLwIpUdpBridge();
|
virtual ~TmTcLwIpUdpBridge();
|
||||||
|
|
||||||
@ -45,9 +44,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,
|
static void udp_server_receive_callback(void *arg, struct udp_pcb *upcb_, struct pbuf *p,
|
||||||
struct udp_pcb *upcb_, 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.
|
||||||
|
@ -1,26 +1,22 @@
|
|||||||
#include "UdpTcLwIpPollingTask.h"
|
#include "UdpTcLwIpPollingTask.h"
|
||||||
#include "TmTcLwIpUdpBridge.h"
|
|
||||||
#include "app_ethernet.h"
|
|
||||||
#include "ethernetif.h"
|
|
||||||
#include "app_dhcp.h"
|
|
||||||
#include "networking.h"
|
|
||||||
#include <hardware_init.h>
|
#include <hardware_init.h>
|
||||||
|
|
||||||
|
#include "TmTcLwIpUdpBridge.h"
|
||||||
|
#include "app_dhcp.h"
|
||||||
|
#include "app_ethernet.h"
|
||||||
|
#include "ethernetif.h"
|
||||||
#include "fsfw/ipc/MutexGuard.h"
|
#include "fsfw/ipc/MutexGuard.h"
|
||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
|
||||||
#include "fsfw/objectmanager/ObjectManager.h"
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
|
|
||||||
#include "lwip/timeouts.h"
|
#include "lwip/timeouts.h"
|
||||||
|
#include "networking.h"
|
||||||
|
|
||||||
UdpTcLwIpPollingTask::UdpTcLwIpPollingTask(object_id_t objectId, object_id_t bridgeId,
|
UdpTcLwIpPollingTask::UdpTcLwIpPollingTask(object_id_t objectId, object_id_t bridgeId,
|
||||||
struct netif* gnetif):
|
struct netif* gnetif)
|
||||||
SystemObject(objectId), periodicHandleCounter(0), bridgeId(bridgeId), gnetif(gnetif) {
|
: SystemObject(objectId), periodicHandleCounter(0), bridgeId(bridgeId), gnetif(gnetif) {}
|
||||||
}
|
|
||||||
|
|
||||||
UdpTcLwIpPollingTask::~UdpTcLwIpPollingTask() {
|
UdpTcLwIpPollingTask::~UdpTcLwIpPollingTask() {}
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t UdpTcLwIpPollingTask::initialize() {
|
ReturnValue_t UdpTcLwIpPollingTask::initialize() {
|
||||||
udpBridge = ObjectManager::instance()->get<TmTcLwIpUdpBridge>(bridgeId);
|
udpBridge = ObjectManager::instance()->get<TmTcLwIpUdpBridge>(bridgeId);
|
||||||
@ -33,7 +29,6 @@ ReturnValue_t UdpTcLwIpPollingTask::initialize() {
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Poll the EMAC Interface and pass content to the network interface (lwIP) */
|
/* Poll the EMAC Interface and pass content to the network interface (lwIP) */
|
||||||
ReturnValue_t UdpTcLwIpPollingTask::performOperation(uint8_t operationCode) {
|
ReturnValue_t UdpTcLwIpPollingTask::performOperation(uint8_t operationCode) {
|
||||||
/* Read a received packet from the Ethernet buffers and send it
|
/* Read a received packet from the Ethernet buffers and send it
|
||||||
@ -52,8 +47,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 not udpBridge->comLinkUp()) {
|
||||||
else if(networking::getEthCableConnected() and not udpBridge->comLinkUp()) {
|
|
||||||
udpBridge->physicalConnectStatusChange(true);
|
udpBridge->physicalConnectStatusChange(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
#define BSP_STM32_RTEMS_EMACPOLLINGTASK_H_
|
#define BSP_STM32_RTEMS_EMACPOLLINGTASK_H_
|
||||||
|
|
||||||
#include <fsfw/objectmanager/SystemObject.h>
|
#include <fsfw/objectmanager/SystemObject.h>
|
||||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
|
||||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||||
#include <lwip/netif.h>
|
#include <lwip/netif.h>
|
||||||
|
|
||||||
class TmTcLwIpUdpBridge;
|
class TmTcLwIpUdpBridge;
|
||||||
@ -13,8 +12,7 @@ class TmTcLwIpUdpBridge;
|
|||||||
* @brief Separate task to poll EMAC interface.
|
* @brief Separate task to poll EMAC interface.
|
||||||
* Polled data is passed to the netif (lwIP)
|
* Polled data is passed to the netif (lwIP)
|
||||||
*/
|
*/
|
||||||
class UdpTcLwIpPollingTask:
|
class UdpTcLwIpPollingTask : public SystemObject,
|
||||||
public SystemObject,
|
|
||||||
public ExecutableObjectIF,
|
public ExecutableObjectIF,
|
||||||
public HasReturnvaluesIF {
|
public HasReturnvaluesIF {
|
||||||
public:
|
public:
|
||||||
@ -29,6 +27,7 @@ public:
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
|
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) 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;
|
||||||
@ -37,5 +36,4 @@ private:
|
|||||||
struct netif* gnetif = nullptr;
|
struct netif* gnetif = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* BSP_STM32_RTEMS_EMACPOLLINGTASK_H_ */
|
#endif /* BSP_STM32_RTEMS_EMACPOLLINGTASK_H_ */
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
#include "OBSWConfig.h"
|
|
||||||
|
|
||||||
#include "app_dhcp.h"
|
#include "app_dhcp.h"
|
||||||
#include "app_ethernet.h"
|
|
||||||
#include "networking.h"
|
|
||||||
#include "udp_config.h"
|
|
||||||
#include "ethernetif.h"
|
|
||||||
|
|
||||||
|
#include "OBSWConfig.h"
|
||||||
|
#include "app_ethernet.h"
|
||||||
|
#include "ethernetif.h"
|
||||||
#include "lwip/dhcp.h"
|
#include "lwip/dhcp.h"
|
||||||
|
#include "networking.h"
|
||||||
#include "stm32h7xx_nucleo.h"
|
#include "stm32h7xx_nucleo.h"
|
||||||
|
#include "udp_config.h"
|
||||||
|
|
||||||
#if LWIP_DHCP == 1
|
#if LWIP_DHCP == 1
|
||||||
|
|
||||||
@ -24,8 +23,7 @@ void handle_dhcp_down(struct netif* netif);
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void DHCP_Process(struct netif *netif)
|
void DHCP_Process(struct netif* netif) {
|
||||||
{
|
|
||||||
struct dhcp* dhcp = NULL;
|
struct dhcp* dhcp = NULL;
|
||||||
switch (DHCP_state) {
|
switch (DHCP_state) {
|
||||||
case DHCP_START: {
|
case DHCP_START: {
|
||||||
@ -84,8 +82,7 @@ void handle_dhcp_timeout(struct netif* netif) {
|
|||||||
* @param netif
|
* @param netif
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void DHCP_Periodic_Handle(struct netif *netif)
|
void DHCP_Periodic_Handle(struct netif* netif) {
|
||||||
{
|
|
||||||
/* Fine DHCP periodic process every 500ms */
|
/* Fine DHCP periodic process every 500ms */
|
||||||
if (HAL_GetTick() - DHCPfineTimer >= DHCP_FINE_TIMER_MSECS) {
|
if (HAL_GetTick() - DHCPfineTimer >= DHCP_FINE_TIMER_MSECS) {
|
||||||
DHCPfineTimer = HAL_GetTick();
|
DHCPfineTimer = HAL_GetTick();
|
||||||
@ -120,13 +117,11 @@ void handle_dhcp_wait(struct netif* netif, struct dhcp** dhcp) {
|
|||||||
BSP_LED_Off(LED2);
|
BSP_LED_Off(LED2);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
*dhcp = (struct dhcp*)netif_get_client_data(netif, LWIP_NETIF_CLIENT_DATA_INDEX_DHCP);
|
*dhcp = (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) {
|
||||||
{
|
|
||||||
handle_dhcp_timeout(netif);
|
handle_dhcp_timeout(netif);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,12 +141,8 @@ void handle_dhcp_down(struct netif* netif) {
|
|||||||
networking::setEthCableConnected(false);
|
networking::setEthCableConnected(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t get_dhcp_state() {
|
uint8_t get_dhcp_state() { return DHCP_state; }
|
||||||
return DHCP_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_dhcp_state(uint8_t new_state) {
|
void set_dhcp_state(uint8_t new_state) { DHCP_state = new_state; }
|
||||||
DHCP_state = new_state;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* LWIP_DHCP == 1 */
|
#endif /* LWIP_DHCP == 1 */
|
||||||
|
@ -1,17 +1,18 @@
|
|||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "app_ethernet.h"
|
#include "app_ethernet.h"
|
||||||
|
|
||||||
#include "ethernetif.h"
|
#include "ethernetif.h"
|
||||||
#include "udp_config.h"
|
|
||||||
#include "networking.h"
|
#include "networking.h"
|
||||||
|
#include "udp_config.h"
|
||||||
|
|
||||||
#if LWIP_DHCP
|
#if LWIP_DHCP
|
||||||
#include "app_dhcp.h"
|
#include "app_dhcp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <lwipopts.h>
|
|
||||||
#include <lwip/netif.h>
|
|
||||||
#include <stm32h7xx_nucleo.h>
|
|
||||||
#include <OBSWConfig.h>
|
#include <OBSWConfig.h>
|
||||||
|
#include <lwip/netif.h>
|
||||||
|
#include <lwipopts.h>
|
||||||
|
#include <stm32h7xx_nucleo.h>
|
||||||
|
|
||||||
/* Private typedef -----------------------------------------------------------*/
|
/* Private typedef -----------------------------------------------------------*/
|
||||||
/* Private define ------------------------------------------------------------*/
|
/* Private define ------------------------------------------------------------*/
|
||||||
@ -22,22 +23,17 @@ uint32_t ethernetLinkTimer = 0;
|
|||||||
/* Private function prototypes -----------------------------------------------*/
|
/* Private function prototypes -----------------------------------------------*/
|
||||||
void handle_status_change(struct netif* netif, bool link_up);
|
void handle_status_change(struct netif* netif, bool link_up);
|
||||||
|
|
||||||
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
/* Private functions ---------------------------------------------------------*/
|
||||||
/**
|
/**
|
||||||
* @brief Notify the User about the network interface config status
|
* @brief Notify the User about the network interface config status
|
||||||
* @param netif: the network interface
|
* @param netif: the network interface
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void networking::ethernetLinkStatusUpdated(struct netif *netif)
|
void networking::ethernetLinkStatusUpdated(struct netif* netif) {
|
||||||
{
|
if (netif_is_link_up(netif)) {
|
||||||
if (netif_is_link_up(netif))
|
|
||||||
{
|
|
||||||
networking::setEthCableConnected(true);
|
networking::setEthCableConnected(true);
|
||||||
handle_status_change(netif, true);
|
handle_status_change(netif, true);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
networking::setEthCableConnected(false);
|
networking::setEthCableConnected(false);
|
||||||
handle_status_change(netif, false);
|
handle_status_change(netif, false);
|
||||||
}
|
}
|
||||||
@ -58,8 +54,7 @@ void handle_status_change(struct netif* netif, bool link_up) {
|
|||||||
BSP_LED_Off(LED2);
|
BSP_LED_Off(LED2);
|
||||||
#endif
|
#endif
|
||||||
#endif /* LWIP_DHCP */
|
#endif /* LWIP_DHCP */
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
printf("Network cable disconnected\n\r");
|
printf("Network cable disconnected\n\r");
|
||||||
#if LWIP_DHCP
|
#if LWIP_DHCP
|
||||||
/* Update DHCP state machine */
|
/* Update DHCP state machine */
|
||||||
@ -80,11 +75,9 @@ void handle_status_change(struct netif* netif, bool link_up) {
|
|||||||
* @param netif
|
* @param netif
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void networking::ethernetLinkPeriodicHandle(struct netif *netif)
|
void networking::ethernetLinkPeriodicHandle(struct netif* netif) {
|
||||||
{
|
|
||||||
/* Ethernet Link every 100ms */
|
/* Ethernet Link every 100ms */
|
||||||
if (HAL_GetTick() - ethernetLinkTimer >= 100)
|
if (HAL_GetTick() - ethernetLinkTimer >= 100) {
|
||||||
{
|
|
||||||
ethernetLinkTimer = HAL_GetTick();
|
ethernetLinkTimer = HAL_GetTick();
|
||||||
ethernet_link_check_state(netif);
|
ethernet_link_check_state(netif);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ namespace networking {
|
|||||||
void ethernetLinkStatusUpdated(struct netif *netif);
|
void ethernetLinkStatusUpdated(struct netif *netif);
|
||||||
void ethernetLinkPeriodicHandle(struct netif *netif);
|
void ethernetLinkPeriodicHandle(struct netif *netif);
|
||||||
|
|
||||||
}
|
} // namespace networking
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
@ -73,6 +73,4 @@ void ethernetLinkPeriodicHandle(struct netif *netif);
|
|||||||
|
|
||||||
#endif /* EXAMPLE_COMMON_APP_ETHERNET_H */
|
#endif /* EXAMPLE_COMMON_APP_ETHERNET_H */
|
||||||
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
|
||||||
|
@ -44,16 +44,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "fsfw/FSFW.h"
|
|
||||||
#include "ethernetif.h"
|
#include "ethernetif.h"
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <lan8742.h>
|
#include <lan8742.h>
|
||||||
#include <stm32h7xx_hal.h>
|
|
||||||
#include <lwip/netif.h>
|
#include <lwip/netif.h>
|
||||||
#include <lwip/opt.h>
|
#include <lwip/opt.h>
|
||||||
#include <lwip/timeouts.h>
|
#include <lwip/timeouts.h>
|
||||||
#include <netif/etharp.h>
|
#include <netif/etharp.h>
|
||||||
|
#include <stm32h7xx_hal.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "fsfw/FSFW.h"
|
||||||
|
|
||||||
#ifdef FSFW_OSAL_RTEMS
|
#ifdef FSFW_OSAL_RTEMS
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
@ -98,24 +99,34 @@ uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_RX_BUFFER_SIZE]; /* Ethernet Receive Buffer
|
|||||||
|
|
||||||
#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(".RxArraySection"))) uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_RX_BUFFER_SIZE]; /* Ethernet Receive Buffer */
|
__attribute__((section(".TxDecripSection")))
|
||||||
|
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]; /* Ethernet Tx DMA Descriptors */
|
||||||
|
__attribute__((section(".RxArraySection")))
|
||||||
|
uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_RX_BUFFER_SIZE]; /* Ethernet Receive Buffer */
|
||||||
|
|
||||||
#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__((section(".bsp_nocache"), __aligned__(DMA_DESCRIPTOR_ALIGNMENT))); /* Ethernet Rx DMA Descriptors */
|
ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT]
|
||||||
|
__attribute__((section(".bsp_nocache"),
|
||||||
|
__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__((section(".bsp_nocache"), __aligned__(DMA_DESCRIPTOR_ALIGNMENT))); /* Ethernet Tx DMA Descriptors */
|
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]
|
||||||
|
__attribute__((section(".bsp_nocache"),
|
||||||
|
__aligned__(DMA_DESCRIPTOR_ALIGNMENT))); /* Ethernet Tx DMA Descriptors */
|
||||||
/* Ethernet Receive Buffers. Just place somewhere is BSS instead of explicitely placing it */
|
/* Ethernet Receive Buffers. Just place somewhere is BSS instead of explicitely 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
|
||||||
/* Placement and alignment specified in linker script here */
|
/* Placement and alignment specified in linker script here */
|
||||||
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 */
|
||||||
uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_RX_BUFFER_SIZE] __attribute__((section(".RxArraySection"))); /* Ethernet Receive Buffers */
|
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT]
|
||||||
|
__attribute__((section(".TxDecripSection"))); /* Ethernet Tx DMA Descriptors */
|
||||||
|
uint8_t Rx_Buff[ETH_RX_DESC_CNT][ETH_RX_BUFFER_SIZE]
|
||||||
|
__attribute__((section(".RxArraySection"))); /* Ethernet Receive Buffers */
|
||||||
#endif /* FSFW_FREERTOS */
|
#endif /* FSFW_FREERTOS */
|
||||||
|
|
||||||
#endif /* defined ( __GNUC__ ) */
|
#endif /* defined ( __GNUC__ ) */
|
||||||
@ -141,12 +152,8 @@ 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_IOCtx_t LAN8742_IOCtx = {ETH_PHY_IO_Init, ETH_PHY_IO_DeInit, ETH_PHY_IO_WriteReg,
|
||||||
lan8742_IOCtx_t LAN8742_IOCtx = {ETH_PHY_IO_Init,
|
ETH_PHY_IO_ReadReg, ETH_PHY_IO_GetTick};
|
||||||
ETH_PHY_IO_DeInit,
|
|
||||||
ETH_PHY_IO_WriteReg,
|
|
||||||
ETH_PHY_IO_ReadReg,
|
|
||||||
ETH_PHY_IO_GetTick};
|
|
||||||
/* Private functions ---------------------------------------------------------*/
|
/* Private functions ---------------------------------------------------------*/
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
LL Driver Interface ( LwIP stack --> ETH)
|
LL Driver Interface ( LwIP stack --> ETH)
|
||||||
@ -158,10 +165,10 @@ lan8742_IOCtx_t LAN8742_IOCtx = {ETH_PHY_IO_Init,
|
|||||||
* @param netif the already initialized lwip network interface structure
|
* @param netif the already initialized lwip network interface structure
|
||||||
* for this ethernetif
|
* for this ethernetif
|
||||||
*/
|
*/
|
||||||
static void low_level_init(struct netif *netif)
|
static void low_level_init(struct netif *netif) {
|
||||||
{
|
|
||||||
uint32_t idx = 0;
|
uint32_t idx = 0;
|
||||||
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;
|
||||||
@ -191,8 +198,7 @@ static void low_level_init(struct netif *netif)
|
|||||||
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
|
/* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
|
||||||
netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
|
netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
|
||||||
|
|
||||||
for(idx = 0; idx < ETH_RX_DESC_CNT; idx ++)
|
for (idx = 0; idx < ETH_RX_DESC_CNT; idx++) {
|
||||||
{
|
|
||||||
HAL_ETH_DescAssignMemory(&EthHandle, idx, Rx_Buff[idx], NULL);
|
HAL_ETH_DescAssignMemory(&EthHandle, idx, Rx_Buff[idx], NULL);
|
||||||
|
|
||||||
/* Set Custom pbuf free function */
|
/* Set Custom pbuf free function */
|
||||||
@ -212,7 +218,6 @@ static void low_level_init(struct netif *netif)
|
|||||||
LAN8742_Init(&LAN8742);
|
LAN8742_Init(&LAN8742);
|
||||||
|
|
||||||
ethernet_link_check_state(netif);
|
ethernet_link_check_state(netif);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -230,29 +235,24 @@ static void low_level_init(struct netif *netif)
|
|||||||
* to become availale since the stack doesn't retry to send a packet
|
* to become availale since the stack doesn't retry to send a packet
|
||||||
* dropped because of memory failure (except for the TCP timers).
|
* dropped because of memory failure (except for the TCP timers).
|
||||||
*/
|
*/
|
||||||
static err_t low_level_output(struct netif *netif, struct pbuf *p)
|
static err_t low_level_output(struct netif *netif, struct pbuf *p) {
|
||||||
{
|
|
||||||
uint32_t i = 0, framelen = 0;
|
uint32_t i = 0, framelen = 0;
|
||||||
struct pbuf *q;
|
struct pbuf *q;
|
||||||
err_t errval = ERR_OK;
|
err_t errval = ERR_OK;
|
||||||
ETH_BufferTypeDef Txbuffer[ETH_TX_DESC_CNT];
|
ETH_BufferTypeDef Txbuffer[ETH_TX_DESC_CNT];
|
||||||
|
|
||||||
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;
|
||||||
framelen += q->len;
|
framelen += 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,34 +279,28 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
|
|||||||
* @return a pbuf filled with the received packet (including MAC header)
|
* @return a pbuf filled with the received packet (including MAC header)
|
||||||
* NULL on memory error
|
* NULL on memory error
|
||||||
*/
|
*/
|
||||||
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;
|
||||||
ETH_BufferTypeDef RxBuff;
|
ETH_BufferTypeDef RxBuff;
|
||||||
uint32_t framelength = 0;
|
uint32_t framelength = 0;
|
||||||
|
|
||||||
if (HAL_ETH_IsRxDataAvailable(&EthHandle))
|
if (HAL_ETH_IsRxDataAvailable(&EthHandle)) {
|
||||||
{
|
|
||||||
HAL_ETH_GetRxDataBuffer(&EthHandle, &RxBuff);
|
HAL_ETH_GetRxDataBuffer(&EthHandle, &RxBuff);
|
||||||
HAL_ETH_GetRxDataLength(&EthHandle, &framelength);
|
HAL_ETH_GetRxDataLength(&EthHandle, &framelength);
|
||||||
|
|
||||||
/* Invalidate data cache for ETH Rx Buffers */
|
/* Invalidate data cache for ETH Rx Buffers */
|
||||||
SCB_InvalidateDCache_by_Addr((uint32_t *)Rx_Buff, (ETH_RX_DESC_CNT * ETH_RX_BUFFER_SIZE));
|
SCB_InvalidateDCache_by_Addr((uint32_t *)Rx_Buff, (ETH_RX_DESC_CNT * ETH_RX_BUFFER_SIZE));
|
||||||
|
|
||||||
p = pbuf_alloced_custom(PBUF_RAW, framelength, PBUF_POOL, &rx_pbuf[current_pbuf_idx], RxBuff.buffer, ETH_RX_BUFFER_SIZE);
|
p = pbuf_alloced_custom(PBUF_RAW, framelength, PBUF_POOL, &rx_pbuf[current_pbuf_idx],
|
||||||
if(current_pbuf_idx < (ETH_RX_DESC_CNT -1))
|
RxBuff.buffer, ETH_RX_BUFFER_SIZE);
|
||||||
{
|
if (current_pbuf_idx < (ETH_RX_DESC_CNT - 1)) {
|
||||||
current_pbuf_idx++;
|
current_pbuf_idx++;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
current_pbuf_idx = 0;
|
current_pbuf_idx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,8 +314,7 @@ static struct pbuf * low_level_input(struct netif *netif)
|
|||||||
*
|
*
|
||||||
* @param netif the lwip network interface structure for this ethernetif
|
* @param netif the lwip network interface structure for this ethernetif
|
||||||
*/
|
*/
|
||||||
void ethernetif_input(struct netif *netif)
|
void ethernetif_input(struct netif *netif) {
|
||||||
{
|
|
||||||
err_t err;
|
err_t err;
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
|
|
||||||
@ -334,8 +327,7 @@ void ethernetif_input(struct netif *netif)
|
|||||||
/* entry point to the LwIP stack */
|
/* entry point to the LwIP stack */
|
||||||
err = netif->input(p, netif);
|
err = netif->input(p, netif);
|
||||||
|
|
||||||
if (err != ERR_OK)
|
if (err != ERR_OK) {
|
||||||
{
|
|
||||||
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
|
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
p = NULL;
|
p = NULL;
|
||||||
@ -356,8 +348,7 @@ void ethernetif_input(struct netif *netif)
|
|||||||
* ERR_MEM if private data couldn't be allocated
|
* ERR_MEM if private data couldn't be allocated
|
||||||
* any other err_t on error
|
* any other err_t on error
|
||||||
*/
|
*/
|
||||||
err_t ethernetif_init(struct netif *netif)
|
err_t ethernetif_init(struct netif *netif) {
|
||||||
{
|
|
||||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||||
|
|
||||||
#if LWIP_NETIF_HOSTNAME
|
#if LWIP_NETIF_HOSTNAME
|
||||||
@ -385,10 +376,8 @@ err_t ethernetif_init(struct netif *netif)
|
|||||||
* @param pbuf: pbuf to be freed
|
* @param pbuf: pbuf to be freed
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void pbuf_free_custom(struct pbuf *p)
|
void pbuf_free_custom(struct pbuf *p) {
|
||||||
{
|
if (p != NULL) {
|
||||||
if(p != NULL)
|
|
||||||
{
|
|
||||||
p->flags = 0;
|
p->flags = 0;
|
||||||
p->next = NULL;
|
p->next = NULL;
|
||||||
p->len = p->tot_len = 0;
|
p->len = p->tot_len = 0;
|
||||||
@ -403,10 +392,7 @@ void pbuf_free_custom(struct pbuf *p)
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval Current Time value
|
* @retval Current Time value
|
||||||
*/
|
*/
|
||||||
u32_t sys_now(void)
|
u32_t sys_now(void) { return HAL_GetTick(); }
|
||||||
{
|
|
||||||
return HAL_GetTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
Ethernet MSP Routines
|
Ethernet MSP Routines
|
||||||
@ -416,8 +402,7 @@ u32_t sys_now(void)
|
|||||||
* @param heth: ETH handle
|
* @param heth: ETH handle
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
|
void HAL_ETH_MspInit(ETH_HandleTypeDef *heth) {
|
||||||
{
|
|
||||||
GPIO_InitTypeDef GPIO_InitStructure;
|
GPIO_InitTypeDef GPIO_InitStructure;
|
||||||
|
|
||||||
/* Ethernett MSP init: RMII Mode */
|
/* Ethernett MSP init: RMII Mode */
|
||||||
@ -482,8 +467,7 @@ void HAL_ETH_MspInit(ETH_HandleTypeDef *heth)
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval 0 if OK, -1 if ERROR
|
* @retval 0 if OK, -1 if ERROR
|
||||||
*/
|
*/
|
||||||
int32_t ETH_PHY_IO_Init(void)
|
int32_t ETH_PHY_IO_Init(void) {
|
||||||
{
|
|
||||||
/* We assume that MDIO GPIO configuration is already done
|
/* We assume that MDIO GPIO configuration is already done
|
||||||
in the ETH_MspInit() else it should be done here
|
in the ETH_MspInit() else it should be done here
|
||||||
*/
|
*/
|
||||||
@ -499,10 +483,7 @@ int32_t ETH_PHY_IO_Init(void)
|
|||||||
* @param None
|
* @param None
|
||||||
* @retval 0 if OK, -1 if ERROR
|
* @retval 0 if OK, -1 if ERROR
|
||||||
*/
|
*/
|
||||||
int32_t ETH_PHY_IO_DeInit (void)
|
int32_t ETH_PHY_IO_DeInit(void) { return 0; }
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Read a PHY register through the MDIO interface.
|
* @brief Read a PHY register through the MDIO interface.
|
||||||
@ -511,10 +492,8 @@ int32_t ETH_PHY_IO_DeInit (void)
|
|||||||
* @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, uint32_t *pRegVal)
|
int32_t ETH_PHY_IO_ReadReg(uint32_t DevAddr, uint32_t RegAddr, 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,10 +507,8 @@ int32_t ETH_PHY_IO_ReadReg(uint32_t DevAddr, uint32_t RegAddr, uint32_t *pRegVal
|
|||||||
* @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, uint32_t RegVal)
|
int32_t ETH_PHY_IO_WriteReg(uint32_t DevAddr, uint32_t RegAddr, 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,33 +519,25 @@ int32_t ETH_PHY_IO_WriteReg(uint32_t DevAddr, uint32_t RegAddr, uint32_t RegVal)
|
|||||||
* @brief Get the time in millisecons used for internal PHY driver process.
|
* @brief Get the time in millisecons used for internal PHY driver process.
|
||||||
* @retval Time value
|
* @retval Time value
|
||||||
*/
|
*/
|
||||||
int32_t ETH_PHY_IO_GetTick(void)
|
int32_t ETH_PHY_IO_GetTick(void) { return HAL_GetTick(); }
|
||||||
{
|
|
||||||
return HAL_GetTick();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief
|
* @brief
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void ethernet_link_check_state(struct netif *netif)
|
void ethernet_link_check_state(struct netif *netif) {
|
||||||
{
|
|
||||||
ETH_MACConfigTypeDef MACConf;
|
ETH_MACConfigTypeDef MACConf;
|
||||||
uint32_t PHYLinkState;
|
uint32_t PHYLinkState;
|
||||||
uint32_t linkchanged = 0, speed = 0, duplex = 0;
|
uint32_t linkchanged = 0, speed = 0, duplex = 0;
|
||||||
|
|
||||||
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(&EthHandle);
|
HAL_ETH_Stop(&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;
|
||||||
@ -593,8 +562,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;
|
||||||
@ -607,8 +575,6 @@ void ethernet_link_check_state(struct netif *netif)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ETH_HandleTypeDef* getEthernetHandle() {
|
ETH_HandleTypeDef *getEthernetHandle() { return &EthHandle; }
|
||||||
return &EthHandle;
|
|
||||||
}
|
|
||||||
|
|
||||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||||
|
@ -46,10 +46,11 @@
|
|||||||
#ifndef __ETHERNETIF_H__
|
#ifndef __ETHERNETIF_H__
|
||||||
#define __ETHERNETIF_H__
|
#define __ETHERNETIF_H__
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stm32h7xx_hal.h>
|
||||||
|
|
||||||
#include "lwip/err.h"
|
#include "lwip/err.h"
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
#include <stm32h7xx_hal.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -1,19 +1,15 @@
|
|||||||
#include "udp_config.h"
|
|
||||||
#include "networking.h"
|
#include "networking.h"
|
||||||
|
|
||||||
|
#include "udp_config.h"
|
||||||
|
|
||||||
bool ethernetCableConnected = false;
|
bool ethernetCableConnected = false;
|
||||||
|
|
||||||
void networking::setEthCableConnected(bool status) {
|
void networking::setEthCableConnected(bool status) { ethernetCableConnected = status; }
|
||||||
ethernetCableConnected = status;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool networking::getEthCableConnected() {
|
bool networking::getEthCableConnected() { return ethernetCableConnected; }
|
||||||
return ethernetCableConnected;
|
|
||||||
}
|
|
||||||
|
|
||||||
void networking::setLwipAddresses(ip_addr_t* ipaddr, ip_addr_t* netmask, ip_addr_t* gw) {
|
void networking::setLwipAddresses(ip_addr_t* ipaddr, ip_addr_t* netmask, 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 ,
|
IP4_ADDR(netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,6 @@ void setEthCableConnected(bool status);
|
|||||||
bool getEthCableConnected();
|
bool getEthCableConnected();
|
||||||
void setLwipAddresses(ip_addr_t* ipaddr, ip_addr_t* netmask, ip_addr_t* gw);
|
void setLwipAddresses(ip_addr_t* ipaddr, ip_addr_t* netmask, ip_addr_t* gw);
|
||||||
|
|
||||||
}
|
} // namespace networking
|
||||||
|
|
||||||
#endif /* BSP_STM32H7_RTEMS_NETWORKING_NETWORKING_H_ */
|
#endif /* BSP_STM32H7_RTEMS_NETWORKING_NETWORKING_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user