Compare commits
21 Commits
develop_up
...
action-upd
Author | SHA1 | Date | |
---|---|---|---|
60f6ef5f1f
|
|||
4ecd9eb62e | |||
fb89d7a3b6 | |||
146c3471d0 | |||
1816c3f623 | |||
d03d5aa74c | |||
26e97ddf89 | |||
be3a57a795 | |||
13b97abf0d | |||
f95c373076 | |||
e03731bcf8 | |||
9fe8579377 | |||
2714e588d7 | |||
e905288adc | |||
3805ea50a7 | |||
699bd694cd | |||
c35a0a8541 | |||
e0a072859b | |||
067cb7d0f8 | |||
2c17af4ef8 | |||
110fb43b9c |
8
.idea/cmake.xml
generated
8
.idea/cmake.xml
generated
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="CMakeSharedSettings">
|
|
||||||
<configurations>
|
|
||||||
<configuration PROFILE_NAME="Debug Test" ENABLED="true" CONFIG_NAME="Debug" GENERATION_OPTIONS="-DFSFW_BUILD_TESTS=ON -DFSFW_OSAL=host" />
|
|
||||||
</configurations>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -27,11 +27,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
- add CFDP subsystem ID
|
- add CFDP subsystem ID
|
||||||
https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/742
|
https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/742
|
||||||
- `PusTmZcWriter` now exposes API to set message counter field.
|
- `EventManager`: Add function to print all listeners.
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
|
|
||||||
- HK generation is now countdown based.
|
|
||||||
- Bump ETL version to 20.35.14
|
- Bump ETL version to 20.35.14
|
||||||
https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/748
|
https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/748
|
||||||
- Renamed `PCDU_2` subsystem ID to `POWER_SWITCH_IF`.
|
- Renamed `PCDU_2` subsystem ID to `POWER_SWITCH_IF`.
|
||||||
@ -40,7 +39,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/743
|
https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/743
|
||||||
- Assert that `FixedArrayList` is larger than 0 at compile time.
|
- Assert that `FixedArrayList` is larger than 0 at compile time.
|
||||||
https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/740
|
https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/740
|
||||||
- Health functions are virtual now.
|
- `EventManager`: Queue depth is configurable now
|
||||||
|
- `ActionHelper`: Allow execution of actions without additional data
|
||||||
|
|
||||||
# [v6.0.0] 2023-02-10
|
# [v6.0.0] 2023-02-10
|
||||||
|
|
||||||
@ -116,8 +116,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
|
|
||||||
## Added
|
## Added
|
||||||
|
|
||||||
- `CServiceHealthCommanding`: Add announce all health info implementation
|
|
||||||
PR: https://egit.irs.uni-stuttgart.de/eive/fsfw/pulls/122
|
|
||||||
- Empty constructor for `CdsShortTimeStamper` which does not do an object manager registration.
|
- Empty constructor for `CdsShortTimeStamper` which does not do an object manager registration.
|
||||||
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/730
|
PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/730
|
||||||
- `Service9TimeManagement`: Add `DUMP_TIME` (129) subservice.
|
- `Service9TimeManagement`: Add `DUMP_TIME` (129) subservice.
|
||||||
|
@ -72,7 +72,7 @@ set(FSFW_ETL_LIB_MAJOR_VERSION
|
|||||||
20
|
20
|
||||||
CACHE STRING "ETL library major version requirement")
|
CACHE STRING "ETL library major version requirement")
|
||||||
set(FSFW_ETL_LIB_VERSION
|
set(FSFW_ETL_LIB_VERSION
|
||||||
${FSFW_ETL_LIB_MAJOR_VERSION}.35.14
|
${FSFW_ETL_LIB_MAJOR_VERSION}.36.0
|
||||||
CACHE STRING "ETL library exact version requirement")
|
CACHE STRING "ETL library exact version requirement")
|
||||||
set(FSFW_ETL_LINK_TARGET etl::etl)
|
set(FSFW_ETL_LINK_TARGET etl::etl)
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ set(FSFW_CATCH2_LIB_MAJOR_VERSION
|
|||||||
3
|
3
|
||||||
CACHE STRING "Catch2 library major version requirement")
|
CACHE STRING "Catch2 library major version requirement")
|
||||||
set(FSFW_CATCH2_LIB_VERSION
|
set(FSFW_CATCH2_LIB_VERSION
|
||||||
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.1.0
|
v${FSFW_CATCH2_LIB_MAJOR_VERSION}.3.2
|
||||||
CACHE STRING "Catch2 library exact version requirement")
|
CACHE STRING "Catch2 library exact version requirement")
|
||||||
|
|
||||||
# Keep this off by default for now. See PR:
|
# Keep this off by default for now. See PR:
|
||||||
|
4
automation/Jenkinsfile
vendored
4
automation/Jenkinsfile
vendored
@ -97,7 +97,7 @@ pipeline {
|
|||||||
sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/development'
|
sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/development'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dir(BUILDDIR) {
|
dir(BUILDDIR_LINUX) {
|
||||||
sshagent(credentials: ['documentation-buildfix']) {
|
sshagent(credentials: ['documentation-buildfix']) {
|
||||||
sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/development'
|
sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/development'
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ pipeline {
|
|||||||
sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/master'
|
sh 'rsync -r --delete docs/sphinx/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/master'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dir(BUILDDIR) {
|
dir(BUILDDIR_LINUX) {
|
||||||
sshagent(credentials: ['documentation-buildfix']) {
|
sshagent(credentials: ['documentation-buildfix']) {
|
||||||
sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/master'
|
sh 'rsync -r --delete fsfw-tests_coverage/* buildfix@documentation.irs.uni-stuttgart.de:/fsfw/coverage/master'
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,7 @@ exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
|
|||||||
html_theme = "alabaster"
|
html_theme = "alabaster"
|
||||||
|
|
||||||
html_theme_options = {
|
html_theme_options = {
|
||||||
"extra_nav_links": {
|
"extra_nav_links": {"Impressum" : "https://www.uni-stuttgart.de/impressum", "Datenschutz": "https://info.irs.uni-stuttgart.de/datenschutz/datenschutzWebmit.html"}
|
||||||
"Impressum": "https://www.uni-stuttgart.de/impressum",
|
|
||||||
"Datenschutz": "https://info.irs.uni-stuttgart.de/datenschutz/datenschutzWebmit.html",
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,9 +2,7 @@
|
|||||||
#define FSFW_CFDP_H
|
#define FSFW_CFDP_H
|
||||||
|
|
||||||
#include "cfdp/definitions.h"
|
#include "cfdp/definitions.h"
|
||||||
#include "cfdp/handler/DestHandler.h"
|
|
||||||
#include "cfdp/handler/FaultHandlerBase.h"
|
#include "cfdp/handler/FaultHandlerBase.h"
|
||||||
#include "cfdp/helpers.h"
|
|
||||||
#include "cfdp/tlv/Lv.h"
|
#include "cfdp/tlv/Lv.h"
|
||||||
#include "cfdp/tlv/StringLv.h"
|
#include "cfdp/tlv/StringLv.h"
|
||||||
#include "cfdp/tlv/Tlv.h"
|
#include "cfdp/tlv/Tlv.h"
|
||||||
|
@ -51,8 +51,9 @@ class VarLenField : public SerializeIF {
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
using SerializeIF::deSerialize; // we overloaded above, so this is needed to uncofuse the
|
||||||
|
// compiler
|
||||||
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||||
Endianness streamEndianness) override;
|
Endianness streamEndianness) override;
|
||||||
|
|
||||||
|
@ -1,2 +1 @@
|
|||||||
target_sources(${LIB_FSFW_NAME} PRIVATE SourceHandler.cpp DestHandler.cpp
|
target_sources(${LIB_FSFW_NAME} PRIVATE FaultHandlerBase.cpp UserBase.cpp)
|
||||||
FaultHandlerBase.cpp UserBase.cpp)
|
|
||||||
|
@ -1,546 +0,0 @@
|
|||||||
#include "DestHandler.h"
|
|
||||||
|
|
||||||
#include <etl/crc32.h>
|
|
||||||
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "fsfw/FSFW.h"
|
|
||||||
#include "fsfw/cfdp/pdu/EofPduReader.h"
|
|
||||||
#include "fsfw/cfdp/pdu/FileDataReader.h"
|
|
||||||
#include "fsfw/cfdp/pdu/FinishedPduCreator.h"
|
|
||||||
#include "fsfw/cfdp/pdu/PduHeaderReader.h"
|
|
||||||
#include "fsfw/objectmanager.h"
|
|
||||||
#include "fsfw/tmtcservices/TmTcMessage.h"
|
|
||||||
|
|
||||||
using namespace returnvalue;
|
|
||||||
|
|
||||||
cfdp::DestHandler::DestHandler(DestHandlerParams params, FsfwParams fsfwParams)
|
|
||||||
: tlvVec(params.maxTlvsInOnePdu),
|
|
||||||
userTlvVec(params.maxTlvsInOnePdu),
|
|
||||||
dp(std::move(params)),
|
|
||||||
fp(fsfwParams),
|
|
||||||
tp(params.maxFilenameLen) {
|
|
||||||
tp.pduConf.direction = cfdp::Direction::TOWARDS_SENDER;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cfdp::DestHandler::FsmResult& cfdp::DestHandler::performStateMachine() {
|
|
||||||
ReturnValue_t result;
|
|
||||||
uint8_t errorIdx = 0;
|
|
||||||
fsmRes.resetOfIteration();
|
|
||||||
if (fsmRes.step == TransactionStep::IDLE) {
|
|
||||||
for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) {
|
|
||||||
if (infoIter->pduType == PduType::FILE_DIRECTIVE and
|
|
||||||
infoIter->directiveType == FileDirective::METADATA) {
|
|
||||||
result = handleMetadataPdu(*infoIter);
|
|
||||||
checkAndHandleError(result, errorIdx);
|
|
||||||
// Store data was deleted in PDU handler because a store guard is used
|
|
||||||
dp.packetListRef.erase(infoIter++);
|
|
||||||
} else {
|
|
||||||
infoIter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fsmRes.step == TransactionStep::IDLE) {
|
|
||||||
// To decrease the already high complexity of the software, all packets arriving before
|
|
||||||
// a metadata PDU are deleted.
|
|
||||||
for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) {
|
|
||||||
fp.tcStore->deleteData(infoIter->storeId);
|
|
||||||
infoIter++;
|
|
||||||
}
|
|
||||||
dp.packetListRef.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fsmRes.step != TransactionStep::IDLE) {
|
|
||||||
fsmRes.callStatus = CallStatus::CALL_AGAIN;
|
|
||||||
}
|
|
||||||
return updateFsmRes(errorIdx);
|
|
||||||
}
|
|
||||||
if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) {
|
|
||||||
if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) {
|
|
||||||
for (auto infoIter = dp.packetListRef.begin(); infoIter != dp.packetListRef.end();) {
|
|
||||||
if (infoIter->pduType == PduType::FILE_DATA) {
|
|
||||||
result = handleFileDataPdu(*infoIter);
|
|
||||||
checkAndHandleError(result, errorIdx);
|
|
||||||
// Store data was deleted in PDU handler because a store guard is used
|
|
||||||
dp.packetListRef.erase(infoIter++);
|
|
||||||
} else if (infoIter->pduType == PduType::FILE_DIRECTIVE and
|
|
||||||
infoIter->directiveType == FileDirective::EOF_DIRECTIVE) {
|
|
||||||
// TODO: Support for check timer missing
|
|
||||||
result = handleEofPdu(*infoIter);
|
|
||||||
checkAndHandleError(result, errorIdx);
|
|
||||||
// Store data was deleted in PDU handler because a store guard is used
|
|
||||||
dp.packetListRef.erase(infoIter++);
|
|
||||||
} else {
|
|
||||||
infoIter++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (fsmRes.step == TransactionStep::TRANSFER_COMPLETION) {
|
|
||||||
result = handleTransferCompletion();
|
|
||||||
checkAndHandleError(result, errorIdx);
|
|
||||||
}
|
|
||||||
if (fsmRes.step == TransactionStep::SENDING_FINISHED_PDU) {
|
|
||||||
result = sendFinishedPdu();
|
|
||||||
checkAndHandleError(result, errorIdx);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
return updateFsmRes(errorIdx);
|
|
||||||
}
|
|
||||||
if (fsmRes.state == CfdpStates::BUSY_CLASS_2_ACKED) {
|
|
||||||
// TODO: Will be implemented at a later stage
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "CFDP state machine for acknowledged mode not implemented yet" << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return updateFsmRes(errorIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::passPacket(PacketInfo packet) {
|
|
||||||
if (dp.packetListRef.full()) {
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
dp.packetListRef.push_back(packet);
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::initialize() {
|
|
||||||
if (fp.tmStore == nullptr) {
|
|
||||||
fp.tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
|
|
||||||
if (fp.tmStore == nullptr) {
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fp.tcStore == nullptr) {
|
|
||||||
fp.tcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
|
||||||
if (fp.tcStore == nullptr) {
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fp.msgQueue == nullptr) {
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::handleMetadataPdu(const PacketInfo& info) {
|
|
||||||
// Process metadata PDU
|
|
||||||
auto constAccessorPair = fp.tcStore->getData(info.storeId);
|
|
||||||
if (constAccessorPair.first != OK) {
|
|
||||||
// TODO: This is not a CFDP error. Event and/or warning?
|
|
||||||
return constAccessorPair.first;
|
|
||||||
}
|
|
||||||
cfdp::StringLv sourceFileName;
|
|
||||||
cfdp::StringLv destFileName;
|
|
||||||
MetadataInfo metadataInfo(tp.fileSize, sourceFileName, destFileName);
|
|
||||||
cfdp::Tlv* tlvArrayAsPtr = tlvVec.data();
|
|
||||||
metadataInfo.setOptionsArray(&tlvArrayAsPtr, std::nullopt, tlvVec.size());
|
|
||||||
MetadataPduReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(),
|
|
||||||
metadataInfo);
|
|
||||||
ReturnValue_t result = reader.parseData();
|
|
||||||
// TODO: The standard does not really specify what happens if this kind of error happens
|
|
||||||
// I think it might be a good idea to cache some sort of error code, which
|
|
||||||
// is translated into a warning and/or event by an upper layer
|
|
||||||
if (result != OK) {
|
|
||||||
return handleMetadataParseError(result, constAccessorPair.second.data(),
|
|
||||||
constAccessorPair.second.size());
|
|
||||||
}
|
|
||||||
return startTransaction(reader, metadataInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::handleFileDataPdu(const cfdp::PacketInfo& info) {
|
|
||||||
// Process file data PDU
|
|
||||||
auto constAccessorPair = fp.tcStore->getData(info.storeId);
|
|
||||||
if (constAccessorPair.first != OK) {
|
|
||||||
// TODO: This is not a CFDP error. Event and/or warning?
|
|
||||||
return constAccessorPair.first;
|
|
||||||
}
|
|
||||||
cfdp::FileSize offset;
|
|
||||||
FileDataInfo fdInfo(offset);
|
|
||||||
FileDataReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), fdInfo);
|
|
||||||
ReturnValue_t result = reader.parseData();
|
|
||||||
if (result != OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
size_t fileSegmentLen = 0;
|
|
||||||
const uint8_t* fileData = fdInfo.getFileData(&fileSegmentLen);
|
|
||||||
FileOpParams fileOpParams(tp.destName.data(), fileSegmentLen);
|
|
||||||
fileOpParams.offset = offset.value();
|
|
||||||
if (dp.cfg.indicCfg.fileSegmentRecvIndicRequired) {
|
|
||||||
FileSegmentRecvdParams segParams;
|
|
||||||
segParams.offset = offset.value();
|
|
||||||
segParams.id = tp.transactionId;
|
|
||||||
segParams.length = fileSegmentLen;
|
|
||||||
segParams.recContState = fdInfo.getRecordContinuationState();
|
|
||||||
size_t segmentMetadatLen = 0;
|
|
||||||
auto* segMetadata = fdInfo.getSegmentMetadata(&segmentMetadatLen);
|
|
||||||
segParams.segmentMetadata = {segMetadata, segmentMetadatLen};
|
|
||||||
dp.user.fileSegmentRecvdIndication(segParams);
|
|
||||||
}
|
|
||||||
result = dp.user.vfs.writeToFile(fileOpParams, fileData);
|
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
// TODO: Proper Error handling
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::error << "cfdp::DestHandler: VFS file write error with code 0x" << std::hex << std::setw(2)
|
|
||||||
<< result << std::endl;
|
|
||||||
#endif
|
|
||||||
tp.vfsErrorCount++;
|
|
||||||
if (tp.vfsErrorCount < 3) {
|
|
||||||
// TODO: Provide execution step as parameter
|
|
||||||
fp.eventReporter->forwardEvent(events::FILESTORE_ERROR, static_cast<uint8_t>(fsmRes.step),
|
|
||||||
result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
tp.deliveryStatus = FileDeliveryStatus::RETAINED_IN_FILESTORE;
|
|
||||||
tp.vfsErrorCount = 0;
|
|
||||||
}
|
|
||||||
if (offset.value() + fileSegmentLen > tp.progress) {
|
|
||||||
tp.progress = offset.value() + fileSegmentLen;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::handleEofPdu(const cfdp::PacketInfo& info) {
|
|
||||||
// Process EOF PDU
|
|
||||||
auto constAccessorPair = fp.tcStore->getData(info.storeId);
|
|
||||||
if (constAccessorPair.first != OK) {
|
|
||||||
// TODO: This is not a CFDP error. Event and/or warning?
|
|
||||||
return constAccessorPair.first;
|
|
||||||
}
|
|
||||||
EofInfo eofInfo(nullptr);
|
|
||||||
EofPduReader reader(constAccessorPair.second.data(), constAccessorPair.second.size(), eofInfo);
|
|
||||||
ReturnValue_t result = reader.parseData();
|
|
||||||
if (result != OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
// TODO: Error handling
|
|
||||||
if (eofInfo.getConditionCode() == ConditionCode::NO_ERROR) {
|
|
||||||
tp.crc = eofInfo.getChecksum();
|
|
||||||
uint64_t fileSizeFromEof = eofInfo.getFileSize().value();
|
|
||||||
// CFDP 4.6.1.2.9: Declare file size error if progress exceeds file size
|
|
||||||
if (fileSizeFromEof > tp.progress) {
|
|
||||||
// TODO: File size error
|
|
||||||
}
|
|
||||||
tp.fileSize.setFileSize(fileSizeFromEof, std::nullopt);
|
|
||||||
}
|
|
||||||
if (dp.cfg.indicCfg.eofRecvIndicRequired) {
|
|
||||||
dp.user.eofRecvIndication(getTransactionId());
|
|
||||||
}
|
|
||||||
if (fsmRes.step == TransactionStep::RECEIVING_FILE_DATA_PDUS) {
|
|
||||||
if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) {
|
|
||||||
fsmRes.step = TransactionStep::TRANSFER_COMPLETION;
|
|
||||||
} else if (fsmRes.state == CfdpStates::BUSY_CLASS_2_ACKED) {
|
|
||||||
fsmRes.step = TransactionStep::SENDING_ACK_PDU;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return returnvalue::OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::handleMetadataParseError(ReturnValue_t result,
|
|
||||||
const uint8_t* rawData, size_t maxSize) {
|
|
||||||
// TODO: try to extract destination ID for error
|
|
||||||
// TODO: Invalid metadata PDU.
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "Parsing Metadata PDU failed with code " << result << std::endl;
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
PduHeaderReader headerReader(rawData, maxSize);
|
|
||||||
result = headerReader.parseData();
|
|
||||||
if (result != OK) {
|
|
||||||
// TODO: Now this really should not happen. Warning or error,
|
|
||||||
// yield or cache appropriate returnvalue
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "Parsing Header failed" << std::endl;
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
// TODO: Trigger appropriate event
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
cfdp::EntityId destId;
|
|
||||||
headerReader.getDestId(destId);
|
|
||||||
RemoteEntityCfg* remoteCfg;
|
|
||||||
if (not dp.remoteCfgTable.getRemoteCfg(destId, &remoteCfg)) {
|
|
||||||
// TODO: No remote config for dest ID. I consider this a configuration error, which is not
|
|
||||||
// covered by the standard.
|
|
||||||
// Warning or error, yield or cache appropriate returnvalue
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "No remote config exists for destination ID" << std::endl;
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
// TODO: Trigger appropriate event
|
|
||||||
}
|
|
||||||
// TODO: Appropriate returnvalue?
|
|
||||||
return returnvalue::FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::startTransaction(MetadataPduReader& reader, MetadataInfo& info) {
|
|
||||||
if (fsmRes.state != CfdpStates::IDLE) {
|
|
||||||
// According to standard, discard metadata PDU if we are busy
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
ReturnValue_t result = OK;
|
|
||||||
size_t sourceNameSize = 0;
|
|
||||||
|
|
||||||
const uint8_t* sourceNamePtr = info.getSourceFileName().getValue(&sourceNameSize);
|
|
||||||
if (sourceNameSize + 1 > tp.sourceName.size()) {
|
|
||||||
fileErrorHandler(events::FILENAME_TOO_LARGE_ERROR, 0, "source filename too large");
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
std::memcpy(tp.sourceName.data(), sourceNamePtr, sourceNameSize);
|
|
||||||
tp.sourceName[sourceNameSize] = '\0';
|
|
||||||
size_t destNameSize = 0;
|
|
||||||
const uint8_t* destNamePtr = info.getDestFileName().getValue(&destNameSize);
|
|
||||||
if (destNameSize + 1 > tp.destName.size()) {
|
|
||||||
fileErrorHandler(events::FILENAME_TOO_LARGE_ERROR, 0, "dest filename too large");
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
std::memcpy(tp.destName.data(), destNamePtr, destNameSize);
|
|
||||||
tp.destName[destNameSize] = '\0';
|
|
||||||
|
|
||||||
// If both dest name size and source name size are 0, we are dealing with a metadata only PDU,
|
|
||||||
// so there is no need to create a file or truncate an existing file
|
|
||||||
if (destNameSize > 0 and sourceNameSize > 0) {
|
|
||||||
FilesystemParams fparams(tp.destName.data());
|
|
||||||
// handling to allow only specifying target directory. Example:
|
|
||||||
// Source path /test/hello.txt, dest path /tmp -> dest path /tmp/hello.txt
|
|
||||||
if (dp.user.vfs.isDirectory(tp.destName.data())) {
|
|
||||||
result = tryBuildingAbsoluteDestName(destNameSize);
|
|
||||||
if (result != OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (dp.user.vfs.fileExists(fparams)) {
|
|
||||||
result = dp.user.vfs.truncateFile(fparams);
|
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
fileErrorHandler(events::FILESTORE_ERROR, result, "file truncation error");
|
|
||||||
return FAILED;
|
|
||||||
// TODO: Relevant for filestore rejection error?
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
result = dp.user.vfs.createFile(fparams);
|
|
||||||
if (result != OK) {
|
|
||||||
fileErrorHandler(events::FILESTORE_ERROR, result, "file creation error");
|
|
||||||
return FAILED;
|
|
||||||
// TODO: Relevant for filestore rejection error?
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EntityId sourceId;
|
|
||||||
reader.getSourceId(sourceId);
|
|
||||||
if (not dp.remoteCfgTable.getRemoteCfg(sourceId, &tp.remoteCfg)) {
|
|
||||||
// TODO: Warning, event etc.
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "cfdp::DestHandler" << __func__
|
|
||||||
<< ": No remote configuration found for destination ID "
|
|
||||||
<< tp.pduConf.sourceId.getValue() << std::endl;
|
|
||||||
#endif
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
fsmRes.step = TransactionStep::TRANSACTION_START;
|
|
||||||
if (reader.getTransmissionMode() == TransmissionMode::UNACKNOWLEDGED) {
|
|
||||||
fsmRes.state = CfdpStates::BUSY_CLASS_1_NACKED;
|
|
||||||
} else if (reader.getTransmissionMode() == TransmissionMode::ACKNOWLEDGED) {
|
|
||||||
fsmRes.state = CfdpStates::BUSY_CLASS_2_ACKED;
|
|
||||||
}
|
|
||||||
tp.checksumType = info.getChecksumType();
|
|
||||||
tp.closureRequested = info.isClosureRequested();
|
|
||||||
reader.fillConfig(tp.pduConf);
|
|
||||||
tp.pduConf.direction = Direction::TOWARDS_SENDER;
|
|
||||||
tp.transactionId.entityId = tp.pduConf.sourceId;
|
|
||||||
tp.transactionId.seqNum = tp.pduConf.seqNum;
|
|
||||||
fsmRes.step = TransactionStep::RECEIVING_FILE_DATA_PDUS;
|
|
||||||
MetadataRecvdParams params(tp.transactionId, tp.pduConf.sourceId);
|
|
||||||
params.fileSize = tp.fileSize.getSize();
|
|
||||||
params.destFileName = tp.destName.data();
|
|
||||||
params.sourceFileName = tp.sourceName.data();
|
|
||||||
params.msgsToUserArray = dynamic_cast<MessageToUserTlv*>(userTlvVec.data());
|
|
||||||
params.msgsToUserLen = info.getOptionsLen();
|
|
||||||
dp.user.metadataRecvdIndication(params);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfdp::CfdpStates cfdp::DestHandler::getCfdpState() const { return fsmRes.state; }
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::handleTransferCompletion() {
|
|
||||||
ReturnValue_t result;
|
|
||||||
if (tp.checksumType != ChecksumType::NULL_CHECKSUM) {
|
|
||||||
result = checksumVerification();
|
|
||||||
if (result != OK) {
|
|
||||||
// TODO: Warning / error handling?
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
tp.conditionCode = ConditionCode::NO_ERROR;
|
|
||||||
}
|
|
||||||
result = noticeOfCompletion();
|
|
||||||
if (result != OK) {
|
|
||||||
}
|
|
||||||
if (fsmRes.state == CfdpStates::BUSY_CLASS_1_NACKED) {
|
|
||||||
if (tp.closureRequested) {
|
|
||||||
fsmRes.step = TransactionStep::SENDING_FINISHED_PDU;
|
|
||||||
} else {
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
} else if (fsmRes.state == CfdpStates::BUSY_CLASS_2_ACKED) {
|
|
||||||
fsmRes.step = TransactionStep::SENDING_FINISHED_PDU;
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::tryBuildingAbsoluteDestName(size_t destNameSize) {
|
|
||||||
char baseNameBuf[tp.destName.size()]{};
|
|
||||||
FilesystemParams fparamsSrc(tp.sourceName.data());
|
|
||||||
size_t baseNameLen = 0;
|
|
||||||
ReturnValue_t result =
|
|
||||||
dp.user.vfs.getBaseFilename(fparamsSrc, baseNameBuf, sizeof(baseNameBuf), baseNameLen);
|
|
||||||
if (result != returnvalue::OK or baseNameLen == 0) {
|
|
||||||
fileErrorHandler(events::FILENAME_TOO_LARGE_ERROR, 0, "error retrieving source base name");
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
// Destination name + slash + base name + null termination
|
|
||||||
if (destNameSize + 1 + baseNameLen + 1 > tp.destName.size()) {
|
|
||||||
fileErrorHandler(events::FILENAME_TOO_LARGE_ERROR, 0,
|
|
||||||
"dest filename too large after adding source base name");
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
tp.destName[destNameSize++] = '/';
|
|
||||||
std::memcpy(tp.destName.data() + destNameSize, baseNameBuf, baseNameLen);
|
|
||||||
destNameSize += baseNameLen;
|
|
||||||
tp.destName[destNameSize++] = '\0';
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cfdp::DestHandler::fileErrorHandler(Event event, ReturnValue_t result, const char* info) {
|
|
||||||
fp.eventReporter->forwardEvent(events::FILENAME_TOO_LARGE_ERROR,
|
|
||||||
static_cast<uint8_t>(fsmRes.step), result);
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "cfdp::DestHandler: " << info << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void cfdp::DestHandler::finish() {
|
|
||||||
tp.reset();
|
|
||||||
dp.packetListRef.clear();
|
|
||||||
fsmRes.state = CfdpStates::IDLE;
|
|
||||||
fsmRes.step = TransactionStep::IDLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::checksumVerification() {
|
|
||||||
std::array<uint8_t, 1024> buf{};
|
|
||||||
// TODO: Checksum verification and notice of completion
|
|
||||||
etl::crc32 crcCalc;
|
|
||||||
uint64_t currentOffset = 0;
|
|
||||||
FileOpParams params(tp.destName.data(), tp.fileSize.value());
|
|
||||||
while (currentOffset < tp.fileSize.value()) {
|
|
||||||
uint64_t readLen;
|
|
||||||
if (currentOffset + buf.size() > tp.fileSize.value()) {
|
|
||||||
readLen = tp.fileSize.value() - currentOffset;
|
|
||||||
} else {
|
|
||||||
readLen = buf.size();
|
|
||||||
}
|
|
||||||
if (readLen > 0) {
|
|
||||||
params.offset = currentOffset;
|
|
||||||
params.size = readLen;
|
|
||||||
auto result = dp.user.vfs.readFromFile(params, buf.data(), buf.size());
|
|
||||||
if (result != OK) {
|
|
||||||
// TODO: I think this is a case for a filestore rejection, but it might sense to print
|
|
||||||
// a warning or trigger an event because this should generally not happen
|
|
||||||
return FAILED;
|
|
||||||
}
|
|
||||||
crcCalc.add(buf.begin(), buf.begin() + readLen);
|
|
||||||
}
|
|
||||||
currentOffset += readLen;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t value = crcCalc.value();
|
|
||||||
if (value == tp.crc) {
|
|
||||||
tp.conditionCode = ConditionCode::NO_ERROR;
|
|
||||||
tp.deliveryCode = FileDeliveryCode::DATA_COMPLETE;
|
|
||||||
} else {
|
|
||||||
// TODO: Proper error handling
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "CRC check for file " << tp.destName.data() << " failed" << std::endl;
|
|
||||||
#endif
|
|
||||||
tp.conditionCode = ConditionCode::FILE_CHECKSUM_FAILURE;
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::noticeOfCompletion() {
|
|
||||||
if (dp.cfg.indicCfg.transactionFinishedIndicRequired) {
|
|
||||||
TransactionFinishedParams params(tp.transactionId, tp.conditionCode, tp.deliveryCode,
|
|
||||||
tp.deliveryStatus);
|
|
||||||
dp.user.transactionFinishedIndication(params);
|
|
||||||
}
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t cfdp::DestHandler::sendFinishedPdu() {
|
|
||||||
FinishedInfo info(tp.conditionCode, tp.deliveryCode, tp.deliveryStatus);
|
|
||||||
FinishPduCreator finishedPdu(tp.pduConf, info);
|
|
||||||
store_address_t storeId;
|
|
||||||
uint8_t* dataPtr = nullptr;
|
|
||||||
ReturnValue_t result =
|
|
||||||
fp.tmStore->getFreeElement(&storeId, finishedPdu.getSerializedSize(), &dataPtr);
|
|
||||||
if (result != OK) {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "cfdp::DestHandler:sendFinishedPdu: Getting store slot failed" << std::endl;
|
|
||||||
#endif
|
|
||||||
fp.eventReporter->forwardEvent(events::STORE_ERROR, result, 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
size_t serLen = 0;
|
|
||||||
result = finishedPdu.serialize(dataPtr, serLen, finishedPdu.getSerializedSize());
|
|
||||||
if (result != OK) {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "cfdp::DestHandler::sendFinishedPdu: Serializing Finished PDU failed"
|
|
||||||
<< std::endl;
|
|
||||||
#endif
|
|
||||||
fp.eventReporter->forwardEvent(events::SERIALIZATION_ERROR, result, 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
TmTcMessage msg(storeId);
|
|
||||||
result = fp.msgQueue->sendMessage(fp.packetDest.getReportReceptionQueue(), &msg);
|
|
||||||
if (result != OK) {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "cfdp::DestHandler::sendFinishedPdu: Sending PDU failed" << std::endl;
|
|
||||||
#endif
|
|
||||||
fp.eventReporter->forwardEvent(events::MSG_QUEUE_ERROR, result, 0);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
fsmRes.packetsSent++;
|
|
||||||
return OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
cfdp::DestHandler::TransactionStep cfdp::DestHandler::getTransactionStep() const {
|
|
||||||
return fsmRes.step;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cfdp::DestHandler::FsmResult& cfdp::DestHandler::updateFsmRes(uint8_t errors) {
|
|
||||||
fsmRes.errors = errors;
|
|
||||||
fsmRes.result = OK;
|
|
||||||
if (fsmRes.errors > 0) {
|
|
||||||
fsmRes.result = FAILED;
|
|
||||||
}
|
|
||||||
return fsmRes;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cfdp::TransactionId& cfdp::DestHandler::getTransactionId() const { return tp.transactionId; }
|
|
||||||
|
|
||||||
void cfdp::DestHandler::checkAndHandleError(ReturnValue_t result, uint8_t& errorIdx) {
|
|
||||||
if (result != OK and errorIdx < 3) {
|
|
||||||
fsmRes.errorCodes[errorIdx] = result;
|
|
||||||
errorIdx++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void cfdp::DestHandler::setMsgQueue(MessageQueueIF& queue) { fp.msgQueue = &queue; }
|
|
||||||
|
|
||||||
void cfdp::DestHandler::setEventReporter(EventReportingProxyIF& reporter) {
|
|
||||||
fp.eventReporter = &reporter;
|
|
||||||
}
|
|
||||||
|
|
||||||
const cfdp::DestHandlerParams& cfdp::DestHandler::getDestHandlerParams() const { return dp; }
|
|
||||||
|
|
||||||
StorageManagerIF* cfdp::DestHandler::getTmStore() const { return fp.tmStore; }
|
|
||||||
StorageManagerIF* cfdp::DestHandler::getTcStore() const { return fp.tcStore; }
|
|
@ -1,206 +0,0 @@
|
|||||||
#ifndef FSFW_CFDP_CFDPDESTHANDLER_H
|
|
||||||
#define FSFW_CFDP_CFDPDESTHANDLER_H
|
|
||||||
|
|
||||||
#include <etl/list.h>
|
|
||||||
#include <etl/set.h>
|
|
||||||
|
|
||||||
#include <optional>
|
|
||||||
#include <utility>
|
|
||||||
|
|
||||||
#include "RemoteConfigTableIF.h"
|
|
||||||
#include "UserBase.h"
|
|
||||||
#include "defs.h"
|
|
||||||
#include "fsfw/cfdp/handler/mib.h"
|
|
||||||
#include "fsfw/cfdp/pdu/MetadataPduReader.h"
|
|
||||||
#include "fsfw/cfdp/pdu/PduConfig.h"
|
|
||||||
#include "fsfw/container/DynamicFIFO.h"
|
|
||||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
|
||||||
#include "fsfw/storagemanager/storeAddress.h"
|
|
||||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
|
||||||
|
|
||||||
namespace cfdp {
|
|
||||||
|
|
||||||
struct PacketInfo {
|
|
||||||
PacketInfo(PduType type, store_address_t storeId,
|
|
||||||
std::optional<FileDirective> directive = std::nullopt)
|
|
||||||
: pduType(type), directiveType(directive), storeId(storeId) {}
|
|
||||||
|
|
||||||
PduType pduType = PduType::FILE_DATA;
|
|
||||||
std::optional<FileDirective> directiveType = FileDirective::INVALID_DIRECTIVE;
|
|
||||||
store_address_t storeId = store_address_t::invalid();
|
|
||||||
PacketInfo() = default;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <size_t SIZE>
|
|
||||||
using LostSegmentsList = etl::set<etl::pair<uint64_t, uint64_t>, SIZE>;
|
|
||||||
template <size_t SIZE>
|
|
||||||
using PacketInfoList = etl::list<PacketInfo, SIZE>;
|
|
||||||
using LostSegmentsListBase = etl::iset<etl::pair<uint64_t, uint64_t>>;
|
|
||||||
using PacketInfoListBase = etl::ilist<PacketInfo>;
|
|
||||||
|
|
||||||
struct DestHandlerParams {
|
|
||||||
DestHandlerParams(LocalEntityCfg cfg, UserBase& user, RemoteConfigTableIF& remoteCfgTable,
|
|
||||||
PacketInfoListBase& packetList,
|
|
||||||
// TODO: This container can potentially take tons of space. For a better
|
|
||||||
// memory efficient implementation, an additional abstraction could be
|
|
||||||
// be used so users can use uint32_t as the pair type
|
|
||||||
LostSegmentsListBase& lostSegmentsContainer)
|
|
||||||
: cfg(std::move(cfg)),
|
|
||||||
user(user),
|
|
||||||
remoteCfgTable(remoteCfgTable),
|
|
||||||
packetListRef(packetList),
|
|
||||||
lostSegmentsContainer(lostSegmentsContainer) {}
|
|
||||||
|
|
||||||
LocalEntityCfg cfg;
|
|
||||||
UserBase& user;
|
|
||||||
RemoteConfigTableIF& remoteCfgTable;
|
|
||||||
|
|
||||||
PacketInfoListBase& packetListRef;
|
|
||||||
LostSegmentsListBase& lostSegmentsContainer;
|
|
||||||
uint8_t maxTlvsInOnePdu = 10;
|
|
||||||
size_t maxFilenameLen = 255;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FsfwParams {
|
|
||||||
FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue,
|
|
||||||
EventReportingProxyIF* eventReporter, StorageManagerIF& tcStore,
|
|
||||||
StorageManagerIF& tmStore)
|
|
||||||
: FsfwParams(packetDest, msgQueue, eventReporter) {
|
|
||||||
this->tcStore = &tcStore;
|
|
||||||
this->tmStore = &tmStore;
|
|
||||||
}
|
|
||||||
|
|
||||||
FsfwParams(AcceptsTelemetryIF& packetDest, MessageQueueIF* msgQueue,
|
|
||||||
EventReportingProxyIF* eventReporter)
|
|
||||||
: packetDest(packetDest), msgQueue(msgQueue), eventReporter(eventReporter) {}
|
|
||||||
AcceptsTelemetryIF& packetDest;
|
|
||||||
MessageQueueIF* msgQueue;
|
|
||||||
EventReportingProxyIF* eventReporter = nullptr;
|
|
||||||
StorageManagerIF* tcStore = nullptr;
|
|
||||||
StorageManagerIF* tmStore = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class CallStatus { DONE, CALL_AFTER_DELAY, CALL_AGAIN };
|
|
||||||
|
|
||||||
class DestHandler {
|
|
||||||
public:
|
|
||||||
enum class TransactionStep : uint8_t {
|
|
||||||
IDLE = 0,
|
|
||||||
TRANSACTION_START = 1,
|
|
||||||
RECEIVING_FILE_DATA_PDUS = 2,
|
|
||||||
SENDING_ACK_PDU = 3,
|
|
||||||
TRANSFER_COMPLETION = 4,
|
|
||||||
SENDING_FINISHED_PDU = 5
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FsmResult {
|
|
||||||
public:
|
|
||||||
ReturnValue_t result = returnvalue::OK;
|
|
||||||
CallStatus callStatus = CallStatus::CALL_AFTER_DELAY;
|
|
||||||
TransactionStep step = TransactionStep::IDLE;
|
|
||||||
CfdpStates state = CfdpStates::IDLE;
|
|
||||||
uint32_t packetsSent = 0;
|
|
||||||
uint8_t errors = 0;
|
|
||||||
std::array<ReturnValue_t, 3> errorCodes = {};
|
|
||||||
void resetOfIteration() {
|
|
||||||
result = returnvalue::OK;
|
|
||||||
callStatus = CallStatus::CALL_AFTER_DELAY;
|
|
||||||
packetsSent = 0;
|
|
||||||
errors = 0;
|
|
||||||
errorCodes.fill(returnvalue::OK);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* Will be returned if it is advisable to call the state machine operation call again
|
|
||||||
*/
|
|
||||||
ReturnValue_t PARTIAL_SUCCESS = returnvalue::makeCode(0, 2);
|
|
||||||
ReturnValue_t FAILURE = returnvalue::makeCode(0, 3);
|
|
||||||
explicit DestHandler(DestHandlerParams handlerParams, FsfwParams fsfwParams);
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return
|
|
||||||
* - @c returnvalue::OK State machine OK for this execution cycle
|
|
||||||
* - @c CALL_FSM_AGAIN State machine should be called again.
|
|
||||||
*/
|
|
||||||
const FsmResult& performStateMachine();
|
|
||||||
void setMsgQueue(MessageQueueIF& queue);
|
|
||||||
void setEventReporter(EventReportingProxyIF& reporter);
|
|
||||||
|
|
||||||
ReturnValue_t passPacket(PacketInfo packet);
|
|
||||||
|
|
||||||
ReturnValue_t initialize();
|
|
||||||
|
|
||||||
[[nodiscard]] CfdpStates getCfdpState() const;
|
|
||||||
[[nodiscard]] TransactionStep getTransactionStep() const;
|
|
||||||
[[nodiscard]] const TransactionId& getTransactionId() const;
|
|
||||||
[[nodiscard]] const DestHandlerParams& getDestHandlerParams() const;
|
|
||||||
[[nodiscard]] StorageManagerIF* getTcStore() const;
|
|
||||||
[[nodiscard]] StorageManagerIF* getTmStore() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
struct TransactionParams {
|
|
||||||
// Initialize char vectors with length + 1 for 0 termination
|
|
||||||
explicit TransactionParams(size_t maxFileNameLen)
|
|
||||||
: sourceName(maxFileNameLen + 1), destName(maxFileNameLen + 1) {}
|
|
||||||
|
|
||||||
void reset() {
|
|
||||||
pduConf = PduConfig();
|
|
||||||
transactionId = TransactionId();
|
|
||||||
std::fill(sourceName.begin(), sourceName.end(), '\0');
|
|
||||||
std::fill(destName.begin(), destName.end(), '\0');
|
|
||||||
fileSize.setFileSize(0, false);
|
|
||||||
conditionCode = ConditionCode::NO_ERROR;
|
|
||||||
deliveryCode = FileDeliveryCode::DATA_INCOMPLETE;
|
|
||||||
deliveryStatus = FileDeliveryStatus::DISCARDED_DELIBERATELY;
|
|
||||||
crc = 0;
|
|
||||||
progress = 0;
|
|
||||||
remoteCfg = nullptr;
|
|
||||||
closureRequested = false;
|
|
||||||
vfsErrorCount = 0;
|
|
||||||
checksumType = ChecksumType::NULL_CHECKSUM;
|
|
||||||
}
|
|
||||||
|
|
||||||
ChecksumType checksumType = ChecksumType::NULL_CHECKSUM;
|
|
||||||
bool closureRequested = false;
|
|
||||||
uint16_t vfsErrorCount = 0;
|
|
||||||
std::vector<char> sourceName;
|
|
||||||
std::vector<char> destName;
|
|
||||||
cfdp::FileSize fileSize;
|
|
||||||
TransactionId transactionId;
|
|
||||||
PduConfig pduConf;
|
|
||||||
ConditionCode conditionCode = ConditionCode::NO_ERROR;
|
|
||||||
FileDeliveryCode deliveryCode = FileDeliveryCode::DATA_INCOMPLETE;
|
|
||||||
FileDeliveryStatus deliveryStatus = FileDeliveryStatus::DISCARDED_DELIBERATELY;
|
|
||||||
uint32_t crc = 0;
|
|
||||||
uint64_t progress = 0;
|
|
||||||
RemoteEntityCfg* remoteCfg = nullptr;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<cfdp::Tlv> tlvVec;
|
|
||||||
std::vector<cfdp::Tlv> userTlvVec;
|
|
||||||
DestHandlerParams dp;
|
|
||||||
FsfwParams fp;
|
|
||||||
TransactionParams tp;
|
|
||||||
FsmResult fsmRes;
|
|
||||||
|
|
||||||
ReturnValue_t startTransaction(MetadataPduReader& reader, MetadataInfo& info);
|
|
||||||
ReturnValue_t handleMetadataPdu(const PacketInfo& info);
|
|
||||||
ReturnValue_t handleFileDataPdu(const PacketInfo& info);
|
|
||||||
ReturnValue_t handleEofPdu(const PacketInfo& info);
|
|
||||||
ReturnValue_t handleMetadataParseError(ReturnValue_t result, const uint8_t* rawData,
|
|
||||||
size_t maxSize);
|
|
||||||
ReturnValue_t handleTransferCompletion();
|
|
||||||
ReturnValue_t tryBuildingAbsoluteDestName(size_t destNameSize);
|
|
||||||
ReturnValue_t sendFinishedPdu();
|
|
||||||
ReturnValue_t noticeOfCompletion();
|
|
||||||
ReturnValue_t checksumVerification();
|
|
||||||
void fileErrorHandler(Event event, ReturnValue_t result, const char* info);
|
|
||||||
const FsmResult& updateFsmRes(uint8_t errors);
|
|
||||||
void checkAndHandleError(ReturnValue_t result, uint8_t& errorIdx);
|
|
||||||
void finish();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace cfdp
|
|
||||||
|
|
||||||
#endif // FSFW_CFDP_CFDPDESTHANDLER_H
|
|
@ -1 +0,0 @@
|
|||||||
#include "SourceHandler.h"
|
|
@ -1,6 +0,0 @@
|
|||||||
#ifndef FSFW_CFDP_CFDPSOURCEHANDLER_H
|
|
||||||
#define FSFW_CFDP_CFDPSOURCEHANDLER_H
|
|
||||||
|
|
||||||
class SourceHandler {};
|
|
||||||
|
|
||||||
#endif // FSFW_CFDP_CFDPSOURCEHANDLER_H
|
|
@ -5,18 +5,5 @@ namespace cfdp {
|
|||||||
|
|
||||||
enum class CfdpStates { IDLE, BUSY_CLASS_1_NACKED, BUSY_CLASS_2_ACKED, SUSPENDED };
|
enum class CfdpStates { IDLE, BUSY_CLASS_1_NACKED, BUSY_CLASS_2_ACKED, SUSPENDED };
|
||||||
|
|
||||||
static constexpr uint8_t SSID = SUBSYSTEM_ID::CFDP;
|
}
|
||||||
|
|
||||||
namespace events {
|
|
||||||
|
|
||||||
static constexpr Event STORE_ERROR = event::makeEvent(SSID, 0, severity::LOW);
|
|
||||||
static constexpr Event MSG_QUEUE_ERROR = event::makeEvent(SSID, 1, severity::LOW);
|
|
||||||
static constexpr Event SERIALIZATION_ERROR = event::makeEvent(SSID, 2, severity::LOW);
|
|
||||||
static constexpr Event FILESTORE_ERROR = event::makeEvent(SSID, 3, severity::LOW);
|
|
||||||
//! [EXPORT] : [COMMENT] P1: Transaction step ID, P2: 0 for source file name, 1 for dest file name
|
|
||||||
static constexpr Event FILENAME_TOO_LARGE_ERROR = event::makeEvent(SSID, 4, severity::LOW);
|
|
||||||
|
|
||||||
} // namespace events
|
|
||||||
|
|
||||||
} // namespace cfdp
|
|
||||||
#endif // FSFW_CFDP_HANDLER_DEFS_H
|
#endif // FSFW_CFDP_HANDLER_DEFS_H
|
||||||
|
@ -23,6 +23,8 @@ class EntityIdTlv : public TlvIF {
|
|||||||
*/
|
*/
|
||||||
ReturnValue_t deSerialize(cfdp::Tlv& tlv, Endianness endianness);
|
ReturnValue_t deSerialize(cfdp::Tlv& tlv, Endianness endianness);
|
||||||
|
|
||||||
|
using SerializeIF::deSerialize; // we overloaded this function, so this is needed to unconfuse
|
||||||
|
// the compiler
|
||||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) override;
|
Endianness streamEndianness) override;
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ class FilestoreResponseTlv : public cfdp::FilestoreTlvBase {
|
|||||||
*/
|
*/
|
||||||
ReturnValue_t deSerialize(const cfdp::Tlv& tlv, Endianness endianness);
|
ReturnValue_t deSerialize(const cfdp::Tlv& tlv, Endianness endianness);
|
||||||
|
|
||||||
|
using SerializeIF::deSerialize; // we overloaded this function, so this is needed to unconfuse
|
||||||
|
// the compiler
|
||||||
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) override;
|
Endianness streamEndianness) override;
|
||||||
|
|
||||||
|
@ -155,8 +155,8 @@ class FixedMap : public SerializeIF {
|
|||||||
|
|
||||||
uint32_t maxSize() const { return theMap.maxSize(); }
|
uint32_t maxSize() const { return theMap.maxSize(); }
|
||||||
|
|
||||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
Endianness streamEndianness) const {
|
Endianness streamEndianness) const override {
|
||||||
ReturnValue_t result =
|
ReturnValue_t result =
|
||||||
SerializeAdapter::serialize(&this->_size, buffer, size, maxSize, streamEndianness);
|
SerializeAdapter::serialize(&this->_size, buffer, size, maxSize, streamEndianness);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
@ -170,7 +170,7 @@ class FixedMap : public SerializeIF {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_t getSerializedSize() const {
|
size_t getSerializedSize() const override {
|
||||||
uint32_t printSize = sizeof(_size);
|
uint32_t printSize = sizeof(_size);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
|
||||||
@ -182,8 +182,8 @@ class FixedMap : public SerializeIF {
|
|||||||
return printSize;
|
return printSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) {
|
Endianness streamEndianness) override {
|
||||||
ReturnValue_t result =
|
ReturnValue_t result =
|
||||||
SerializeAdapter::deSerialize(&this->_size, buffer, size, streamEndianness);
|
SerializeAdapter::deSerialize(&this->_size, buffer, size, streamEndianness);
|
||||||
if (this->_size > theMap.maxSize()) {
|
if (this->_size > theMap.maxSize()) {
|
||||||
|
@ -4,31 +4,48 @@
|
|||||||
#include "fsfw/ipc/QueueFactory.h"
|
#include "fsfw/ipc/QueueFactory.h"
|
||||||
#include "fsfw/objectmanager/ObjectManager.h"
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
#include "fsfw/subsystem/SubsystemBase.h"
|
#include "fsfw/subsystem/SubsystemBase.h"
|
||||||
#include "fsfw/subsystem/helper.h"
|
|
||||||
|
|
||||||
ControllerBase::ControllerBase(object_id_t setObjectId, size_t commandQueueDepth)
|
ControllerBase::ControllerBase(object_id_t setObjectId, object_id_t parentId,
|
||||||
|
size_t commandQueueDepth)
|
||||||
: SystemObject(setObjectId),
|
: SystemObject(setObjectId),
|
||||||
|
parentId(parentId),
|
||||||
mode(MODE_OFF),
|
mode(MODE_OFF),
|
||||||
submode(SUBMODE_NONE),
|
submode(SUBMODE_NONE),
|
||||||
modeHelper(this),
|
modeHelper(this),
|
||||||
healthHelper(this, setObjectId) {
|
healthHelper(this, setObjectId) {
|
||||||
auto mqArgs = MqArgs(setObjectId, static_cast<void*>(this));
|
commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth);
|
||||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
|
||||||
commandQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ControllerBase::~ControllerBase() { QueueFactory::instance()->deleteMessageQueue(commandQueue); }
|
ControllerBase::~ControllerBase() { QueueFactory::instance()->deleteMessageQueue(commandQueue); }
|
||||||
|
|
||||||
ReturnValue_t ControllerBase::initialize() {
|
ReturnValue_t ControllerBase::initialize() {
|
||||||
ReturnValue_t result = modeHelper.initialize();
|
ReturnValue_t result = SystemObject::initialize();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result = healthHelper.initialize();
|
|
||||||
|
MessageQueueId_t parentQueue = 0;
|
||||||
|
if (parentId != objects::NO_OBJECT) {
|
||||||
|
auto* parent = ObjectManager::instance()->get<SubsystemBase>(parentId);
|
||||||
|
if (parent == nullptr) {
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
||||||
|
parentQueue = parent->getCommandQueue();
|
||||||
|
|
||||||
|
parent->registerChild(getObjectId());
|
||||||
|
}
|
||||||
|
|
||||||
|
result = healthHelper.initialize(parentQueue);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
return SystemObject::initialize();
|
|
||||||
|
result = modeHelper.initialize(parentQueue);
|
||||||
|
if (result != returnvalue::OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueId_t ControllerBase::getCommandQueue() const { return commandQueue->getId(); }
|
MessageQueueId_t ControllerBase::getCommandQueue() const { return commandQueue->getId(); }
|
||||||
@ -58,7 +75,7 @@ void ControllerBase::handleQueue() {
|
|||||||
|
|
||||||
void ControllerBase::startTransition(Mode_t mode_, Submode_t submode_) {
|
void ControllerBase::startTransition(Mode_t mode_, Submode_t submode_) {
|
||||||
changeHK(this->mode, this->submode, false);
|
changeHK(this->mode, this->submode, false);
|
||||||
triggerEvent(CHANGING_MODE, mode_, submode_);
|
triggerEvent(CHANGING_MODE, mode, submode);
|
||||||
mode = mode_;
|
mode = mode_;
|
||||||
submode = submode_;
|
submode = submode_;
|
||||||
modeHelper.modeChanged(mode, submode);
|
modeHelper.modeChanged(mode, submode);
|
||||||
@ -101,13 +118,3 @@ void ControllerBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = task_; }
|
|||||||
void ControllerBase::changeHK(Mode_t mode_, Submode_t submode_, bool enable) {}
|
void ControllerBase::changeHK(Mode_t mode_, Submode_t submode_, bool enable) {}
|
||||||
|
|
||||||
ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return returnvalue::OK; }
|
ReturnValue_t ControllerBase::initializeAfterTaskCreation() { return returnvalue::OK; }
|
||||||
|
|
||||||
const HasHealthIF* ControllerBase::getOptHealthIF() const { return this; }
|
|
||||||
|
|
||||||
const HasModesIF& ControllerBase::getModeIF() const { return *this; }
|
|
||||||
|
|
||||||
ModeTreeChildIF& ControllerBase::getModeTreeChildIF() { return *this; }
|
|
||||||
|
|
||||||
ReturnValue_t ControllerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) {
|
|
||||||
return modetree::connectModeTreeParent(parent, *this, &healthHelper, modeHelper);
|
|
||||||
}
|
|
||||||
|
@ -6,9 +6,6 @@
|
|||||||
#include "fsfw/modes/HasModesIF.h"
|
#include "fsfw/modes/HasModesIF.h"
|
||||||
#include "fsfw/modes/ModeHelper.h"
|
#include "fsfw/modes/ModeHelper.h"
|
||||||
#include "fsfw/objectmanager/SystemObject.h"
|
#include "fsfw/objectmanager/SystemObject.h"
|
||||||
#include "fsfw/subsystem/HasModeTreeChildrenIF.h"
|
|
||||||
#include "fsfw/subsystem/ModeTreeChildIF.h"
|
|
||||||
#include "fsfw/subsystem/ModeTreeConnectionIF.h"
|
|
||||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||||
#include "fsfw/tasks/PeriodicTaskIF.h"
|
#include "fsfw/tasks/PeriodicTaskIF.h"
|
||||||
|
|
||||||
@ -21,18 +18,13 @@
|
|||||||
class ControllerBase : public HasModesIF,
|
class ControllerBase : public HasModesIF,
|
||||||
public HasHealthIF,
|
public HasHealthIF,
|
||||||
public ExecutableObjectIF,
|
public ExecutableObjectIF,
|
||||||
public ModeTreeChildIF,
|
|
||||||
public ModeTreeConnectionIF,
|
|
||||||
public SystemObject {
|
public SystemObject {
|
||||||
public:
|
public:
|
||||||
static const Mode_t MODE_NORMAL = 2;
|
static const Mode_t MODE_NORMAL = 2;
|
||||||
|
|
||||||
ControllerBase(object_id_t setObjectId, size_t commandQueueDepth = 3);
|
ControllerBase(object_id_t setObjectId, object_id_t parentId, size_t commandQueueDepth = 3);
|
||||||
~ControllerBase() override;
|
~ControllerBase() override;
|
||||||
|
|
||||||
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
|
|
||||||
ModeTreeChildIF &getModeTreeChildIF() override;
|
|
||||||
|
|
||||||
/** SystemObject override */
|
/** SystemObject override */
|
||||||
ReturnValue_t initialize() override;
|
ReturnValue_t initialize() override;
|
||||||
|
|
||||||
@ -46,8 +38,6 @@ class ControllerBase : public HasModesIF,
|
|||||||
ReturnValue_t performOperation(uint8_t opCode) override;
|
ReturnValue_t performOperation(uint8_t opCode) override;
|
||||||
void setTaskIF(PeriodicTaskIF *task) override;
|
void setTaskIF(PeriodicTaskIF *task) override;
|
||||||
ReturnValue_t initializeAfterTaskCreation() override;
|
ReturnValue_t initializeAfterTaskCreation() override;
|
||||||
const HasHealthIF *getOptHealthIF() const override;
|
|
||||||
const HasModesIF &getModeIF() const override;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
@ -66,6 +56,8 @@ class ControllerBase : public HasModesIF,
|
|||||||
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||||
uint32_t *msToReachTheMode) override = 0;
|
uint32_t *msToReachTheMode) override = 0;
|
||||||
|
|
||||||
|
const object_id_t parentId;
|
||||||
|
|
||||||
Mode_t mode;
|
Mode_t mode;
|
||||||
|
|
||||||
Submode_t submode;
|
Submode_t submode;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
#include "fsfw/controller/ExtendedControllerBase.h"
|
#include "fsfw/controller/ExtendedControllerBase.h"
|
||||||
|
|
||||||
ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, size_t commandQueueDepth)
|
ExtendedControllerBase::ExtendedControllerBase(object_id_t objectId, object_id_t parentId,
|
||||||
: ControllerBase(objectId, commandQueueDepth),
|
size_t commandQueueDepth)
|
||||||
|
: ControllerBase(objectId, parentId, commandQueueDepth),
|
||||||
poolManager(this, commandQueue),
|
poolManager(this, commandQueue),
|
||||||
actionHelper(this, commandQueue) {}
|
actionHelper(this, commandQueue) {}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class ExtendedControllerBase : public ControllerBase,
|
|||||||
public HasActionsIF,
|
public HasActionsIF,
|
||||||
public HasLocalDataPoolIF {
|
public HasLocalDataPoolIF {
|
||||||
public:
|
public:
|
||||||
ExtendedControllerBase(object_id_t objectId, size_t commandQueueDepth = 3);
|
ExtendedControllerBase(object_id_t objectId, object_id_t parentId, size_t commandQueueDepth = 3);
|
||||||
~ExtendedControllerBase() override;
|
~ExtendedControllerBase() override;
|
||||||
|
|
||||||
/* SystemObjectIF overrides */
|
/* SystemObjectIF overrides */
|
||||||
|
@ -166,9 +166,9 @@ ReturnValue_t Sgp4Propagator::propagate(double* position, double* velocity, time
|
|||||||
timeval timeSinceEpoch = time - epoch;
|
timeval timeSinceEpoch = time - epoch;
|
||||||
double minutesSinceEpoch = timeSinceEpoch.tv_sec / 60. + timeSinceEpoch.tv_usec / 60000000.;
|
double minutesSinceEpoch = timeSinceEpoch.tv_sec / 60. + timeSinceEpoch.tv_usec / 60000000.;
|
||||||
|
|
||||||
double monthsSinceEpoch = minutesSinceEpoch / 60 / 24 / 30;
|
double yearsSinceEpoch = minutesSinceEpoch / 60 / 24 / 365;
|
||||||
|
|
||||||
if ((monthsSinceEpoch > 1) || (monthsSinceEpoch < -1)) {
|
if ((yearsSinceEpoch > 1) || (yearsSinceEpoch < -1)) {
|
||||||
return TLE_TOO_OLD;
|
return TLE_TOO_OLD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF {
|
|||||||
* - @c SET_WAS_ALREADY_READ if read() is called twice without calling
|
* - @c SET_WAS_ALREADY_READ if read() is called twice without calling
|
||||||
* commit() in between
|
* commit() in between
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t read(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
ReturnValue_t read(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
||||||
uint32_t lockTimeout = 20) override;
|
uint32_t lockTimeout = 20) override;
|
||||||
/**
|
/**
|
||||||
* @brief The commit call initializes writing back the registered variables.
|
* @brief The commit call initializes writing back the registered variables.
|
||||||
@ -84,7 +84,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF {
|
|||||||
* - @c COMMITING_WITHOUT_READING if set was not read yet and
|
* - @c COMMITING_WITHOUT_READING if set was not read yet and
|
||||||
* contains non write-only variables
|
* contains non write-only variables
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t commit(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
ReturnValue_t commit(MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING,
|
||||||
uint32_t lockTimeout = 20) override;
|
uint32_t lockTimeout = 20) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,7 +92,7 @@ class PoolDataSetBase : public PoolDataSetIF, public SerializeIF {
|
|||||||
* @param variable
|
* @param variable
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t registerVariable(PoolVariableIF* variable) override;
|
ReturnValue_t registerVariable(PoolVariableIF* variable) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides the means to lock the underlying data structure to ensure
|
* Provides the means to lock the underlying data structure to ensure
|
||||||
|
@ -70,7 +70,8 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LocalDataPoolManager::initializeAfterTaskCreation() {
|
ReturnValue_t LocalDataPoolManager::initializeAfterTaskCreation(uint8_t nonDiagInvlFactor) {
|
||||||
|
setNonDiagnosticIntervalFactor(nonDiagInvlFactor);
|
||||||
return initializeHousekeepingPoolEntriesOnce();
|
return initializeHousekeepingPoolEntriesOnce();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -505,9 +506,9 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me
|
|||||||
float newCollIntvl = 0;
|
float newCollIntvl = 0;
|
||||||
HousekeepingMessage::getCollectionIntervalModificationCommand(message, &newCollIntvl);
|
HousekeepingMessage::getCollectionIntervalModificationCommand(message, &newCollIntvl);
|
||||||
if (command == HousekeepingMessage::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL) {
|
if (command == HousekeepingMessage::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL) {
|
||||||
result = changeCollectionInterval(sid, newCollIntvl);
|
result = changeCollectionInterval(sid, newCollIntvl, true);
|
||||||
} else {
|
} else {
|
||||||
result = changeCollectionInterval(sid, newCollIntvl);
|
result = changeCollectionInterval(sid, newCollIntvl, false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -569,10 +570,6 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(CommandMessage* me
|
|||||||
|
|
||||||
CommandMessage reply;
|
CommandMessage reply;
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
if (result == WRONG_HK_PACKET_TYPE) {
|
|
||||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "handleHousekeepingMessage",
|
|
||||||
WRONG_HK_PACKET_TYPE);
|
|
||||||
}
|
|
||||||
HousekeepingMessage::setHkRequestFailureReply(&reply, sid, result);
|
HousekeepingMessage::setHkRequestFailureReply(&reply, sid, result);
|
||||||
} else {
|
} else {
|
||||||
HousekeepingMessage::setHkRequestSuccessReply(&reply, sid);
|
HousekeepingMessage::setHkRequestSuccessReply(&reply, sid);
|
||||||
@ -660,6 +657,10 @@ ReturnValue_t LocalDataPoolManager::serializeHkPacketIntoStore(HousekeepingPacke
|
|||||||
return hkPacket.serialize(&dataPtr, serializedSize, maxSize, SerializeIF::Endianness::MACHINE);
|
return hkPacket.serialize(&dataPtr, serializedSize, maxSize, SerializeIF::Endianness::MACHINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LocalDataPoolManager::setNonDiagnosticIntervalFactor(uint8_t nonDiagInvlFactor) {
|
||||||
|
this->nonDiagnosticIntervalFactor = nonDiagInvlFactor;
|
||||||
|
}
|
||||||
|
|
||||||
void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
|
void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
|
||||||
sid_t sid = receiver.dataId.sid;
|
sid_t sid = receiver.dataId.sid;
|
||||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||||
@ -713,15 +714,15 @@ ReturnValue_t LocalDataPoolManager::togglePeriodicGeneration(sid_t sid, bool ena
|
|||||||
|
|
||||||
if ((LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and enable) or
|
if ((LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and enable) or
|
||||||
(not LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and not enable)) {
|
(not LocalPoolDataSetAttorney::getReportingEnabled(*dataSet) and not enable)) {
|
||||||
return returnvalue::OK;
|
return REPORTING_STATUS_UNCHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enable);
|
LocalPoolDataSetAttorney::setReportingEnabled(*dataSet, enable);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid,
|
ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid, float newCollectionInterval,
|
||||||
float newCollectionInterval) {
|
bool isDiagnostics) {
|
||||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||||
if (dataSet == nullptr) {
|
if (dataSet == nullptr) {
|
||||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "changeCollectionInterval",
|
printWarningOrError(sif::OutputTypes::OUT_WARNING, "changeCollectionInterval",
|
||||||
@ -729,6 +730,11 @@ ReturnValue_t LocalDataPoolManager::changeCollectionInterval(sid_t sid,
|
|||||||
return DATASET_NOT_FOUND;
|
return DATASET_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool targetIsDiagnostics = LocalPoolDataSetAttorney::isDiagnostics(*dataSet);
|
||||||
|
if ((targetIsDiagnostics and not isDiagnostics) or (not targetIsDiagnostics and isDiagnostics)) {
|
||||||
|
return WRONG_HK_PACKET_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
PeriodicHousekeepingHelper* periodicHelper =
|
PeriodicHousekeepingHelper* periodicHelper =
|
||||||
LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
|
LocalPoolDataSetAttorney::getPeriodicHelper(*dataSet);
|
||||||
|
|
||||||
@ -819,8 +825,6 @@ void LocalDataPoolManager::printWarningOrError(sif::OutputTypes outputType,
|
|||||||
errorPrint = "Dataset not found";
|
errorPrint = "Dataset not found";
|
||||||
} else if (error == POOLOBJECT_NOT_FOUND) {
|
} else if (error == POOLOBJECT_NOT_FOUND) {
|
||||||
errorPrint = "Pool Object not found";
|
errorPrint = "Pool Object not found";
|
||||||
} else if (error == WRONG_HK_PACKET_TYPE) {
|
|
||||||
errorPrint = "Wrong Packet Type";
|
|
||||||
} else if (error == returnvalue::FAILED) {
|
} else if (error == returnvalue::FAILED) {
|
||||||
if (outputType == sif::OutputTypes::OUT_WARNING) {
|
if (outputType == sif::OutputTypes::OUT_WARNING) {
|
||||||
errorPrint = "Generic Warning";
|
errorPrint = "Generic Warning";
|
||||||
|
@ -102,7 +102,7 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
|
|||||||
* @param nonDiagInvlFactor
|
* @param nonDiagInvlFactor
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ReturnValue_t initializeAfterTaskCreation();
|
ReturnValue_t initializeAfterTaskCreation(uint8_t nonDiagInvlFactor = 5);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This should be called in the periodic handler of the owner.
|
* @brief This should be called in the periodic handler of the owner.
|
||||||
@ -152,6 +152,17 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
|
|||||||
MessageQueueId_t targetQueueId,
|
MessageQueueId_t targetQueueId,
|
||||||
bool generateSnapshot) override;
|
bool generateSnapshot) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Non-Diagnostics packets usually have a lower minimum sampling frequency
|
||||||
|
* than diagnostic packets.
|
||||||
|
* A factor can be specified to determine the minimum sampling frequency
|
||||||
|
* for non-diagnostic packets. The minimum sampling frequency of the
|
||||||
|
* diagnostics packets,which is usually jusst the period of the
|
||||||
|
* performOperation calls, is multiplied with that factor.
|
||||||
|
* @param factor
|
||||||
|
*/
|
||||||
|
void setNonDiagnosticIntervalFactor(uint8_t nonDiagInvlFactor);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The manager is also able to handle housekeeping messages.
|
* @brief The manager is also able to handle housekeeping messages.
|
||||||
* @details
|
* @details
|
||||||
@ -174,7 +185,6 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
|
|||||||
ReturnValue_t generateHousekeepingPacket(sid_t sid, LocalPoolDataSetBase* dataSet,
|
ReturnValue_t generateHousekeepingPacket(sid_t sid, LocalPoolDataSetBase* dataSet,
|
||||||
bool forDownlink,
|
bool forDownlink,
|
||||||
MessageQueueId_t destination = MessageQueueIF::NO_QUEUE);
|
MessageQueueId_t destination = MessageQueueIF::NO_QUEUE);
|
||||||
ReturnValue_t changeCollectionInterval(sid_t sid, float newCollectionInterval);
|
|
||||||
|
|
||||||
HasLocalDataPoolIF* getOwner();
|
HasLocalDataPoolIF* getOwner();
|
||||||
|
|
||||||
@ -338,6 +348,8 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces
|
|||||||
|
|
||||||
void performPeriodicHkGeneration(HkReceiver& hkReceiver);
|
void performPeriodicHkGeneration(HkReceiver& hkReceiver);
|
||||||
ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable, bool isDiagnostics);
|
ReturnValue_t togglePeriodicGeneration(sid_t sid, bool enable, bool isDiagnostics);
|
||||||
|
ReturnValue_t changeCollectionInterval(sid_t sid, float newCollectionInterval,
|
||||||
|
bool isDiagnostics);
|
||||||
ReturnValue_t generateSetStructurePacket(sid_t sid, bool isDiagnostics);
|
ReturnValue_t generateSetStructurePacket(sid_t sid, bool isDiagnostics);
|
||||||
|
|
||||||
void handleHkUpdateResetListInsertion(DataType dataType, DataId dataId);
|
void handleHkUpdateResetListInsertion(DataType dataType, DataId dataId);
|
||||||
|
@ -250,8 +250,9 @@ void LocalPoolDataSetBase::setReportingEnabled(bool reportingEnabled) {
|
|||||||
bool LocalPoolDataSetBase::getReportingEnabled() const { return reportingEnabled; }
|
bool LocalPoolDataSetBase::getReportingEnabled() const { return reportingEnabled; }
|
||||||
|
|
||||||
void LocalPoolDataSetBase::initializePeriodicHelper(float collectionInterval,
|
void LocalPoolDataSetBase::initializePeriodicHelper(float collectionInterval,
|
||||||
dur_millis_t minimumPeriodicInterval) {
|
dur_millis_t minimumPeriodicInterval,
|
||||||
periodicHelper->initialize(collectionInterval, minimumPeriodicInterval);
|
uint8_t nonDiagIntervalFactor) {
|
||||||
|
periodicHelper->initialize(collectionInterval, minimumPeriodicInterval, nonDiagIntervalFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LocalPoolDataSetBase::setChanged(bool changed) { this->changed = changed; }
|
void LocalPoolDataSetBase::setChanged(bool changed) { this->changed = changed; }
|
||||||
|
@ -162,7 +162,6 @@ class LocalPoolDataSetBase : public PoolDataSetBase, public MarkChangedIF {
|
|||||||
object_id_t getCreatorObjectId();
|
object_id_t getCreatorObjectId();
|
||||||
|
|
||||||
bool getReportingEnabled() const;
|
bool getReportingEnabled() const;
|
||||||
void setReportingEnabled(bool enabled);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the current periodic HK generation interval this set
|
* Returns the current periodic HK generation interval this set
|
||||||
@ -190,8 +189,10 @@ class LocalPoolDataSetBase : public PoolDataSetBase, public MarkChangedIF {
|
|||||||
* Used for periodic generation.
|
* Used for periodic generation.
|
||||||
*/
|
*/
|
||||||
bool reportingEnabled = false;
|
bool reportingEnabled = false;
|
||||||
|
void setReportingEnabled(bool enabled);
|
||||||
|
|
||||||
void initializePeriodicHelper(float collectionInterval, dur_millis_t minimumPeriodicInterval);
|
void initializePeriodicHelper(float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
||||||
|
uint8_t nonDiagIntervalFactor = 5);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If the valid state of a dataset is always relevant to the whole
|
* If the valid state of a dataset is always relevant to the whole
|
||||||
|
@ -87,8 +87,8 @@ class LocalPoolVariable : public LocalPoolObjectBase {
|
|||||||
|
|
||||||
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
SerializeIF::Endianness streamEndianness) const override;
|
SerializeIF::Endianness streamEndianness) const override;
|
||||||
virtual size_t getSerializedSize() const override;
|
size_t getSerializedSize() const override;
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
SerializeIF::Endianness streamEndianness) override;
|
SerializeIF::Endianness streamEndianness) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,10 +98,10 @@ class LocalPoolVector : public LocalPoolObjectBase {
|
|||||||
T& operator[](size_t i);
|
T& operator[](size_t i);
|
||||||
const T& operator[](size_t i) const;
|
const T& operator[](size_t i) const;
|
||||||
|
|
||||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, const size_t maxSize,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size, const size_t maxSize,
|
||||||
SerializeIF::Endianness streamEndiannes) const override;
|
SerializeIF::Endianness streamEndiannes) const override;
|
||||||
virtual size_t getSerializedSize() const override;
|
size_t getSerializedSize() const override;
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
SerializeIF::Endianness streamEndianness) override;
|
SerializeIF::Endianness streamEndianness) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,8 +12,10 @@ class LocalPoolDataSetAttorney {
|
|||||||
static bool isDiagnostics(LocalPoolDataSetBase& set) { return set.isDiagnostics(); }
|
static bool isDiagnostics(LocalPoolDataSetBase& set) { return set.isDiagnostics(); }
|
||||||
|
|
||||||
static void initializePeriodicHelper(LocalPoolDataSetBase& set, float collectionInterval,
|
static void initializePeriodicHelper(LocalPoolDataSetBase& set, float collectionInterval,
|
||||||
uint32_t minimumPeriodicIntervalMs) {
|
uint32_t minimumPeriodicIntervalMs,
|
||||||
set.initializePeriodicHelper(collectionInterval, minimumPeriodicIntervalMs);
|
uint8_t nonDiagIntervalFactor = 5) {
|
||||||
|
set.initializePeriodicHelper(collectionInterval, minimumPeriodicIntervalMs,
|
||||||
|
nonDiagIntervalFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setReportingEnabled(LocalPoolDataSetBase& set, bool enabled) {
|
static void setReportingEnabled(LocalPoolDataSetBase& set, bool enabled) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include "fsfw/devicehandlers/AssemblyBase.h"
|
#include "fsfw/devicehandlers/AssemblyBase.h"
|
||||||
|
|
||||||
AssemblyBase::AssemblyBase(object_id_t objectId, uint16_t commandQueueDepth)
|
AssemblyBase::AssemblyBase(object_id_t objectId, object_id_t parentId, uint16_t commandQueueDepth)
|
||||||
: SubsystemBase(objectId, MODE_OFF, commandQueueDepth),
|
: SubsystemBase(objectId, parentId, MODE_OFF, commandQueueDepth),
|
||||||
internalState(STATE_NONE),
|
internalState(STATE_NONE),
|
||||||
recoveryState(RECOVERY_IDLE),
|
recoveryState(RECOVERY_IDLE),
|
||||||
recoveringDevice(childrenMap.end()),
|
recoveringDevice(childrenMap.end()),
|
||||||
@ -26,7 +26,11 @@ void AssemblyBase::performChildOperation() {
|
|||||||
|
|
||||||
void AssemblyBase::startTransition(Mode_t mode, Submode_t submode) {
|
void AssemblyBase::startTransition(Mode_t mode, Submode_t submode) {
|
||||||
doStartTransition(mode, submode);
|
doStartTransition(mode, submode);
|
||||||
triggerModeHelperEvents(mode, submode);
|
if (modeHelper.isForced()) {
|
||||||
|
triggerEvent(FORCING_MODE, mode, submode);
|
||||||
|
} else {
|
||||||
|
triggerEvent(CHANGING_MODE, mode, submode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssemblyBase::doStartTransition(Mode_t mode, Submode_t submode) {
|
void AssemblyBase::doStartTransition(Mode_t mode, Submode_t submode) {
|
||||||
@ -73,10 +77,9 @@ bool AssemblyBase::handleChildrenChangedHealth() {
|
|||||||
}
|
}
|
||||||
HealthState healthState = healthHelper.healthTable->getHealth(iter->first);
|
HealthState healthState = healthHelper.healthTable->getHealth(iter->first);
|
||||||
if (healthState == HasHealthIF::NEEDS_RECOVERY) {
|
if (healthState == HasHealthIF::NEEDS_RECOVERY) {
|
||||||
triggerEvent(TRYING_RECOVERY, iter->first, 0);
|
triggerEvent(TRYING_RECOVERY);
|
||||||
recoveryState = RECOVERY_STARTED;
|
recoveryState = RECOVERY_STARTED;
|
||||||
recoveringDevice = iter;
|
recoveringDevice = iter;
|
||||||
// The user needs to take care of commanding the children off in commandChildren
|
|
||||||
doStartTransition(targetMode, targetSubmode);
|
doStartTransition(targetMode, targetSubmode);
|
||||||
} else {
|
} else {
|
||||||
triggerEvent(CHILD_CHANGED_HEALTH);
|
triggerEvent(CHILD_CHANGED_HEALTH);
|
||||||
@ -225,9 +228,6 @@ ReturnValue_t AssemblyBase::handleHealthReply(CommandMessage* message) {
|
|||||||
bool AssemblyBase::checkAndHandleRecovery() {
|
bool AssemblyBase::checkAndHandleRecovery() {
|
||||||
switch (recoveryState) {
|
switch (recoveryState) {
|
||||||
case RECOVERY_STARTED:
|
case RECOVERY_STARTED:
|
||||||
// The recovery was already start in #handleChildrenChangedHealth and we just need
|
|
||||||
// to wait for an off time period.
|
|
||||||
// TODO: make time period configurable
|
|
||||||
recoveryState = RECOVERY_WAIT;
|
recoveryState = RECOVERY_WAIT;
|
||||||
recoveryOffTimer.resetTimer();
|
recoveryOffTimer.resetTimer();
|
||||||
return true;
|
return true;
|
||||||
@ -266,11 +266,3 @@ void AssemblyBase::overwriteDeviceHealth(object_id_t objectId, HasHealthIF::Heal
|
|||||||
modeHelper.setForced(true);
|
modeHelper.setForced(true);
|
||||||
sendHealthCommand(childrenMap[objectId].commandQueue, EXTERNAL_CONTROL);
|
sendHealthCommand(childrenMap[objectId].commandQueue, EXTERNAL_CONTROL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssemblyBase::triggerModeHelperEvents(Mode_t mode, Submode_t submode) {
|
|
||||||
if (modeHelper.isForced()) {
|
|
||||||
triggerEvent(FORCING_MODE, mode, submode);
|
|
||||||
} else {
|
|
||||||
triggerEvent(CHANGING_MODE, mode, submode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -12,8 +12,7 @@
|
|||||||
* Documentation: Dissertation Baetz p.156, 157.
|
* Documentation: Dissertation Baetz p.156, 157.
|
||||||
*
|
*
|
||||||
* This class reduces the complexity of controller components which would
|
* This class reduces the complexity of controller components which would
|
||||||
* otherwise be needed for the handling of redundant devices. However, it can also be used to
|
* otherwise be needed for the handling of redundant devices.
|
||||||
* manage the mode keeping and recovery of non-redundant devices
|
|
||||||
*
|
*
|
||||||
* The template class monitors mode and health state of its children
|
* The template class monitors mode and health state of its children
|
||||||
* and checks availability of devices on every detected change.
|
* and checks availability of devices on every detected change.
|
||||||
@ -27,9 +26,11 @@
|
|||||||
*
|
*
|
||||||
* Important:
|
* Important:
|
||||||
*
|
*
|
||||||
* The implementation must call #registerChild for all commanded children during initialization.
|
* The implementation must call registerChild(object_id_t child)
|
||||||
|
* for all commanded children during initialization.
|
||||||
* The implementation must call the initialization function of the base class.
|
* The implementation must call the initialization function of the base class.
|
||||||
* (This will call the function in SubsystemBase)
|
* (This will call the function in SubsystemBase)
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
class AssemblyBase : public SubsystemBase {
|
class AssemblyBase : public SubsystemBase {
|
||||||
public:
|
public:
|
||||||
@ -41,15 +42,14 @@ class AssemblyBase : public SubsystemBase {
|
|||||||
static const ReturnValue_t NEED_TO_CHANGE_HEALTH = MAKE_RETURN_CODE(0x05);
|
static const ReturnValue_t NEED_TO_CHANGE_HEALTH = MAKE_RETURN_CODE(0x05);
|
||||||
static const ReturnValue_t NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE = MAKE_RETURN_CODE(0xa1);
|
static const ReturnValue_t NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE = MAKE_RETURN_CODE(0xa1);
|
||||||
|
|
||||||
AssemblyBase(object_id_t objectId, uint16_t commandQueueDepth = 8);
|
AssemblyBase(object_id_t objectId, object_id_t parentId, uint16_t commandQueueDepth = 8);
|
||||||
virtual ~AssemblyBase();
|
virtual ~AssemblyBase();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* Command children to reach [mode,submode] combination. Can be done by setting
|
* Command children to reach [mode,submode] combination
|
||||||
* #commandsOutstanding correctly, or using #executeTable. In case of an FDIR recovery,
|
* Can be done by setting #commandsOutstanding correctly,
|
||||||
* the user needs to ensure that the target devices are healthy. If a device is not healthy,
|
* or using executeTable()
|
||||||
* a recovery might be on-going and the device needs to be commanded to off first.
|
|
||||||
* @param mode
|
* @param mode
|
||||||
* @param submode
|
* @param submode
|
||||||
* @return
|
* @return
|
||||||
@ -120,19 +120,8 @@ class AssemblyBase : public SubsystemBase {
|
|||||||
|
|
||||||
virtual ReturnValue_t handleHealthReply(CommandMessage *message);
|
virtual ReturnValue_t handleHealthReply(CommandMessage *message);
|
||||||
|
|
||||||
/**
|
virtual void performChildOperation();
|
||||||
* @brief Default periodic handler
|
|
||||||
* @details
|
|
||||||
* This is the default periodic handler which will be called by the SubsystemBase
|
|
||||||
* performOperation. It performs the child transitions or reacts to changed health/mode states
|
|
||||||
* of children objects
|
|
||||||
*/
|
|
||||||
virtual void performChildOperation() override;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function handles changed mode or health states of children
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
bool handleChildrenChanged();
|
bool handleChildrenChanged();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -145,37 +134,12 @@ class AssemblyBase : public SubsystemBase {
|
|||||||
|
|
||||||
bool handleChildrenChangedHealth();
|
bool handleChildrenChangedHealth();
|
||||||
|
|
||||||
/**
|
|
||||||
* Core transition handler. The default implementation will only do something if
|
|
||||||
* #commandsOutstanding is smaller or equal to zero, which means that all mode commands
|
|
||||||
* from the #doPerformTransition call were executed successfully.
|
|
||||||
*
|
|
||||||
* Unless a second step was requested, the function will then use #checkChildrenState to
|
|
||||||
* determine whether the target mode was reached.
|
|
||||||
*
|
|
||||||
* There is some special handling for certain (internal) modes:
|
|
||||||
* - A second step is necessary. #commandChildren will be performed again
|
|
||||||
* - The device health was overwritten. #commandChildren will be called
|
|
||||||
* - A recovery is ongoing. #checkAndHandleRecovery will be called.
|
|
||||||
*/
|
|
||||||
virtual void handleChildrenTransition();
|
virtual void handleChildrenTransition();
|
||||||
|
|
||||||
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode);
|
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t *msToReachTheMode);
|
||||||
|
|
||||||
/**
|
|
||||||
* Calls #doStartTransition and triggers an informative event as well that the mode will
|
|
||||||
* change
|
|
||||||
* @param mode
|
|
||||||
* @param submode
|
|
||||||
*/
|
|
||||||
virtual void startTransition(Mode_t mode, Submode_t submode);
|
virtual void startTransition(Mode_t mode, Submode_t submode);
|
||||||
|
|
||||||
/**
|
|
||||||
* This function starts the transition by setting the internal #targetSubmode and #targetMode
|
|
||||||
* variables and then calling the #commandChildren function.
|
|
||||||
* @param mode
|
|
||||||
* @param submode
|
|
||||||
*/
|
|
||||||
virtual void doStartTransition(Mode_t mode, Submode_t submode);
|
virtual void doStartTransition(Mode_t mode, Submode_t submode);
|
||||||
|
|
||||||
virtual bool isInTransition();
|
virtual bool isInTransition();
|
||||||
@ -196,7 +160,7 @@ class AssemblyBase : public SubsystemBase {
|
|||||||
* Manages recovery of a device
|
* Manages recovery of a device
|
||||||
* @return true if recovery is still ongoing, false else.
|
* @return true if recovery is still ongoing, false else.
|
||||||
*/
|
*/
|
||||||
virtual bool checkAndHandleRecovery();
|
bool checkAndHandleRecovery();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method to overwrite health state of one of the children.
|
* Helper method to overwrite health state of one of the children.
|
||||||
@ -204,8 +168,6 @@ class AssemblyBase : public SubsystemBase {
|
|||||||
* @param objectId Must be a registered child.
|
* @param objectId Must be a registered child.
|
||||||
*/
|
*/
|
||||||
void overwriteDeviceHealth(object_id_t objectId, HasHealthIF::HealthState oldHealth);
|
void overwriteDeviceHealth(object_id_t objectId, HasHealthIF::HealthState oldHealth);
|
||||||
|
|
||||||
void triggerModeHelperEvents(Mode_t mode, Submode_t submode);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_ */
|
#endif /* FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_ */
|
||||||
|
@ -3,12 +3,17 @@
|
|||||||
#include "fsfw/subsystem/SubsystemBase.h"
|
#include "fsfw/subsystem/SubsystemBase.h"
|
||||||
|
|
||||||
ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication,
|
ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication,
|
||||||
CookieIF* cookie, HasModeTreeChildrenIF& parent,
|
CookieIF* cookie, object_id_t hkDestination,
|
||||||
FailureIsolationBase* customFdir, size_t cmdQueueSize)
|
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId,
|
||||||
|
object_id_t parent, FailureIsolationBase* customFdir,
|
||||||
|
size_t cmdQueueSize)
|
||||||
: DeviceHandlerBase(setObjectId, deviceCommunication, cookie,
|
: DeviceHandlerBase(setObjectId, deviceCommunication, cookie,
|
||||||
(customFdir == nullptr ? &childHandlerFdir : customFdir), cmdQueueSize),
|
(customFdir == nullptr ? &childHandlerFdir : customFdir), cmdQueueSize),
|
||||||
parent(parent),
|
parentId(parent),
|
||||||
childHandlerFdir(setObjectId) {}
|
childHandlerFdir(setObjectId) {
|
||||||
|
this->setHkDestination(hkDestination);
|
||||||
|
this->setThermalStateRequestPoolIds(thermalStatePoolId, thermalRequestPoolId);
|
||||||
|
}
|
||||||
|
|
||||||
ChildHandlerBase::~ChildHandlerBase() {}
|
ChildHandlerBase::~ChildHandlerBase() {}
|
||||||
|
|
||||||
@ -18,5 +23,21 @@ ReturnValue_t ChildHandlerBase::initialize() {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return DeviceHandlerBase::connectModeTreeParent(parent);
|
MessageQueueId_t parentQueue = 0;
|
||||||
|
|
||||||
|
if (parentId != objects::NO_OBJECT) {
|
||||||
|
SubsystemBase* parent = ObjectManager::instance()->get<SubsystemBase>(parentId);
|
||||||
|
if (parent == NULL) {
|
||||||
|
return returnvalue::FAILED;
|
||||||
|
}
|
||||||
|
parentQueue = parent->getCommandQueue();
|
||||||
|
|
||||||
|
parent->registerChild(getObjectId());
|
||||||
|
}
|
||||||
|
|
||||||
|
healthHelper.setParentQueue(parentQueue);
|
||||||
|
|
||||||
|
modeHelper.setParentQueue(parentQueue);
|
||||||
|
|
||||||
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,22 @@
|
|||||||
#ifndef FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
|
#ifndef FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
|
||||||
#define FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
|
#define FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
|
||||||
|
|
||||||
#include <fsfw/subsystem/HasModeTreeChildrenIF.h>
|
|
||||||
|
|
||||||
#include "ChildHandlerFDIR.h"
|
#include "ChildHandlerFDIR.h"
|
||||||
#include "DeviceHandlerBase.h"
|
#include "DeviceHandlerBase.h"
|
||||||
|
|
||||||
class ChildHandlerBase : public DeviceHandlerBase {
|
class ChildHandlerBase : public DeviceHandlerBase {
|
||||||
public:
|
public:
|
||||||
ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, CookieIF* cookie,
|
ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, CookieIF* cookie,
|
||||||
HasModeTreeChildrenIF& parent, FailureIsolationBase* customFdir = nullptr,
|
object_id_t hkDestination, uint32_t thermalStatePoolId,
|
||||||
size_t cmdQueueSize = 20);
|
uint32_t thermalRequestPoolId, object_id_t parent = objects::NO_OBJECT,
|
||||||
|
FailureIsolationBase* customFdir = nullptr, size_t cmdQueueSize = 20);
|
||||||
|
|
||||||
virtual ~ChildHandlerBase();
|
virtual ~ChildHandlerBase();
|
||||||
|
|
||||||
virtual ReturnValue_t initialize();
|
virtual ReturnValue_t initialize();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HasModeTreeChildrenIF& parent;
|
const uint32_t parentId;
|
||||||
ChildHandlerFDIR childHandlerFdir;
|
ChildHandlerFDIR childHandlerFdir;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -49,7 +49,6 @@ class DeviceCommunicationIF {
|
|||||||
// is this needed if there is no open/close call?
|
// is this needed if there is no open/close call?
|
||||||
static const ReturnValue_t NOT_ACTIVE = MAKE_RETURN_CODE(0x05);
|
static const ReturnValue_t NOT_ACTIVE = MAKE_RETURN_CODE(0x05);
|
||||||
static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x06);
|
static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x06);
|
||||||
static constexpr ReturnValue_t BUSY = MAKE_RETURN_CODE(0x07);
|
|
||||||
|
|
||||||
virtual ~DeviceCommunicationIF() {}
|
virtual ~DeviceCommunicationIF() {}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "DeviceHandlerBase.h"
|
#include "fsfw/devicehandlers/DeviceHandlerBase.h"
|
||||||
|
|
||||||
#include "fsfw/datapool/PoolReadGuard.h"
|
#include "fsfw/datapool/PoolReadGuard.h"
|
||||||
#include "fsfw/datapoollocal/LocalPoolVariable.h"
|
#include "fsfw/datapoollocal/LocalPoolVariable.h"
|
||||||
@ -13,7 +13,6 @@
|
|||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||||
#include "fsfw/subsystem/SubsystemBase.h"
|
#include "fsfw/subsystem/SubsystemBase.h"
|
||||||
#include "fsfw/subsystem/helper.h"
|
|
||||||
#include "fsfw/thermal/ThermalComponentIF.h"
|
#include "fsfw/thermal/ThermalComponentIF.h"
|
||||||
|
|
||||||
object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
|
object_id_t DeviceHandlerBase::powerSwitcherId = objects::NO_OBJECT;
|
||||||
@ -24,6 +23,8 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device
|
|||||||
CookieIF* comCookie, FailureIsolationBase* fdirInstance,
|
CookieIF* comCookie, FailureIsolationBase* fdirInstance,
|
||||||
size_t cmdQueueSize)
|
size_t cmdQueueSize)
|
||||||
: SystemObject(setObjectId),
|
: SystemObject(setObjectId),
|
||||||
|
mode(MODE_OFF),
|
||||||
|
submode(SUBMODE_NONE),
|
||||||
wiretappingMode(OFF),
|
wiretappingMode(OFF),
|
||||||
storedRawData(StorageManagerIF::INVALID_ADDRESS),
|
storedRawData(StorageManagerIF::INVALID_ADDRESS),
|
||||||
deviceCommunicationId(deviceCommunication),
|
deviceCommunicationId(deviceCommunication),
|
||||||
@ -38,13 +39,10 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device
|
|||||||
defaultFDIRUsed(fdirInstance == nullptr),
|
defaultFDIRUsed(fdirInstance == nullptr),
|
||||||
switchOffWasReported(false),
|
switchOffWasReported(false),
|
||||||
childTransitionDelay(5000),
|
childTransitionDelay(5000),
|
||||||
mode(MODE_OFF),
|
|
||||||
submode(SUBMODE_NONE),
|
|
||||||
transitionSourceMode(_MODE_POWER_DOWN),
|
transitionSourceMode(_MODE_POWER_DOWN),
|
||||||
transitionSourceSubMode(SUBMODE_NONE) {
|
transitionSourceSubMode(SUBMODE_NONE) {
|
||||||
auto mqArgs = MqArgs(setObjectId, static_cast<void*>(this));
|
|
||||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
commandQueue = QueueFactory::instance()->createMessageQueue(
|
||||||
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
cmdQueueSize, MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||||
insertInCommandMap(RAW_COMMAND_ID);
|
insertInCommandMap(RAW_COMMAND_ID);
|
||||||
cookieInfo.state = COOKIE_UNUSED;
|
cookieInfo.state = COOKIE_UNUSED;
|
||||||
cookieInfo.pendingCommand = deviceCommandMap.end();
|
cookieInfo.pendingCommand = deviceCommandMap.end();
|
||||||
@ -52,13 +50,21 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, object_id_t device
|
|||||||
printWarningOrError(sif::OutputTypes::OUT_ERROR, "DeviceHandlerBase", returnvalue::FAILED,
|
printWarningOrError(sif::OutputTypes::OUT_ERROR, "DeviceHandlerBase", returnvalue::FAILED,
|
||||||
"Invalid cookie");
|
"Invalid cookie");
|
||||||
}
|
}
|
||||||
|
if (this->fdirInstance == nullptr) {
|
||||||
|
this->fdirInstance = new DeviceHandlerFailureIsolation(setObjectId, defaultFdirParentId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) {
|
void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) {
|
||||||
this->hkDestination = hkDestination;
|
this->hkDestination = hkDestination;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::enableThermalModule(ThermalStateCfg cfg) { this->thermalStateCfg = cfg; }
|
void DeviceHandlerBase::setThermalStateRequestPoolIds(lp_id_t thermalStatePoolId,
|
||||||
|
lp_id_t heaterRequestPoolId,
|
||||||
|
uint32_t thermalSetId) {
|
||||||
|
thermalSet =
|
||||||
|
new DeviceHandlerThermalSet(this, thermalSetId, thermalStatePoolId, heaterRequestPoolId);
|
||||||
|
}
|
||||||
|
|
||||||
DeviceHandlerBase::~DeviceHandlerBase() {
|
DeviceHandlerBase::~DeviceHandlerBase() {
|
||||||
if (comCookie != nullptr) {
|
if (comCookie != nullptr) {
|
||||||
@ -124,10 +130,6 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
|||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (this->fdirInstance == nullptr) {
|
|
||||||
this->fdirInstance =
|
|
||||||
new DeviceHandlerFailureIsolation(this->getObjectId(), defaultFdirParentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
communicationInterface =
|
communicationInterface =
|
||||||
ObjectManager::instance()->get<DeviceCommunicationIF>(deviceCommunicationId);
|
ObjectManager::instance()->get<DeviceCommunicationIF>(deviceCommunicationId);
|
||||||
@ -222,11 +224,12 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
|||||||
fillCommandAndReplyMap();
|
fillCommandAndReplyMap();
|
||||||
|
|
||||||
if (thermalSet != nullptr) {
|
if (thermalSet != nullptr) {
|
||||||
PoolReadGuard pg(thermalSet);
|
|
||||||
// Set temperature target state to NON_OP.
|
// Set temperature target state to NON_OP.
|
||||||
if (pg.getReadResult() == returnvalue::OK) {
|
result = thermalSet->read();
|
||||||
|
if (result == returnvalue::OK) {
|
||||||
thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
|
thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
|
||||||
thermalSet->heaterRequest.setValid(true);
|
thermalSet->heaterRequest.setValid(true);
|
||||||
|
thermalSet->commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,6 +353,7 @@ void DeviceHandlerBase::doStateMachine() {
|
|||||||
currentUptime - timeoutStart >= powerSwitcher->getSwitchDelayMs()) {
|
currentUptime - timeoutStart >= powerSwitcher->getSwitchDelayMs()) {
|
||||||
triggerEvent(MODE_TRANSITION_FAILED, PowerSwitchIF::SWITCH_TIMEOUT, 0);
|
triggerEvent(MODE_TRANSITION_FAILED, PowerSwitchIF::SWITCH_TIMEOUT, 0);
|
||||||
setMode(_MODE_POWER_DOWN);
|
setMode(_MODE_POWER_DOWN);
|
||||||
|
callChildStatemachine();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ReturnValue_t switchState = getStateOfSwitches();
|
ReturnValue_t switchState = getStateOfSwitches();
|
||||||
@ -363,12 +367,13 @@ void DeviceHandlerBase::doStateMachine() {
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case _MODE_WAIT_OFF: {
|
case _MODE_WAIT_OFF: {
|
||||||
|
uint32_t currentUptime;
|
||||||
|
Clock::getUptime(¤tUptime);
|
||||||
|
|
||||||
if (powerSwitcher == nullptr) {
|
if (powerSwitcher == nullptr) {
|
||||||
setMode(MODE_OFF);
|
setMode(MODE_OFF);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
uint32_t currentUptime;
|
|
||||||
Clock::getUptime(¤tUptime);
|
|
||||||
if (currentUptime - timeoutStart >= powerSwitcher->getSwitchDelayMs()) {
|
if (currentUptime - timeoutStart >= powerSwitcher->getSwitchDelayMs()) {
|
||||||
triggerEvent(MODE_TRANSITION_FAILED, PowerSwitchIF::SWITCH_TIMEOUT, 0);
|
triggerEvent(MODE_TRANSITION_FAILED, PowerSwitchIF::SWITCH_TIMEOUT, 0);
|
||||||
setMode(MODE_ERROR_ON);
|
setMode(MODE_ERROR_ON);
|
||||||
@ -376,7 +381,7 @@ void DeviceHandlerBase::doStateMachine() {
|
|||||||
}
|
}
|
||||||
ReturnValue_t switchState = getStateOfSwitches();
|
ReturnValue_t switchState = getStateOfSwitches();
|
||||||
if ((switchState == PowerSwitchIF::SWITCH_OFF) || (switchState == NO_SWITCH)) {
|
if ((switchState == PowerSwitchIF::SWITCH_OFF) || (switchState == NO_SWITCH)) {
|
||||||
setMode(MODE_OFF, SUBMODE_NONE);
|
setMode(_MODE_SWITCH_IS_OFF);
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case MODE_OFF:
|
case MODE_OFF:
|
||||||
@ -389,6 +394,9 @@ void DeviceHandlerBase::doStateMachine() {
|
|||||||
case MODE_NORMAL:
|
case MODE_NORMAL:
|
||||||
case MODE_ERROR_ON:
|
case MODE_ERROR_ON:
|
||||||
break;
|
break;
|
||||||
|
case _MODE_SWITCH_IS_OFF:
|
||||||
|
setMode(MODE_OFF, SUBMODE_NONE);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
triggerEvent(OBJECT_IN_INVALID_MODE, mode, submode);
|
triggerEvent(OBJECT_IN_INVALID_MODE, mode, submode);
|
||||||
setMode(_MODE_POWER_DOWN, 0);
|
setMode(_MODE_POWER_DOWN, 0);
|
||||||
@ -560,40 +568,25 @@ void DeviceHandlerBase::setTransition(Mode_t modeTo, Submode_t submodeTo) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
|
void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
|
||||||
/**
|
/* TODO: This will probably be done by the LocalDataPoolManager now */
|
||||||
* handle transition from OFF to NORMAL by continuing towards normal when ON is reached
|
// changeHK(mode, submode, false);
|
||||||
*/
|
|
||||||
if (newMode == MODE_ON and continueToNormal) {
|
|
||||||
continueToNormal = false;
|
|
||||||
// TODO: Check whether the following two lines are okay to do so.
|
|
||||||
transitionSourceMode = MODE_ON;
|
|
||||||
transitionSourceSubMode = newSubmode;
|
|
||||||
mode = _MODE_TO_NORMAL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
submode = newSubmode;
|
submode = newSubmode;
|
||||||
mode = newMode;
|
mode = newMode;
|
||||||
modeChanged();
|
modeChanged();
|
||||||
setNormalDatapoolEntriesInvalid();
|
setNormalDatapoolEntriesInvalid();
|
||||||
if (newMode == MODE_OFF) {
|
|
||||||
disableCommandsAndReplies();
|
|
||||||
}
|
|
||||||
if (!isTransitionalMode()) {
|
if (!isTransitionalMode()) {
|
||||||
// clear this flag when a non-transitional Mode is reached to be safe
|
|
||||||
continueToNormal = false;
|
|
||||||
modeHelper.modeChanged(newMode, newSubmode);
|
modeHelper.modeChanged(newMode, newSubmode);
|
||||||
announceMode(false);
|
announceMode(false);
|
||||||
}
|
}
|
||||||
Clock::getUptime(&timeoutStart);
|
Clock::getUptime(&timeoutStart);
|
||||||
|
|
||||||
if (mode == MODE_OFF and thermalSet != nullptr) {
|
if (mode == MODE_OFF and thermalSet != nullptr) {
|
||||||
PoolReadGuard pg(thermalSet);
|
ReturnValue_t result = thermalSet->read();
|
||||||
if (pg.getReadResult() == returnvalue::OK) {
|
if (result == returnvalue::OK) {
|
||||||
if (thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) {
|
if (thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) {
|
||||||
thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
|
thermalSet->heaterRequest.value = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
|
||||||
}
|
}
|
||||||
thermalSet->heaterRequest.setValid(true);
|
thermalSet->heaterRequest.commit(PoolVariableIF::VALID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TODO: This will probably be done by the LocalDataPoolManager now */
|
/* TODO: This will probably be done by the LocalDataPoolManager now */
|
||||||
@ -1066,7 +1059,8 @@ Mode_t DeviceHandlerBase::getBaseMode(Mode_t transitionMode) {
|
|||||||
return transitionMode & ~(TRANSITION_MODE_BASE_ACTION_MASK | TRANSITION_MODE_CHILD_ACTION_MASK);
|
return transitionMode & ~(TRANSITION_MODE_BASE_ACTION_MASK | TRANSITION_MODE_CHILD_ACTION_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SHOULDDO: throw away DHB and write a new one:
|
// SHOULDDO: Allow transition from OFF to NORMAL to reduce complexity in assemblies. And, by the
|
||||||
|
// way, throw away DHB and write a new one:
|
||||||
// - Include power and thermal completely, but more modular :-)
|
// - Include power and thermal completely, but more modular :-)
|
||||||
// - Don't use modes for state transitions, reduce FSM (Finte State Machine) complexity.
|
// - Don't use modes for state transitions, reduce FSM (Finte State Machine) complexity.
|
||||||
// - Modularization?
|
// - Modularization?
|
||||||
@ -1078,12 +1072,13 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode, Submode_
|
|||||||
if ((mode == MODE_ERROR_ON) && (commandedMode != MODE_OFF)) {
|
if ((mode == MODE_ERROR_ON) && (commandedMode != MODE_OFF)) {
|
||||||
return TRANS_NOT_ALLOWED;
|
return TRANS_NOT_ALLOWED;
|
||||||
}
|
}
|
||||||
|
if ((commandedMode == MODE_NORMAL) && (mode == MODE_OFF)) {
|
||||||
|
return TRANS_NOT_ALLOWED;
|
||||||
|
}
|
||||||
|
|
||||||
// Do not check thermal state for MODE_RAW
|
if ((commandedMode == MODE_ON) && (mode == MODE_OFF) and (thermalSet != nullptr)) {
|
||||||
if ((mode == MODE_OFF) and ((commandedMode == MODE_ON) or (commandedMode == MODE_NORMAL)) and
|
ReturnValue_t result = thermalSet->read();
|
||||||
(thermalSet != nullptr)) {
|
if (result == returnvalue::OK) {
|
||||||
PoolReadGuard pg(thermalSet);
|
|
||||||
if (pg.getReadResult() == returnvalue::OK) {
|
|
||||||
if ((thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) and
|
if ((thermalSet->heaterRequest.value != ThermalComponentIF::STATE_REQUEST_IGNORE) and
|
||||||
(not ThermalComponentIF::isOperational(thermalSet->thermalState.value))) {
|
(not ThermalComponentIF::isOperational(thermalSet->thermalState.value))) {
|
||||||
triggerEvent(ThermalComponentIF::TEMP_NOT_IN_OP_RANGE, thermalSet->thermalState.value);
|
triggerEvent(ThermalComponentIF::TEMP_NOT_IN_OP_RANGE, thermalSet->thermalState.value);
|
||||||
@ -1096,7 +1091,6 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode, Submode_
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::startTransition(Mode_t commandedMode, Submode_t commandedSubmode) {
|
void DeviceHandlerBase::startTransition(Mode_t commandedMode, Submode_t commandedSubmode) {
|
||||||
continueToNormal = false;
|
|
||||||
switch (commandedMode) {
|
switch (commandedMode) {
|
||||||
case MODE_ON:
|
case MODE_ON:
|
||||||
handleTransitionToOnMode(commandedMode, commandedSubmode);
|
handleTransitionToOnMode(commandedMode, commandedSubmode);
|
||||||
@ -1126,9 +1120,8 @@ void DeviceHandlerBase::startTransition(Mode_t commandedMode, Submode_t commande
|
|||||||
case MODE_NORMAL:
|
case MODE_NORMAL:
|
||||||
if (mode != MODE_OFF) {
|
if (mode != MODE_OFF) {
|
||||||
setTransition(MODE_NORMAL, commandedSubmode);
|
setTransition(MODE_NORMAL, commandedSubmode);
|
||||||
} else { // mode is off
|
} else {
|
||||||
continueToNormal = true;
|
replyReturnvalueToCommand(HasModesIF::TRANS_NOT_ALLOWED);
|
||||||
handleTransitionToOnMode(MODE_NORMAL, commandedSubmode);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1144,10 +1137,11 @@ void DeviceHandlerBase::handleTransitionToOnMode(Mode_t commandedMode, Submode_t
|
|||||||
childTransitionDelay = getTransitionDelayMs(_MODE_START_UP, MODE_ON);
|
childTransitionDelay = getTransitionDelayMs(_MODE_START_UP, MODE_ON);
|
||||||
triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode);
|
triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode);
|
||||||
if (thermalSet != nullptr) {
|
if (thermalSet != nullptr) {
|
||||||
PoolReadGuard pg(thermalSet);
|
ReturnValue_t result = thermalSet->read();
|
||||||
if (pg.getReadResult() == returnvalue::OK) {
|
if (result == returnvalue::OK) {
|
||||||
if (thermalSet->heaterRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) {
|
if (thermalSet->heaterRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) {
|
||||||
thermalSet->heaterRequest = ThermalComponentIF::STATE_REQUEST_OPERATIONAL;
|
thermalSet->heaterRequest = ThermalComponentIF::STATE_REQUEST_OPERATIONAL;
|
||||||
|
thermalSet->commit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1285,7 +1279,6 @@ void DeviceHandlerBase::handleDeviceTm(const SerializeIF& dataSet, DeviceCommand
|
|||||||
if (iter->second.command != deviceCommandMap.end()) {
|
if (iter->second.command != deviceCommandMap.end()) {
|
||||||
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
|
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
|
||||||
|
|
||||||
// This may fail, but we'll ignore the fault.
|
|
||||||
if (queueId != NO_COMMANDER) {
|
if (queueId != NO_COMMANDER) {
|
||||||
// This may fail, but we'll ignore the fault.
|
// This may fail, but we'll ignore the fault.
|
||||||
actionHelper.reportData(queueId, replyId, const_cast<SerializeIF*>(&dataSet));
|
actionHelper.reportData(queueId, replyId, const_cast<SerializeIF*>(&dataSet));
|
||||||
@ -1464,17 +1457,15 @@ void DeviceHandlerBase::setTaskIF(PeriodicTaskIF* task) { executingTask = task;
|
|||||||
void DeviceHandlerBase::debugInterface(uint8_t positionTracker, object_id_t objectId,
|
void DeviceHandlerBase::debugInterface(uint8_t positionTracker, object_id_t objectId,
|
||||||
uint32_t parameter) {}
|
uint32_t parameter) {}
|
||||||
|
|
||||||
Submode_t DeviceHandlerBase::getInitialSubmode() { return SUBMODE_NONE; }
|
|
||||||
|
|
||||||
void DeviceHandlerBase::performOperationHook() {}
|
void DeviceHandlerBase::performOperationHook() {}
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||||
LocalDataPoolManager& poolManager) {
|
LocalDataPoolManager& poolManager) {
|
||||||
if (thermalStateCfg.has_value()) {
|
if (thermalSet != nullptr) {
|
||||||
localDataPoolMap.emplace(thermalStateCfg.value().thermalStatePoolId,
|
localDataPoolMap.emplace(thermalSet->thermalStatePoolId,
|
||||||
new PoolEntry<DeviceHandlerIF::dh_thermal_state_t>());
|
new PoolEntry<DeviceHandlerIF::dh_thermal_state_t>);
|
||||||
localDataPoolMap.emplace(thermalStateCfg.value().thermalRequestPoolId,
|
localDataPoolMap.emplace(thermalSet->heaterRequestPoolId,
|
||||||
new PoolEntry<DeviceHandlerIF::dh_heater_request_t>());
|
new PoolEntry<DeviceHandlerIF::dh_heater_request_t>);
|
||||||
}
|
}
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
@ -1487,12 +1478,8 @@ ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() {
|
|||||||
}
|
}
|
||||||
this->poolManager.initializeAfterTaskCreation();
|
this->poolManager.initializeAfterTaskCreation();
|
||||||
|
|
||||||
if (thermalStateCfg.has_value()) {
|
|
||||||
ThermalStateCfg& cfg = thermalStateCfg.value();
|
|
||||||
thermalSet = new DeviceHandlerThermalSet(this, cfg);
|
|
||||||
}
|
|
||||||
if (setStartupImmediately) {
|
if (setStartupImmediately) {
|
||||||
startTransition(MODE_ON, getInitialSubmode());
|
startTransition(MODE_ON, SUBMODE_NONE);
|
||||||
}
|
}
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
@ -1579,52 +1566,3 @@ MessageQueueId_t DeviceHandlerBase::getCommanderQueueId(DeviceCommandId_t replyI
|
|||||||
}
|
}
|
||||||
return commandIter->second.sendReplyTo;
|
return commandIter->second.sendReplyTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::setCustomFdir(FailureIsolationBase* fdir) { this->fdirInstance = fdir; }
|
|
||||||
|
|
||||||
void DeviceHandlerBase::setPowerSwitcher(PowerSwitchIF* switcher) {
|
|
||||||
this->powerSwitcher = switcher;
|
|
||||||
}
|
|
||||||
|
|
||||||
Mode_t DeviceHandlerBase::getMode() { return mode; }
|
|
||||||
|
|
||||||
Submode_t DeviceHandlerBase::getSubmode() { return submode; }
|
|
||||||
|
|
||||||
void DeviceHandlerBase::disableCommandsAndReplies() {
|
|
||||||
for (auto& command : deviceCommandMap) {
|
|
||||||
if (command.second.isExecuting) {
|
|
||||||
command.second.isExecuting = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (auto& reply : deviceReplyMap) {
|
|
||||||
if (!reply.second.periodic) {
|
|
||||||
if (reply.second.countdown != nullptr) {
|
|
||||||
reply.second.countdown->timeOut();
|
|
||||||
} else {
|
|
||||||
reply.second.delayCycles = 0;
|
|
||||||
}
|
|
||||||
reply.second.active = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::connectModeTreeParent(HasModeTreeChildrenIF& parent) {
|
|
||||||
return modetree::connectModeTreeParent(parent, *this, &healthHelper, modeHelper);
|
|
||||||
}
|
|
||||||
|
|
||||||
const HasHealthIF* DeviceHandlerBase::getOptHealthIF() const { return this; }
|
|
||||||
|
|
||||||
const HasModesIF& DeviceHandlerBase::getModeIF() const { return *this; }
|
|
||||||
|
|
||||||
ModeTreeChildIF& DeviceHandlerBase::getModeTreeChildIF() { return *this; }
|
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::finishAction(bool success, DeviceCommandId_t action,
|
|
||||||
ReturnValue_t result) {
|
|
||||||
auto commandIter = deviceCommandMap.find(action);
|
|
||||||
if (commandIter == deviceCommandMap.end()) {
|
|
||||||
return MessageQueueIF::NO_QUEUE;
|
|
||||||
}
|
|
||||||
commandIter->second.isExecuting = false;
|
|
||||||
actionHelper.finish(success, commandIter->second.sendReplyTo, action, result);
|
|
||||||
return returnvalue::OK;
|
|
||||||
}
|
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_
|
#define FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
|
||||||
|
|
||||||
#include "DeviceCommunicationIF.h"
|
#include "DeviceCommunicationIF.h"
|
||||||
#include "DeviceHandlerFailureIsolation.h"
|
#include "DeviceHandlerFailureIsolation.h"
|
||||||
@ -22,7 +21,6 @@
|
|||||||
#include "fsfw/returnvalues/returnvalue.h"
|
#include "fsfw/returnvalues/returnvalue.h"
|
||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
|
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
|
||||||
#include "fsfw/subsystem/ModeTreeConnectionIF.h"
|
|
||||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||||
#include "fsfw/tasks/PeriodicTaskIF.h"
|
#include "fsfw/tasks/PeriodicTaskIF.h"
|
||||||
|
|
||||||
@ -85,8 +83,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
public HasModesIF,
|
public HasModesIF,
|
||||||
public HasHealthIF,
|
public HasHealthIF,
|
||||||
public HasActionsIF,
|
public HasActionsIF,
|
||||||
public ModeTreeChildIF,
|
|
||||||
public ModeTreeConnectionIF,
|
|
||||||
public ReceivesParameterMessagesIF,
|
public ReceivesParameterMessagesIF,
|
||||||
public HasLocalDataPoolIF {
|
public HasLocalDataPoolIF {
|
||||||
friend void(Factory::setStaticFrameworkObjectIds)();
|
friend void(Factory::setStaticFrameworkObjectIds)();
|
||||||
@ -106,51 +102,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
DeviceHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, CookieIF *comCookie,
|
DeviceHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, CookieIF *comCookie,
|
||||||
FailureIsolationBase *fdirInstance = nullptr, size_t cmdQueueSize = 20);
|
FailureIsolationBase *fdirInstance = nullptr, size_t cmdQueueSize = 20);
|
||||||
|
|
||||||
void setCustomFdir(FailureIsolationBase *fdir);
|
|
||||||
void setPowerSwitcher(PowerSwitchIF *switcher);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* extending the modes of DeviceHandler IF for internal state machine
|
|
||||||
*/
|
|
||||||
static constexpr uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20;
|
|
||||||
static constexpr uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10;
|
|
||||||
//! This is a transitional state which can not be commanded. The device
|
|
||||||
//! handler performs all commands to get the device in a state ready to
|
|
||||||
//! perform commands. When this is completed, the mode changes to @c MODE_ON.
|
|
||||||
static const Mode_t _MODE_START_UP = TRANSITION_MODE_CHILD_ACTION_MASK | 5;
|
|
||||||
//! This is a transitional state which can not be commanded.
|
|
||||||
//! The device handler performs all actions and commands to get the device
|
|
||||||
//! shut down. When the device is off, the mode changes to @c MODE_OFF.
|
|
||||||
//! It is possible to set the mode to _MODE_SHUT_DOWN to use the to off
|
|
||||||
//! transition if available.
|
|
||||||
static const Mode_t _MODE_SHUT_DOWN = TRANSITION_MODE_CHILD_ACTION_MASK | 6;
|
|
||||||
//! It is possible to set the mode to _MODE_TO_ON to use the to on
|
|
||||||
//! transition if available.
|
|
||||||
static const Mode_t _MODE_TO_ON = TRANSITION_MODE_CHILD_ACTION_MASK | HasModesIF::MODE_ON;
|
|
||||||
//! It is possible to set the mode to _MODE_TO_RAW to use the to raw
|
|
||||||
//! transition if available.
|
|
||||||
static const Mode_t _MODE_TO_RAW = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_RAW;
|
|
||||||
//! It is possible to set the mode to _MODE_TO_NORMAL to use the to normal
|
|
||||||
//! transition if available.
|
|
||||||
static const Mode_t _MODE_TO_NORMAL = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_NORMAL;
|
|
||||||
//! This is a transitional state which can not be commanded.
|
|
||||||
//! The device is shut down and ready to be switched off.
|
|
||||||
//! After the command to set the switch off has been sent,
|
|
||||||
//! the mode changes to @c _MODE_WAIT_OFF
|
|
||||||
static const Mode_t _MODE_POWER_DOWN = TRANSITION_MODE_BASE_ACTION_MASK | 1;
|
|
||||||
//! This is a transitional state which can not be commanded. The device
|
|
||||||
//! will be switched on in this state. After the command to set the switch
|
|
||||||
//! on has been sent, the mode changes to @c _MODE_WAIT_ON.
|
|
||||||
static const Mode_t _MODE_POWER_ON = TRANSITION_MODE_BASE_ACTION_MASK | 2;
|
|
||||||
//! This is a transitional state which can not be commanded. The switch has
|
|
||||||
//! been commanded off and the handler waits for it to be off.
|
|
||||||
//! When the switch is off, the mode changes to @c MODE_OFF.
|
|
||||||
static const Mode_t _MODE_WAIT_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 3;
|
|
||||||
//! This is a transitional state which can not be commanded. The switch
|
|
||||||
//! has been commanded on and the handler waits for it to be on.
|
|
||||||
//! When the switch is on, the mode changes to @c _MODE_TO_ON.
|
|
||||||
static const Mode_t _MODE_WAIT_ON = TRANSITION_MODE_BASE_ACTION_MASK | 4;
|
|
||||||
|
|
||||||
void setHkDestination(object_id_t hkDestination);
|
void setHkDestination(object_id_t hkDestination);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -159,12 +110,13 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
* The device handler will then take care of creating local pool entries
|
* The device handler will then take care of creating local pool entries
|
||||||
* for the device thermal state and device heating request.
|
* for the device thermal state and device heating request.
|
||||||
* Custom local pool IDs can be assigned as well.
|
* Custom local pool IDs can be assigned as well.
|
||||||
|
* @param thermalStatePoolId
|
||||||
|
* @param thermalRequestPoolId
|
||||||
*/
|
*/
|
||||||
void enableThermalModule(ThermalStateCfg cfg);
|
void setThermalStateRequestPoolIds(
|
||||||
|
lp_id_t thermalStatePoolId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID,
|
||||||
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
|
lp_id_t thermalRequestPoolId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID,
|
||||||
ModeTreeChildIF &getModeTreeChildIF() override;
|
uint32_t thermalSetId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Helper function to ease device handler development.
|
* @brief Helper function to ease device handler development.
|
||||||
* This will instruct the transition to MODE_ON immediately
|
* This will instruct the transition to MODE_ON immediately
|
||||||
@ -210,7 +162,7 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
* @param counter Specifies which Action to perform
|
* @param counter Specifies which Action to perform
|
||||||
* @return returnvalue::OK for successful execution
|
* @return returnvalue::OK for successful execution
|
||||||
*/
|
*/
|
||||||
ReturnValue_t performOperation(uint8_t counter) override;
|
virtual ReturnValue_t performOperation(uint8_t counter) override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initializes the device handler
|
* @brief Initializes the device handler
|
||||||
@ -220,14 +172,14 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
* Calls fillCommandAndReplyMap().
|
* Calls fillCommandAndReplyMap().
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ReturnValue_t initialize() override;
|
virtual ReturnValue_t initialize() override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Intialization steps performed after all tasks have been created.
|
* @brief Intialization steps performed after all tasks have been created.
|
||||||
* This function will be called by the executing task.
|
* This function will be called by the executing task.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
ReturnValue_t initializeAfterTaskCreation() override;
|
virtual ReturnValue_t initializeAfterTaskCreation() override;
|
||||||
|
|
||||||
/** Destructor. */
|
/** Destructor. */
|
||||||
virtual ~DeviceHandlerBase();
|
virtual ~DeviceHandlerBase();
|
||||||
@ -244,8 +196,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
virtual object_id_t getObjectId() const override;
|
virtual object_id_t getObjectId() const override;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a helper method for classes which are parent nodes in the mode tree.
|
|
||||||
* It registers the passed queue as the destination for mode and health messages.
|
|
||||||
* @param parentQueueId
|
* @param parentQueueId
|
||||||
*/
|
*/
|
||||||
virtual void setParentQueue(MessageQueueId_t parentQueueId);
|
virtual void setParentQueue(MessageQueueId_t parentQueueId);
|
||||||
@ -257,8 +207,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
Mode_t getTransitionSourceMode() const;
|
Mode_t getTransitionSourceMode() const;
|
||||||
Submode_t getTransitionSourceSubMode() const;
|
Submode_t getTransitionSourceSubMode() const;
|
||||||
virtual void getMode(Mode_t *mode, Submode_t *submode);
|
virtual void getMode(Mode_t *mode, Submode_t *submode);
|
||||||
virtual HealthState getHealth() override;
|
HealthState getHealth();
|
||||||
virtual ReturnValue_t setHealth(HealthState health) override;
|
ReturnValue_t setHealth(HealthState health);
|
||||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueId,
|
||||||
ParameterWrapper *parameterWrapper,
|
ParameterWrapper *parameterWrapper,
|
||||||
const ParameterWrapper *newValues,
|
const ParameterWrapper *newValues,
|
||||||
@ -445,8 +395,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
*/
|
*/
|
||||||
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) = 0;
|
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) = 0;
|
||||||
MessageQueueId_t getCommanderQueueId(DeviceCommandId_t replyId) const;
|
MessageQueueId_t getCommanderQueueId(DeviceCommandId_t replyId) const;
|
||||||
ReturnValue_t finishAction(bool success, DeviceCommandId_t action, ReturnValue_t result);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to get pending command. This is useful for devices
|
* Helper function to get pending command. This is useful for devices
|
||||||
* like SPI sensors to identify the last sent command.
|
* like SPI sensors to identify the last sent command.
|
||||||
@ -707,12 +655,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
virtual void debugInterface(uint8_t positionTracker = 0, object_id_t objectId = 0,
|
virtual void debugInterface(uint8_t positionTracker = 0, object_id_t objectId = 0,
|
||||||
uint32_t parameter = 0);
|
uint32_t parameter = 0);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Can be overwritten by a child to specify the initial submode when device has been set
|
|
||||||
* to startup immediately.
|
|
||||||
*/
|
|
||||||
virtual Submode_t getInitialSubmode();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE;
|
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE;
|
||||||
|
|
||||||
@ -742,18 +684,15 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
size_t rawPacketLen = 0;
|
size_t rawPacketLen = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current mode
|
* The mode the device handler is currently in.
|
||||||
*
|
* This should never be changed directly but only with setMode()
|
||||||
* set via setMode()
|
|
||||||
*/
|
*/
|
||||||
Mode_t getMode();
|
Mode_t mode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current Submode
|
* The submode the device handler is currently in.
|
||||||
*
|
* This should never be changed directly but only with setMode()
|
||||||
* set via setMode()
|
|
||||||
*/
|
*/
|
||||||
Submode_t getSubmode();
|
Submode_t submode;
|
||||||
|
|
||||||
/** This is the counter value from performOperation(). */
|
/** This is the counter value from performOperation(). */
|
||||||
uint8_t pstStep = 0;
|
uint8_t pstStep = 0;
|
||||||
@ -834,18 +773,11 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
* This is used to keep track of pending replies.
|
* This is used to keep track of pending replies.
|
||||||
*/
|
*/
|
||||||
struct DeviceReplyInfo {
|
struct DeviceReplyInfo {
|
||||||
//! For Command-Reply combinations:
|
|
||||||
//! The maximum number of cycles the handler should wait for a reply
|
//! The maximum number of cycles the handler should wait for a reply
|
||||||
//! to this command.
|
//! to this command.
|
||||||
//!
|
|
||||||
//! Reply Only:
|
|
||||||
//! For periodic replies, this variable will be the number of delay cycles between the replies.
|
|
||||||
//! For the non-periodic variant, this variable is not used as there is no meaningful
|
|
||||||
//! definition for delay
|
|
||||||
uint16_t maxDelayCycles;
|
uint16_t maxDelayCycles;
|
||||||
//! This variable will be set to #maxDelayCycles if a reply is expected.
|
//! The currently remaining cycles the handler should wait for a reply,
|
||||||
//! For non-periodic replies without a command, this variable is unused.
|
//! 0 means there is no reply expected
|
||||||
//! A runtime value of 0 means there is no reply is currently expected.
|
|
||||||
uint16_t delayCycles;
|
uint16_t delayCycles;
|
||||||
size_t replyLen = 0; //!< Expected size of the reply.
|
size_t replyLen = 0; //!< Expected size of the reply.
|
||||||
//! if this is !=0, the delayCycles will not be reset to 0 but to
|
//! if this is !=0, the delayCycles will not be reset to 0 but to
|
||||||
@ -901,7 +833,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
/** Pointer to the used FDIR instance. If not provided by child,
|
/** Pointer to the used FDIR instance. If not provided by child,
|
||||||
* default class is instantiated. */
|
* default class is instantiated. */
|
||||||
FailureIsolationBase *fdirInstance;
|
FailureIsolationBase *fdirInstance;
|
||||||
object_id_t parent = objects::NO_OBJECT;
|
|
||||||
|
|
||||||
//! To correctly delete the default instance.
|
//! To correctly delete the default instance.
|
||||||
bool defaultFDIRUsed;
|
bool defaultFDIRUsed;
|
||||||
@ -922,8 +853,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
//! Object which may be the root cause of an identified fault.
|
//! Object which may be the root cause of an identified fault.
|
||||||
static object_id_t defaultFdirParentId;
|
static object_id_t defaultFdirParentId;
|
||||||
|
|
||||||
std::optional<ThermalStateCfg> thermalStateCfg;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Send a reply to a received device handler command.
|
* @brief Send a reply to a received device handler command.
|
||||||
*
|
*
|
||||||
@ -944,8 +873,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
* Do the transition to the main modes (MODE_ON, MODE_NORMAL and MODE_RAW).
|
* Do the transition to the main modes (MODE_ON, MODE_NORMAL and MODE_RAW).
|
||||||
*
|
*
|
||||||
* If the transition is complete, the mode should be set to the target mode,
|
* If the transition is complete, the mode should be set to the target mode,
|
||||||
* which can be deduced from the current mode (which is
|
* which can be deduced from the current mode which is
|
||||||
* [_MODE_TO_ON, _MODE_TO_NORMAL, _MODE_TO_RAW]) using getBaseMode()
|
* [_MODE_TO_ON, _MODE_TO_NORMAL, _MODE_TO_RAW]
|
||||||
*
|
*
|
||||||
* The intended target submode is already set.
|
* The intended target submode is already set.
|
||||||
* The origin submode can be read in subModeFrom.
|
* The origin submode can be read in subModeFrom.
|
||||||
@ -1012,9 +941,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
*/
|
*/
|
||||||
LocalDataPoolManager *getHkManagerHandle() override;
|
LocalDataPoolManager *getHkManagerHandle() override;
|
||||||
|
|
||||||
const HasHealthIF *getOptHealthIF() const override;
|
|
||||||
const HasModesIF &getModeIF() const override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the delay cycle count of a reply.
|
* Returns the delay cycle count of a reply.
|
||||||
* A count != 0 indicates that the command is already executed.
|
* A count != 0 indicates that the command is already executed.
|
||||||
@ -1194,22 +1120,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
*/
|
*/
|
||||||
virtual ReturnValue_t doSendReadHook();
|
virtual ReturnValue_t doSendReadHook();
|
||||||
|
|
||||||
/**
|
|
||||||
* Send a RMAP getRead command.
|
|
||||||
*
|
|
||||||
* The size of the getRead command is #maxDeviceReplyLen.
|
|
||||||
* This is always executed, independently from the current mode.
|
|
||||||
*/
|
|
||||||
virtual void doSendRead(void);
|
|
||||||
/**
|
|
||||||
* Check the getRead reply and the contained data.
|
|
||||||
*
|
|
||||||
* If data was received scanForReply() and, if successful, handleReply()
|
|
||||||
* are called. If the current mode is @c MODE_RAW, the received packet
|
|
||||||
* is sent to the commanding object via commandQueue.
|
|
||||||
*/
|
|
||||||
virtual void doGetRead();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* State a cookie is in.
|
* State a cookie is in.
|
||||||
@ -1260,18 +1170,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
*/
|
*/
|
||||||
uint32_t childTransitionDelay;
|
uint32_t childTransitionDelay;
|
||||||
|
|
||||||
/**
|
|
||||||
* The mode the device handler is currently in.
|
|
||||||
* This should not be changed directly but only with setMode()
|
|
||||||
*/
|
|
||||||
Mode_t mode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The submode the device handler is currently in.
|
|
||||||
* This should not be changed directly but only with setMode()
|
|
||||||
*/
|
|
||||||
Submode_t submode;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The mode the current transition originated from
|
* @brief The mode the current transition originated from
|
||||||
*
|
*
|
||||||
@ -1289,15 +1187,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
*/
|
*/
|
||||||
Submode_t transitionSourceSubMode;
|
Submode_t transitionSourceSubMode;
|
||||||
|
|
||||||
/**
|
|
||||||
* used to make the state machine continue from ON to NOMAL when
|
|
||||||
* a Device is commanded to NORMAL in OFF mode
|
|
||||||
*
|
|
||||||
* set in startTransition()
|
|
||||||
* evaluated in setMode() to continue to NORMAL when ON is reached
|
|
||||||
*/
|
|
||||||
bool continueToNormal;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read the command queue
|
* read the command queue
|
||||||
*/
|
*/
|
||||||
@ -1366,6 +1255,21 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
* - if the action was successful, the reply timout counter is initialized
|
* - if the action was successful, the reply timout counter is initialized
|
||||||
*/
|
*/
|
||||||
void doGetWrite(void);
|
void doGetWrite(void);
|
||||||
|
/**
|
||||||
|
* Send a RMAP getRead command.
|
||||||
|
*
|
||||||
|
* The size of the getRead command is #maxDeviceReplyLen.
|
||||||
|
* This is always executed, independently from the current mode.
|
||||||
|
*/
|
||||||
|
void doSendRead(void);
|
||||||
|
/**
|
||||||
|
* Check the getRead reply and the contained data.
|
||||||
|
*
|
||||||
|
* If data was received scanForReply() and, if successful, handleReply()
|
||||||
|
* are called. If the current mode is @c MODE_RAW, the received packet
|
||||||
|
* is sent to the commanding object via commandQueue.
|
||||||
|
*/
|
||||||
|
void doGetRead(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Resets replies which use a timeout to detect missed replies.
|
* @brief Resets replies which use a timeout to detect missed replies.
|
||||||
@ -1419,11 +1323,6 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
|||||||
void printWarningOrError(sif::OutputTypes errorType, const char *functionName,
|
void printWarningOrError(sif::OutputTypes errorType, const char *functionName,
|
||||||
ReturnValue_t errorCode = returnvalue::FAILED,
|
ReturnValue_t errorCode = returnvalue::FAILED,
|
||||||
const char *errorPrint = nullptr);
|
const char *errorPrint = nullptr);
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disables all commands and replies when device is set to MODE_OFF
|
|
||||||
*/
|
|
||||||
void disableCommandsAndReplies();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */
|
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */
|
||||||
|
@ -10,9 +10,8 @@
|
|||||||
|
|
||||||
object_id_t DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
|
object_id_t DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
|
||||||
|
|
||||||
DeviceHandlerFailureIsolation::DeviceHandlerFailureIsolation(object_id_t owner, object_id_t parent,
|
DeviceHandlerFailureIsolation::DeviceHandlerFailureIsolation(object_id_t owner, object_id_t parent)
|
||||||
uint8_t eventQueueDepth)
|
: FailureIsolationBase(owner, parent),
|
||||||
: FailureIsolationBase(owner, parent, eventQueueDepth),
|
|
||||||
strangeReplyCount(DEFAULT_MAX_STRANGE_REPLIES, DEFAULT_STRANGE_REPLIES_TIME_MS,
|
strangeReplyCount(DEFAULT_MAX_STRANGE_REPLIES, DEFAULT_STRANGE_REPLIES_TIME_MS,
|
||||||
parameterDomainBase++),
|
parameterDomainBase++),
|
||||||
missedReplyCount(DEFAULT_MAX_MISSED_REPLY_COUNT, DEFAULT_MISSED_REPLY_TIME_MS,
|
missedReplyCount(DEFAULT_MAX_MISSED_REPLY_COUNT, DEFAULT_MISSED_REPLY_TIME_MS,
|
||||||
@ -30,7 +29,6 @@ ReturnValue_t DeviceHandlerFailureIsolation::eventReceived(EventMessage* event)
|
|||||||
switch (event->getEvent()) {
|
switch (event->getEvent()) {
|
||||||
case HasModesIF::MODE_TRANSITION_FAILED:
|
case HasModesIF::MODE_TRANSITION_FAILED:
|
||||||
case HasModesIF::OBJECT_IN_INVALID_MODE:
|
case HasModesIF::OBJECT_IN_INVALID_MODE:
|
||||||
case DeviceHandlerIF::DEVICE_WANTS_HARD_REBOOT:
|
|
||||||
// We'll try a recovery as long as defined in MAX_REBOOT.
|
// We'll try a recovery as long as defined in MAX_REBOOT.
|
||||||
// Might cause some AssemblyBase cycles, so keep number low.
|
// Might cause some AssemblyBase cycles, so keep number low.
|
||||||
handleRecovery(event->getEvent());
|
handleRecovery(event->getEvent());
|
||||||
|
@ -13,8 +13,7 @@ class DeviceHandlerFailureIsolation : public FailureIsolationBase {
|
|||||||
friend class Heater;
|
friend class Heater;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DeviceHandlerFailureIsolation(object_id_t owner, object_id_t parent,
|
DeviceHandlerFailureIsolation(object_id_t owner, object_id_t parent);
|
||||||
uint8_t eventQueueDepth = 10);
|
|
||||||
~DeviceHandlerFailureIsolation();
|
~DeviceHandlerFailureIsolation();
|
||||||
ReturnValue_t initialize();
|
ReturnValue_t initialize();
|
||||||
void triggerEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0);
|
void triggerEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0);
|
||||||
|
@ -24,6 +24,9 @@ class DeviceHandlerIF {
|
|||||||
static const DeviceCommandId_t RAW_COMMAND_ID = -1;
|
static const DeviceCommandId_t RAW_COMMAND_ID = -1;
|
||||||
static const DeviceCommandId_t NO_COMMAND_ID = -2;
|
static const DeviceCommandId_t NO_COMMAND_ID = -2;
|
||||||
|
|
||||||
|
static constexpr uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20;
|
||||||
|
static constexpr uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10;
|
||||||
|
|
||||||
using dh_heater_request_t = uint8_t;
|
using dh_heater_request_t = uint8_t;
|
||||||
using dh_thermal_state_t = int8_t;
|
using dh_thermal_state_t = int8_t;
|
||||||
|
|
||||||
@ -51,6 +54,47 @@ class DeviceHandlerIF {
|
|||||||
//! device still is powered. In this mode, only a mode change to @c MODE_OFF
|
//! device still is powered. In this mode, only a mode change to @c MODE_OFF
|
||||||
//! can be commanded, which tries to switch off the device again.
|
//! can be commanded, which tries to switch off the device again.
|
||||||
static const Mode_t MODE_ERROR_ON = 4;
|
static const Mode_t MODE_ERROR_ON = 4;
|
||||||
|
//! This is a transitional state which can not be commanded. The device
|
||||||
|
//! handler performs all commands to get the device in a state ready to
|
||||||
|
//! perform commands. When this is completed, the mode changes to @c MODE_ON.
|
||||||
|
static const Mode_t _MODE_START_UP = TRANSITION_MODE_CHILD_ACTION_MASK | 5;
|
||||||
|
//! This is a transitional state which can not be commanded.
|
||||||
|
//! The device handler performs all actions and commands to get the device
|
||||||
|
//! shut down. When the device is off, the mode changes to @c MODE_OFF.
|
||||||
|
//! It is possible to set the mode to _MODE_SHUT_DOWN to use the to off
|
||||||
|
//! transition if available.
|
||||||
|
static const Mode_t _MODE_SHUT_DOWN = TRANSITION_MODE_CHILD_ACTION_MASK | 6;
|
||||||
|
//! It is possible to set the mode to _MODE_TO_ON to use the to on
|
||||||
|
//! transition if available.
|
||||||
|
static const Mode_t _MODE_TO_ON = TRANSITION_MODE_CHILD_ACTION_MASK | HasModesIF::MODE_ON;
|
||||||
|
//! It is possible to set the mode to _MODE_TO_RAW to use the to raw
|
||||||
|
//! transition if available.
|
||||||
|
static const Mode_t _MODE_TO_RAW = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_RAW;
|
||||||
|
//! It is possible to set the mode to _MODE_TO_NORMAL to use the to normal
|
||||||
|
//! transition if available.
|
||||||
|
static const Mode_t _MODE_TO_NORMAL = TRANSITION_MODE_CHILD_ACTION_MASK | MODE_NORMAL;
|
||||||
|
//! This is a transitional state which can not be commanded.
|
||||||
|
//! The device is shut down and ready to be switched off.
|
||||||
|
//! After the command to set the switch off has been sent,
|
||||||
|
//! the mode changes to @c MODE_WAIT_OFF
|
||||||
|
static const Mode_t _MODE_POWER_DOWN = TRANSITION_MODE_BASE_ACTION_MASK | 1;
|
||||||
|
//! This is a transitional state which can not be commanded. The device
|
||||||
|
//! will be switched on in this state. After the command to set the switch
|
||||||
|
//! on has been sent, the mode changes to @c MODE_WAIT_ON.
|
||||||
|
static const Mode_t _MODE_POWER_ON = TRANSITION_MODE_BASE_ACTION_MASK | 2;
|
||||||
|
//! This is a transitional state which can not be commanded. The switch has
|
||||||
|
//! been commanded off and the handler waits for it to be off.
|
||||||
|
//! When the switch is off, the mode changes to @c MODE_OFF.
|
||||||
|
static const Mode_t _MODE_WAIT_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 3;
|
||||||
|
//! This is a transitional state which can not be commanded. The switch
|
||||||
|
//! has been commanded on and the handler waits for it to be on.
|
||||||
|
//! When the switch is on, the mode changes to @c MODE_TO_ON.
|
||||||
|
static const Mode_t _MODE_WAIT_ON = TRANSITION_MODE_BASE_ACTION_MASK | 4;
|
||||||
|
//! This is a transitional state which can not be commanded. The switch has
|
||||||
|
//! been commanded off and is off now. This state is only to do an RMAP
|
||||||
|
//! cycle once more where the doSendRead() function will set the mode to
|
||||||
|
//! MODE_OFF. The reason to do this is to get rid of stuck packets in the IO Board.
|
||||||
|
static const Mode_t _MODE_SWITCH_IS_OFF = TRANSITION_MODE_BASE_ACTION_MASK | 5;
|
||||||
|
|
||||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CDH;
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CDH;
|
||||||
static const Event DEVICE_BUILDING_COMMAND_FAILED = MAKE_EVENT(0, severity::LOW);
|
static const Event DEVICE_BUILDING_COMMAND_FAILED = MAKE_EVENT(0, severity::LOW);
|
||||||
@ -65,7 +109,6 @@ class DeviceHandlerIF {
|
|||||||
static const Event INVALID_DEVICE_COMMAND = MAKE_EVENT(8, severity::LOW);
|
static const Event INVALID_DEVICE_COMMAND = MAKE_EVENT(8, severity::LOW);
|
||||||
static const Event MONITORING_LIMIT_EXCEEDED = MAKE_EVENT(9, severity::LOW);
|
static const Event MONITORING_LIMIT_EXCEEDED = MAKE_EVENT(9, severity::LOW);
|
||||||
static const Event MONITORING_AMBIGUOUS = MAKE_EVENT(10, severity::HIGH);
|
static const Event MONITORING_AMBIGUOUS = MAKE_EVENT(10, severity::HIGH);
|
||||||
static const Event DEVICE_WANTS_HARD_REBOOT = MAKE_EVENT(11, severity::HIGH);
|
|
||||||
|
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF;
|
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF;
|
||||||
|
|
||||||
@ -136,10 +179,4 @@ class DeviceHandlerIF {
|
|||||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ThermalStateCfg {
|
|
||||||
lp_id_t thermalStatePoolId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID;
|
|
||||||
lp_id_t thermalRequestPoolId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID;
|
|
||||||
uint32_t thermalSetId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_ */
|
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_ */
|
||||||
|
@ -7,21 +7,27 @@
|
|||||||
|
|
||||||
class DeviceHandlerThermalSet : public StaticLocalDataSet<2> {
|
class DeviceHandlerThermalSet : public StaticLocalDataSet<2> {
|
||||||
public:
|
public:
|
||||||
DeviceHandlerThermalSet(HasLocalDataPoolIF* hkOwner, ThermalStateCfg cfg)
|
DeviceHandlerThermalSet(
|
||||||
: DeviceHandlerThermalSet(hkOwner->getObjectId(), cfg) {}
|
HasLocalDataPoolIF* hkOwner, uint32_t setId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID,
|
||||||
|
lp_id_t thermalStateId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID,
|
||||||
|
lp_id_t heaterRequestId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID)
|
||||||
|
: DeviceHandlerThermalSet(hkOwner->getObjectId(), setId, thermalStateId, heaterRequestId) {}
|
||||||
|
|
||||||
DeviceHandlerThermalSet(object_id_t deviceHandler, ThermalStateCfg cfg)
|
DeviceHandlerThermalSet(
|
||||||
: StaticLocalDataSet(sid_t(deviceHandler, cfg.thermalSetId)),
|
object_id_t deviceHandler, uint32_t setId = DeviceHandlerIF::DEFAULT_THERMAL_SET_ID,
|
||||||
thermalStatePoolId(cfg.thermalStatePoolId),
|
lp_id_t thermalStateId = DeviceHandlerIF::DEFAULT_THERMAL_STATE_POOL_ID,
|
||||||
heaterRequestPoolId(cfg.thermalRequestPoolId) {}
|
lp_id_t thermalStateRequestId = DeviceHandlerIF::DEFAULT_THERMAL_HEATING_REQUEST_POOL_ID)
|
||||||
|
: StaticLocalDataSet(sid_t(deviceHandler, setId)),
|
||||||
|
thermalStatePoolId(thermalStateId),
|
||||||
|
heaterRequestPoolId(thermalStateRequestId) {}
|
||||||
|
|
||||||
const lp_id_t thermalStatePoolId;
|
const lp_id_t thermalStatePoolId;
|
||||||
const lp_id_t heaterRequestPoolId;
|
const lp_id_t heaterRequestPoolId;
|
||||||
|
|
||||||
lp_var_t<DeviceHandlerIF::dh_thermal_state_t> thermalState =
|
lp_var_t<DeviceHandlerIF::dh_thermal_state_t> thermalState =
|
||||||
lp_var_t<DeviceHandlerIF::dh_thermal_state_t>(sid.objectId, thermalStatePoolId, this);
|
lp_var_t<DeviceHandlerIF::dh_thermal_state_t>(thermalStatePoolId, sid.objectId, this);
|
||||||
lp_var_t<DeviceHandlerIF::dh_heater_request_t> heaterRequest =
|
lp_var_t<DeviceHandlerIF::dh_heater_request_t> heaterRequest =
|
||||||
lp_var_t<DeviceHandlerIF::dh_heater_request_t>(sid.objectId, heaterRequestPoolId, this);
|
lp_var_t<DeviceHandlerIF::dh_heater_request_t>(heaterRequestPoolId, sid.objectId, this);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERTHERMALSET_H_ */
|
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERTHERMALSET_H_ */
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
|
#ifndef FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
|
||||||
#define FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
|
#define FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
|
||||||
|
|
||||||
#include "fsfw/action/HasActionsIF.h"
|
#include "../action/HasActionsIF.h"
|
||||||
#include "fsfw/objectmanager/SystemObjectIF.h"
|
#include "../objectmanager/SystemObjectIF.h"
|
||||||
#include "fsfw/serialize/SerializeIF.h"
|
#include "../serialize/SerializeIF.h"
|
||||||
|
|
||||||
class DeviceTmReportingWrapper : public SerializeIF {
|
class DeviceTmReportingWrapper : public SerializeIF {
|
||||||
public:
|
public:
|
||||||
|
@ -8,9 +8,7 @@ HealthDevice::HealthDevice(object_id_t setObjectId, MessageQueueId_t parentQueue
|
|||||||
parentQueue(parentQueue),
|
parentQueue(parentQueue),
|
||||||
commandQueue(),
|
commandQueue(),
|
||||||
healthHelper(this, setObjectId) {
|
healthHelper(this, setObjectId) {
|
||||||
auto mqArgs = MqArgs(setObjectId, static_cast<void*>(this));
|
commandQueue = QueueFactory::instance()->createMessageQueue(3);
|
||||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
|
||||||
3, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HealthDevice::~HealthDevice() { QueueFactory::instance()->deleteMessageQueue(commandQueue); }
|
HealthDevice::~HealthDevice() { QueueFactory::instance()->deleteMessageQueue(commandQueue); }
|
||||||
@ -29,10 +27,11 @@ ReturnValue_t HealthDevice::initialize() {
|
|||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (parentQueue != MessageQueueIF::NO_QUEUE) {
|
if (parentQueue != 0) {
|
||||||
return healthHelper.initialize(parentQueue);
|
return healthHelper.initialize(parentQueue);
|
||||||
}
|
} else {
|
||||||
return healthHelper.initialize();
|
return healthHelper.initialize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueId_t HealthDevice::getCommandQueue() const { return commandQueue->getId(); }
|
MessageQueueId_t HealthDevice::getCommandQueue() const { return commandQueue->getId(); }
|
||||||
|
@ -29,8 +29,10 @@ class HealthDevice : public SystemObject, public ExecutableObjectIF, public HasH
|
|||||||
protected:
|
protected:
|
||||||
HealthState lastHealth;
|
HealthState lastHealth;
|
||||||
|
|
||||||
MessageQueueId_t parentQueue = MessageQueueIF::NO_QUEUE;
|
MessageQueueId_t parentQueue;
|
||||||
MessageQueueIF* commandQueue;
|
MessageQueueIF* commandQueue;
|
||||||
|
|
||||||
|
public:
|
||||||
HealthHelper healthHelper;
|
HealthHelper healthHelper;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,9 +55,8 @@ void EventManager::notifyListeners(EventMessage* message) {
|
|||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << std::hex << "EventManager::notifyListeners: MSG to 0x" << std::setfill('0')
|
sif::error << std::hex << "EventManager::notifyListeners: MSG to 0x" << std::setfill('0')
|
||||||
<< std::setw(8) << listener.first << " for event 0x" << std::setw(4)
|
<< std::setw(8) << listener.first << " failed with result 0x" << std::setw(4)
|
||||||
<< message->getEventId() << " failed with result 0x" << std::setw(4) << result
|
<< result << std::setfill(' ') << std::endl;
|
||||||
<< std::setfill(' ') << std::endl;
|
|
||||||
#else
|
#else
|
||||||
sif::printError("Sending message to listener 0x%08x failed with result %04x\n",
|
sif::printError("Sending message to listener 0x%08x failed with result %04x\n",
|
||||||
listener.first, result);
|
listener.first, result);
|
||||||
|
@ -21,8 +21,6 @@ extern const char* translateEvents(Event event);
|
|||||||
|
|
||||||
class EventManager : public EventManagerIF, public ExecutableObjectIF, public SystemObject {
|
class EventManager : public EventManagerIF, public ExecutableObjectIF, public SystemObject {
|
||||||
public:
|
public:
|
||||||
static const uint16_t DEFAULT_MAX_EVENTS_PER_CYCLE = 80;
|
|
||||||
|
|
||||||
EventManager(object_id_t setObjectId, uint32_t eventQueueDepth);
|
EventManager(object_id_t setObjectId, uint32_t eventQueueDepth);
|
||||||
virtual ~EventManager();
|
virtual ~EventManager();
|
||||||
|
|
||||||
|
@ -9,9 +9,8 @@
|
|||||||
FailureIsolationBase::FailureIsolationBase(object_id_t owner, object_id_t parent,
|
FailureIsolationBase::FailureIsolationBase(object_id_t owner, object_id_t parent,
|
||||||
uint8_t messageDepth, uint8_t parameterDomainBase)
|
uint8_t messageDepth, uint8_t parameterDomainBase)
|
||||||
: ownerId(owner), faultTreeParent(parent), parameterDomainBase(parameterDomainBase) {
|
: ownerId(owner), faultTreeParent(parent), parameterDomainBase(parameterDomainBase) {
|
||||||
auto mqArgs = MqArgs(owner, static_cast<void*>(this));
|
eventQueue =
|
||||||
eventQueue = QueueFactory::instance()->createMessageQueue(
|
QueueFactory::instance()->createMessageQueue(messageDepth, EventMessage::EVENT_MESSAGE_SIZE);
|
||||||
messageDepth, EventMessage::EVENT_MESSAGE_SIZE, &mqArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FailureIsolationBase::~FailureIsolationBase() {
|
FailureIsolationBase::~FailureIsolationBase() {
|
||||||
@ -62,12 +61,11 @@ ReturnValue_t FailureIsolationBase::initialize() {
|
|||||||
ObjectManager::instance()->get<ConfirmsFailuresIF>(faultTreeParent);
|
ObjectManager::instance()->get<ConfirmsFailuresIF>(faultTreeParent);
|
||||||
if (parentIF == nullptr) {
|
if (parentIF == nullptr) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "FailureIsolationBase::intialize: Parent object "
|
sif::error << "FailureIsolationBase::intialize: Parent object"
|
||||||
<< "invalid" << std::endl;
|
<< "invalid." << std::endl;
|
||||||
sif::error << "Make sure it implements ConfirmsFailuresIF" << std::endl;
|
#endif
|
||||||
#else
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::printError("FailureIsolationBase::intialize: Parent object invalid\n");
|
sif::error << "Make sure it implements ConfirmsFailuresIF." << std::endl;
|
||||||
sif::printError("Make sure it implements ConfirmsFailuresIF\n");
|
|
||||||
#endif
|
#endif
|
||||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
|
@ -12,12 +12,13 @@
|
|||||||
class FailureIsolationBase : public ConfirmsFailuresIF, public HasParametersIF {
|
class FailureIsolationBase : public ConfirmsFailuresIF, public HasParametersIF {
|
||||||
public:
|
public:
|
||||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FDIR_1;
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::FDIR_1;
|
||||||
//! FDIR has an internal state, which changed from par2 (oldState) to par1 (newState).
|
static const Event FDIR_CHANGED_STATE =
|
||||||
static const Event FDIR_CHANGED_STATE = MAKE_EVENT(1, severity::INFO);
|
MAKE_EVENT(1, severity::INFO); //!< FDIR has an internal state, which changed from par2
|
||||||
//! FDIR tries to restart device. Par1: event that caused recovery.
|
//!< (oldState) to par1 (newState).
|
||||||
static const Event FDIR_STARTS_RECOVERY = MAKE_EVENT(2, severity::MEDIUM);
|
static const Event FDIR_STARTS_RECOVERY = MAKE_EVENT(
|
||||||
//! FDIR turns off device. Par1: event that caused recovery.
|
2, severity::MEDIUM); //!< FDIR tries to restart device. Par1: event that caused recovery.
|
||||||
static const Event FDIR_TURNS_OFF_DEVICE = MAKE_EVENT(3, severity::MEDIUM);
|
static const Event FDIR_TURNS_OFF_DEVICE = MAKE_EVENT(
|
||||||
|
3, severity::MEDIUM); //!< FDIR turns off device. Par1: event that caused recovery.
|
||||||
|
|
||||||
FailureIsolationBase(object_id_t owner, object_id_t parent = objects::NO_OBJECT,
|
FailureIsolationBase(object_id_t owner, object_id_t parent = objects::NO_OBJECT,
|
||||||
uint8_t messageDepth = 10, uint8_t parameterDomainBase = 0xF0);
|
uint8_t messageDepth = 10, uint8_t parameterDomainBase = 0xF0);
|
||||||
|
@ -68,7 +68,7 @@ ReturnValue_t FaultCounter::getParameter(uint8_t domainId, uint8_t uniqueId,
|
|||||||
parameterWrapper->set(faultCount);
|
parameterWrapper->set(faultCount);
|
||||||
break;
|
break;
|
||||||
case ParameterIds::TIMEOUT:
|
case ParameterIds::TIMEOUT:
|
||||||
parameterWrapper->set(timer.getTimeoutMs());
|
parameterWrapper->set(timer.timeout);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return INVALID_IDENTIFIER_ID;
|
return INVALID_IDENTIFIER_ID;
|
||||||
|
@ -40,7 +40,6 @@ class HasFileSystemIF {
|
|||||||
//! [EXPORT] : P1: Can be file system specific error code
|
//! [EXPORT] : P1: Can be file system specific error code
|
||||||
static constexpr ReturnValue_t GENERIC_FILE_ERROR = MAKE_RETURN_CODE(0);
|
static constexpr ReturnValue_t GENERIC_FILE_ERROR = MAKE_RETURN_CODE(0);
|
||||||
static constexpr ReturnValue_t GENERIC_DIR_ERROR = MAKE_RETURN_CODE(1);
|
static constexpr ReturnValue_t GENERIC_DIR_ERROR = MAKE_RETURN_CODE(1);
|
||||||
static constexpr ReturnValue_t FILESYSTEM_INACTIVE = MAKE_RETURN_CODE(2);
|
|
||||||
static constexpr ReturnValue_t GENERIC_RENAME_ERROR = MAKE_RETURN_CODE(3);
|
static constexpr ReturnValue_t GENERIC_RENAME_ERROR = MAKE_RETURN_CODE(3);
|
||||||
|
|
||||||
//! [EXPORT] : File system is currently busy
|
//! [EXPORT] : File system is currently busy
|
||||||
@ -74,12 +73,6 @@ class HasFileSystemIF {
|
|||||||
return MessageQueueIF::NO_QUEUE;
|
return MessageQueueIF::NO_QUEUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the base filename without the full directory path
|
|
||||||
virtual ReturnValue_t getBaseFilename(FilesystemParams params, char* nameBuf, size_t maxLen,
|
|
||||||
size_t& baseNameLen) = 0;
|
|
||||||
|
|
||||||
virtual bool isDirectory(const char* path) = 0;
|
|
||||||
|
|
||||||
virtual bool fileExists(FilesystemParams params) = 0;
|
virtual bool fileExists(FilesystemParams params) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,11 +18,8 @@
|
|||||||
*/
|
*/
|
||||||
class DleParser {
|
class DleParser {
|
||||||
public:
|
public:
|
||||||
//! [EXPORT] : [SKIP]
|
|
||||||
static constexpr ReturnValue_t NO_PACKET_FOUND = returnvalue::makeCode(1, 1);
|
static constexpr ReturnValue_t NO_PACKET_FOUND = returnvalue::makeCode(1, 1);
|
||||||
//! [EXPORT] : [SKIP]
|
|
||||||
static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS = returnvalue::makeCode(1, 2);
|
static constexpr ReturnValue_t POSSIBLE_PACKET_LOSS = returnvalue::makeCode(1, 2);
|
||||||
|
|
||||||
using BufPair = std::pair<uint8_t*, size_t>;
|
using BufPair = std::pair<uint8_t*, size_t>;
|
||||||
|
|
||||||
enum class ContextType { NONE, PACKET_FOUND, ERROR };
|
enum class ContextType { NONE, PACKET_FOUND, ERROR };
|
||||||
|
@ -44,12 +44,12 @@ class Type : public SerializeIF {
|
|||||||
|
|
||||||
static ActualType_t getActualType(uint8_t ptc, uint8_t pfc);
|
static ActualType_t getActualType(uint8_t ptc, uint8_t pfc);
|
||||||
|
|
||||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||||
Endianness streamEndianness) const override;
|
Endianness streamEndianness) const override;
|
||||||
|
|
||||||
virtual size_t getSerializedSize() const override;
|
size_t getSerializedSize() const override;
|
||||||
|
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||||
Endianness streamEndianness) override;
|
Endianness streamEndianness) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -53,9 +53,8 @@ class VectorOperations {
|
|||||||
mulScalar(vector, 1 / norm(vector, size), normalizedVector, size);
|
mulScalar(vector, 1 / norm(vector, size), normalizedVector, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
static T maxAbsValue(const T *vector, uint8_t size, uint8_t *index = nullptr) {
|
static T maxAbsValue(const T *vector, uint8_t size, uint8_t *index = 0) {
|
||||||
T max = vector[size - 1];
|
T max = -1;
|
||||||
uint8_t foundIndex = size - 1;
|
|
||||||
|
|
||||||
for (; size > 0; size--) {
|
for (; size > 0; size--) {
|
||||||
T abs = vector[size - 1];
|
T abs = vector[size - 1];
|
||||||
@ -65,35 +64,24 @@ class VectorOperations {
|
|||||||
if (abs > max) {
|
if (abs > max) {
|
||||||
max = abs;
|
max = abs;
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
foundIndex = size - 1;
|
*index = size - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index != nullptr) {
|
|
||||||
*index = foundIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
static T maxValue(const T *vector, uint8_t size, uint8_t *index = nullptr) {
|
static T maxValue(const T *vector, uint8_t size, uint8_t *index = 0) {
|
||||||
T max = vector[size - 1];
|
T max = -1;
|
||||||
uint8_t foundIndex = size - 1;
|
|
||||||
|
|
||||||
for (; size > 0; size--) {
|
for (; size > 0; size--) {
|
||||||
if (vector[size - 1] > max) {
|
if (vector[size - 1] > max) {
|
||||||
max = vector[size - 1];
|
max = vector[size - 1];
|
||||||
if (index != 0) {
|
if (index != 0) {
|
||||||
foundIndex = size - 1;
|
*index = size - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index != nullptr) {
|
|
||||||
*index = foundIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class HousekeepingSnapshot : public SerializeIF {
|
|||||||
HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize, LocalPoolObjectBase* dataSetPtr)
|
HousekeepingSnapshot(uint8_t* timeStamp, size_t timeStampSize, LocalPoolObjectBase* dataSetPtr)
|
||||||
: timeStamp(timeStamp), timeStampSize(timeStampSize), updateData(dataSetPtr){};
|
: timeStamp(timeStamp), timeStampSize(timeStampSize), updateData(dataSetPtr){};
|
||||||
|
|
||||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
Endianness streamEndianness) const {
|
Endianness streamEndianness) const {
|
||||||
if (timeStamp != nullptr) {
|
if (timeStamp != nullptr) {
|
||||||
/* Endianness will always be MACHINE, so we can simply use memcpy
|
/* Endianness will always be MACHINE, so we can simply use memcpy
|
||||||
@ -70,14 +70,14 @@ class HousekeepingSnapshot : public SerializeIF {
|
|||||||
return updateData->serialize(buffer, size, maxSize, streamEndianness);
|
return updateData->serialize(buffer, size, maxSize, streamEndianness);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_t getSerializedSize() const {
|
size_t getSerializedSize() const {
|
||||||
if (updateData == nullptr) {
|
if (updateData == nullptr) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return timeStampSize + updateData->getSerializedSize();
|
return timeStampSize + updateData->getSerializedSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
SerializeIF::Endianness streamEndianness) override {
|
SerializeIF::Endianness streamEndianness) override {
|
||||||
if (*size < timeStampSize) {
|
if (*size < timeStampSize) {
|
||||||
return SerializeIF::STREAM_TOO_SHORT;
|
return SerializeIF::STREAM_TOO_SHORT;
|
||||||
|
@ -3,37 +3,85 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
#include "fsfw/datapoollocal/LocalPoolDataSetBase.h"
|
#include "fsfw/datapoollocal/LocalPoolDataSetBase.h"
|
||||||
#include "fsfw/serviceinterface.h"
|
|
||||||
|
|
||||||
PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner)
|
PeriodicHousekeepingHelper::PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner)
|
||||||
: owner(owner) {}
|
: owner(owner) {}
|
||||||
|
|
||||||
void PeriodicHousekeepingHelper::initialize(float collectionInterval,
|
void PeriodicHousekeepingHelper::initialize(float collectionInterval,
|
||||||
dur_millis_t minimumPeriodicInterval) {
|
dur_millis_t minimumPeriodicInterval,
|
||||||
|
uint8_t nonDiagIntervalFactor) {
|
||||||
this->minimumPeriodicInterval = minimumPeriodicInterval;
|
this->minimumPeriodicInterval = minimumPeriodicInterval;
|
||||||
changeCollectionInterval(collectionInterval);
|
this->nonDiagIntervalFactor = nonDiagIntervalFactor;
|
||||||
|
collectionIntervalTicks = intervalSecondsToIntervalTicks(collectionInterval);
|
||||||
|
/* This will cause a checkOpNecessary call to be true immediately. I think it's okay
|
||||||
|
if a HK packet is generated immediately instead of waiting one generation cycle. */
|
||||||
|
internalTickCounter = collectionIntervalTicks;
|
||||||
}
|
}
|
||||||
|
|
||||||
float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() const {
|
float PeriodicHousekeepingHelper::getCollectionIntervalInSeconds() const {
|
||||||
return collectionInterval;
|
return intervalTicksToSeconds(collectionIntervalTicks);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PeriodicHousekeepingHelper::checkOpNecessary() {
|
bool PeriodicHousekeepingHelper::checkOpNecessary() {
|
||||||
if (hkGenerationCd.hasTimedOut()) {
|
if (internalTickCounter >= collectionIntervalTicks) {
|
||||||
hkGenerationCd.resetTimer();
|
internalTickCounter = 1;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
internalTickCounter++;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeriodicHousekeepingHelper::changeCollectionInterval(float newIntervalSeconds) {
|
uint32_t PeriodicHousekeepingHelper::intervalSecondsToIntervalTicks(
|
||||||
uint32_t intervalMs = newIntervalSeconds * 1000;
|
float collectionIntervalSeconds) {
|
||||||
if (newIntervalSeconds <= 0) {
|
if (owner == nullptr) {
|
||||||
intervalMs = minimumPeriodicInterval;
|
return 0;
|
||||||
newIntervalSeconds = static_cast<float>(minimumPeriodicInterval) / 1000.0;
|
}
|
||||||
|
bool isDiagnostics = owner->isDiagnostics();
|
||||||
|
|
||||||
|
/* Avoid division by zero */
|
||||||
|
if (minimumPeriodicInterval == 0) {
|
||||||
|
if (isDiagnostics) {
|
||||||
|
/* Perform operation each cycle */
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return nonDiagIntervalFactor;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dur_millis_t intervalInMs = collectionIntervalSeconds * 1000;
|
||||||
|
uint32_t divisor = minimumPeriodicInterval;
|
||||||
|
if (not isDiagnostics) {
|
||||||
|
/* We need to multiply the divisor because non-diagnostics only
|
||||||
|
allow a multiple of the minimum periodic interval */
|
||||||
|
divisor *= nonDiagIntervalFactor;
|
||||||
|
}
|
||||||
|
uint32_t ticks = std::ceil(static_cast<float>(intervalInMs) / divisor);
|
||||||
|
if (not isDiagnostics) {
|
||||||
|
/* Now we need to multiply the calculated ticks with the factor as as well
|
||||||
|
because the minimum tick count to generate a non-diagnostic is the factor itself.
|
||||||
|
|
||||||
|
Example calculation for non-diagnostic with
|
||||||
|
0.4 second interval and 0.2 second task interval.
|
||||||
|
Resultant tick count of 5 is equal to operation each second.
|
||||||
|
|
||||||
|
Examle calculation for non-diagnostic with 2.0 second interval and 0.2 second
|
||||||
|
task interval.
|
||||||
|
Resultant tick count of 10 is equal to operatin every 2 seconds.
|
||||||
|
|
||||||
|
Example calculation for diagnostic with 0.4 second interval and 0.3
|
||||||
|
second task interval. Resulting tick count of 2 is equal to operation
|
||||||
|
every 0.6 seconds. */
|
||||||
|
ticks *= nonDiagIntervalFactor;
|
||||||
|
}
|
||||||
|
return ticks;
|
||||||
}
|
}
|
||||||
collectionInterval = newIntervalSeconds;
|
}
|
||||||
hkGenerationCd.setTimeout(intervalMs);
|
|
||||||
// We want an immediate HK packet at the start, so time out the generation CD immediately.
|
float PeriodicHousekeepingHelper::intervalTicksToSeconds(uint32_t collectionInterval) const {
|
||||||
hkGenerationCd.timeOut();
|
/* Number of ticks times the minimum interval is in milliseconds, so we divide by 1000 to get
|
||||||
|
the value in seconds */
|
||||||
|
return static_cast<float>(collectionInterval * minimumPeriodicInterval / 1000.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void PeriodicHousekeepingHelper::changeCollectionInterval(float newIntervalSeconds) {
|
||||||
|
collectionIntervalTicks = intervalSecondsToIntervalTicks(newIntervalSeconds);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "fsfw/timemanager/Clock.h"
|
#include "fsfw/timemanager/Clock.h"
|
||||||
#include "fsfw/timemanager/Countdown.h"
|
|
||||||
|
|
||||||
class LocalPoolDataSetBase;
|
class LocalPoolDataSetBase;
|
||||||
|
|
||||||
@ -12,7 +11,8 @@ class PeriodicHousekeepingHelper {
|
|||||||
public:
|
public:
|
||||||
PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner);
|
PeriodicHousekeepingHelper(LocalPoolDataSetBase* owner);
|
||||||
|
|
||||||
void initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval);
|
void initialize(float collectionInterval, dur_millis_t minimumPeriodicInterval,
|
||||||
|
uint8_t nonDiagIntervalFactor);
|
||||||
|
|
||||||
void changeCollectionInterval(float newInterval);
|
void changeCollectionInterval(float newInterval);
|
||||||
float getCollectionIntervalInSeconds() const;
|
float getCollectionIntervalInSeconds() const;
|
||||||
@ -20,10 +20,14 @@ class PeriodicHousekeepingHelper {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
LocalPoolDataSetBase* owner = nullptr;
|
LocalPoolDataSetBase* owner = nullptr;
|
||||||
Countdown hkGenerationCd;
|
uint8_t nonDiagIntervalFactor = 0;
|
||||||
float collectionInterval = 0.0;
|
|
||||||
|
uint32_t intervalSecondsToIntervalTicks(float collectionIntervalSeconds);
|
||||||
|
float intervalTicksToSeconds(uint32_t collectionInterval) const;
|
||||||
|
|
||||||
dur_millis_t minimumPeriodicInterval = 0;
|
dur_millis_t minimumPeriodicInterval = 0;
|
||||||
|
uint32_t internalTickCounter = 1;
|
||||||
|
uint32_t collectionIntervalTicks = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ */
|
#endif /* FSFW_HOUSEKEEPING_PERIODICHOUSEKEEPINGHELPER_H_ */
|
||||||
|
@ -5,19 +5,13 @@
|
|||||||
#include "fsfw/ipc/QueueFactory.h"
|
#include "fsfw/ipc/QueueFactory.h"
|
||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth,
|
InternalErrorReporter::InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth)
|
||||||
bool enableSetByDefault, float generationFrequency)
|
|
||||||
: SystemObject(setObjectId),
|
: SystemObject(setObjectId),
|
||||||
poolManager(this, commandQueue),
|
poolManager(this, commandQueue),
|
||||||
enableSetByDefault(enableSetByDefault),
|
|
||||||
generationFrequency(generationFrequency),
|
|
||||||
internalErrorSid(setObjectId, InternalErrorDataset::ERROR_SET_ID),
|
internalErrorSid(setObjectId, InternalErrorDataset::ERROR_SET_ID),
|
||||||
internalErrorDataset(this) {
|
internalErrorDataset(this) {
|
||||||
commandQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
commandQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
||||||
mutex = MutexFactory::instance()->createMutex();
|
mutex = MutexFactory::instance()->createMutex();
|
||||||
auto mqArgs = MqArgs(setObjectId, static_cast<void *>(this));
|
|
||||||
commandQueue = QueueFactory::instance()->createMessageQueue(
|
|
||||||
messageQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
InternalErrorReporter::~InternalErrorReporter() {
|
InternalErrorReporter::~InternalErrorReporter() {
|
||||||
@ -45,14 +39,15 @@ ReturnValue_t InternalErrorReporter::performOperation(uint8_t opCode) {
|
|||||||
if ((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) {
|
if ((newQueueHits > 0) or (newTmHits > 0) or (newStoreHits > 0)) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::debug << "InternalErrorReporter::performOperation: Errors "
|
sif::debug << "InternalErrorReporter::performOperation: Errors "
|
||||||
<< "occured: Queue | TM | Store : " << newQueueHits << " | " << newTmHits << " | "
|
<< "occured!" << std::endl;
|
||||||
<< newStoreHits << std::endl;
|
sif::debug << "Queue errors: " << newQueueHits << std::endl;
|
||||||
|
sif::debug << "TM errors: " << newTmHits << std::endl;
|
||||||
|
sif::debug << "Store errors: " << newStoreHits << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printDebug(
|
sif::printDebug("InternalErrorReporter::performOperation: Errors occured!\n");
|
||||||
"InternalErrorReporter::performOperation: Errors occured: Queue | TM | Store: %lu | %lu "
|
sif::printDebug("Queue errors: %lu\n", static_cast<unsigned int>(newQueueHits));
|
||||||
"| %lu\n",
|
sif::printDebug("TM errors: %lu\n", static_cast<unsigned int>(newTmHits));
|
||||||
static_cast<unsigned int>(newQueueHits), static_cast<unsigned int>(newTmHits),
|
sif::printDebug("Store errors: %lu\n", static_cast<unsigned int>(newStoreHits));
|
||||||
static_cast<unsigned int>(newStoreHits));
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -137,8 +132,9 @@ ReturnValue_t InternalErrorReporter::initializeLocalDataPool(localpool::DataPool
|
|||||||
localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry);
|
localDataPoolMap.emplace(errorPoolIds::TM_HITS, &tmHitsEntry);
|
||||||
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry);
|
localDataPoolMap.emplace(errorPoolIds::QUEUE_HITS, &queueHitsEntry);
|
||||||
localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry);
|
localDataPoolMap.emplace(errorPoolIds::STORE_HITS, &storeHitsEntry);
|
||||||
poolManager.subscribeForRegularPeriodicPacket(
|
poolManager.subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams(
|
||||||
subdp::RegularHkPeriodicParams(internalErrorSid, enableSetByDefault, generationFrequency));
|
internalErrorSid, false,
|
||||||
|
static_cast<float>(getPeriodicOperationFrequency()) / static_cast<float>(1000.0)));
|
||||||
internalErrorDataset.setValidity(true, true);
|
internalErrorDataset.setValidity(true, true);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,7 @@ class InternalErrorReporter : public SystemObject,
|
|||||||
public InternalErrorReporterIF,
|
public InternalErrorReporterIF,
|
||||||
public HasLocalDataPoolIF {
|
public HasLocalDataPoolIF {
|
||||||
public:
|
public:
|
||||||
InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth,
|
InternalErrorReporter(object_id_t setObjectId, uint32_t messageQueueDepth = 5);
|
||||||
bool enableSetByDefault, float generationFrequency);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable diagnostic printout. Please note that this feature will
|
* Enable diagnostic printout. Please note that this feature will
|
||||||
@ -64,8 +63,6 @@ class InternalErrorReporter : public SystemObject,
|
|||||||
MutexIF* mutex = nullptr;
|
MutexIF* mutex = nullptr;
|
||||||
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
|
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
|
||||||
uint32_t timeoutMs = 20;
|
uint32_t timeoutMs = 20;
|
||||||
bool enableSetByDefault;
|
|
||||||
float generationFrequency;
|
|
||||||
|
|
||||||
sid_t internalErrorSid;
|
sid_t internalErrorSid;
|
||||||
InternalErrorDataset internalErrorDataset;
|
InternalErrorDataset internalErrorDataset;
|
||||||
|
@ -34,7 +34,7 @@ class CommandMessageIF {
|
|||||||
static const Command_t CMD_NONE = MAKE_COMMAND_ID(0);
|
static const Command_t CMD_NONE = MAKE_COMMAND_ID(0);
|
||||||
static const Command_t REPLY_COMMAND_OK = MAKE_COMMAND_ID(1);
|
static const Command_t REPLY_COMMAND_OK = MAKE_COMMAND_ID(1);
|
||||||
//! Reply indicating that the current command was rejected,
|
//! Reply indicating that the current command was rejected,
|
||||||
//! Parameter 1 should contain the error code
|
//! par1 should contain the error code
|
||||||
static const Command_t REPLY_REJECTED = MAKE_COMMAND_ID(2);
|
static const Command_t REPLY_REJECTED = MAKE_COMMAND_ID(2);
|
||||||
|
|
||||||
virtual ~CommandMessageIF(){};
|
virtual ~CommandMessageIF(){};
|
||||||
|
@ -7,17 +7,14 @@
|
|||||||
class MutexGuard {
|
class MutexGuard {
|
||||||
public:
|
public:
|
||||||
MutexGuard(MutexIF* mutex, MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::BLOCKING,
|
MutexGuard(MutexIF* mutex, MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::BLOCKING,
|
||||||
uint32_t timeoutMs = 0, const char* context = nullptr)
|
uint32_t timeoutMs = 0)
|
||||||
: internalMutex(mutex) {
|
: internalMutex(mutex) {
|
||||||
if (context == nullptr) {
|
|
||||||
context = "unknown";
|
|
||||||
}
|
|
||||||
if (mutex == nullptr) {
|
if (mutex == nullptr) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "MutexGuard::" << context << ": Passed mutex is invalid!" << std::endl;
|
sif::error << "MutexGuard: Passed mutex is invalid!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("MutexGuard::%s: Passed mutex is invalid!\n", context);
|
sif::printError("MutexGuard: Passed mutex is invalid!\n");
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return;
|
return;
|
||||||
@ -26,11 +23,11 @@ class MutexGuard {
|
|||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
if (result == MutexIF::MUTEX_TIMEOUT) {
|
if (result == MutexIF::MUTEX_TIMEOUT) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::error << "MutexGuard::" << context << ": Lock of mutex failed with timeout of "
|
sif::error << "MutexGuard: Lock of mutex failed with timeout of " << timeoutMs
|
||||||
<< timeoutMs << " milliseconds!" << std::endl;
|
<< " milliseconds!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printError("MutexGuard::%s: Lock of mutex failed with timeout of %lu milliseconds\n",
|
sif::printError("MutexGuard: Lock of mutex failed with timeout of %lu milliseconds\n",
|
||||||
context, timeoutMs);
|
timeoutMs);
|
||||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||||
|
|
||||||
} else if (result != returnvalue::OK) {
|
} else if (result != returnvalue::OK) {
|
||||||
|
@ -19,33 +19,32 @@ class HasModesIF {
|
|||||||
static const ReturnValue_t INVALID_SUBMODE = MAKE_RETURN_CODE(0x04);
|
static const ReturnValue_t INVALID_SUBMODE = MAKE_RETURN_CODE(0x04);
|
||||||
|
|
||||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_MANAGER;
|
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_MANAGER;
|
||||||
//! An object announces changing the mode. p1: target mode. p2: target submode
|
static const Event CHANGING_MODE =
|
||||||
static const Event CHANGING_MODE = MAKE_EVENT(0, severity::INFO);
|
MAKE_EVENT(0, severity::INFO); //!< An object announces changing the mode. p1: target mode.
|
||||||
//! An Object announces its mode; parameter1 is mode, parameter2 is submode
|
//!< p2: target submode
|
||||||
static const Event MODE_INFO = MAKE_EVENT(1, severity::INFO);
|
static const Event MODE_INFO = MAKE_EVENT(
|
||||||
|
1,
|
||||||
|
severity::INFO); //!< An Object announces its mode; parameter1 is mode, parameter2 is submode
|
||||||
static const Event FALLBACK_FAILED = MAKE_EVENT(2, severity::HIGH);
|
static const Event FALLBACK_FAILED = MAKE_EVENT(2, severity::HIGH);
|
||||||
static const Event MODE_TRANSITION_FAILED = MAKE_EVENT(3, severity::LOW);
|
static const Event MODE_TRANSITION_FAILED = MAKE_EVENT(3, severity::LOW);
|
||||||
static const Event CANT_KEEP_MODE = MAKE_EVENT(4, severity::HIGH);
|
static const Event CANT_KEEP_MODE = MAKE_EVENT(4, severity::HIGH);
|
||||||
//! Indicates a bug or configuration failure: Object is in a mode it should never be in.
|
static const Event OBJECT_IN_INVALID_MODE =
|
||||||
static const Event OBJECT_IN_INVALID_MODE = MAKE_EVENT(5, severity::LOW);
|
MAKE_EVENT(5, severity::LOW); //!< Indicates a bug or configuration failure: Object is in a
|
||||||
//! The mode is changed, but for some reason, the change is forced, i.e. EXTERNAL_CONTROL ignored.
|
//!< mode it should never be in.
|
||||||
//! p1: target mode. p2: target submode
|
static const Event FORCING_MODE = MAKE_EVENT(
|
||||||
static const Event FORCING_MODE = MAKE_EVENT(6, severity::MEDIUM);
|
6, severity::MEDIUM); //!< The mode is changed, but for some reason, the change is forced,
|
||||||
//! A mode command was rejected by the called object. Par1: called object id, Par2: return code.
|
//!< i.e. EXTERNAL_CONTROL ignored. p1: target mode. p2: target submode
|
||||||
static const Event MODE_CMD_REJECTED = MAKE_EVENT(7, severity::LOW);
|
static const Event MODE_CMD_REJECTED =
|
||||||
|
MAKE_EVENT(7, severity::LOW); //!< A mode command was rejected by the called object. Par1:
|
||||||
|
//!< called object id, Par2: return code.
|
||||||
|
|
||||||
//! The device is powered and ready to perform operations. In this mode, no commands are
|
static const Mode_t MODE_ON =
|
||||||
//! sent by the device handler itself, but direct commands van be commanded and will be
|
1; //!< The device is powered and ready to perform operations. In this mode, no commands are
|
||||||
//! interpreted
|
//!< sent by the device handler itself, but direct commands van be commanded and will be
|
||||||
static constexpr Mode_t MODE_ON = 1;
|
//!< interpreted
|
||||||
//! The device is powered off. The only command accepted in this mode is a mode change to on.
|
static const Mode_t MODE_OFF = 0; //!< The device is powered off. The only command accepted in
|
||||||
static constexpr Mode_t MODE_OFF = 0;
|
//!< this mode is a mode change to on.
|
||||||
|
static const Submode_t SUBMODE_NONE = 0; //!< To avoid checks against magic number "0".
|
||||||
static constexpr Mode_t MODE_INVALID = -1;
|
|
||||||
static constexpr Mode_t MODE_UNDEFINED = -2;
|
|
||||||
|
|
||||||
//! To avoid checks against magic number "0".
|
|
||||||
static const Submode_t SUBMODE_NONE = 0;
|
|
||||||
|
|
||||||
virtual ~HasModesIF() {}
|
virtual ~HasModesIF() {}
|
||||||
virtual MessageQueueId_t getCommandQueue() const = 0;
|
virtual MessageQueueId_t getCommandQueue() const = 0;
|
||||||
|
@ -1,42 +1,43 @@
|
|||||||
#ifndef FSFW_MODES_MODEMESSAGE_H_
|
#ifndef FSFW_MODES_MODEMESSAGE_H_
|
||||||
#define FSFW_MODES_MODEMESSAGE_H_
|
#define FSFW_MODES_MODEMESSAGE_H_
|
||||||
|
|
||||||
#include "fsfw/ipc/CommandMessage.h"
|
#include "../ipc/CommandMessage.h"
|
||||||
|
|
||||||
typedef uint32_t Mode_t;
|
typedef uint32_t Mode_t;
|
||||||
typedef uint8_t Submode_t;
|
typedef uint8_t Submode_t;
|
||||||
|
|
||||||
class ModeMessage {
|
class ModeMessage {
|
||||||
|
private:
|
||||||
|
ModeMessage();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const uint8_t MESSAGE_ID = messagetypes::MODE_COMMAND;
|
static const uint8_t MESSAGE_ID = messagetypes::MODE_COMMAND;
|
||||||
//!> Command to set the specified Mode, replies are: REPLY_MODE_REPLY,
|
static const Command_t CMD_MODE_COMMAND =
|
||||||
|
MAKE_COMMAND_ID(0x01); //!> Command to set the specified Mode, replies are: REPLY_MODE_REPLY,
|
||||||
//! REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any replies,
|
//! REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any replies,
|
||||||
//! as this will break the subsystem mode machine!!
|
//! as this will break the subsystem mode machine!!
|
||||||
static const Command_t CMD_MODE_COMMAND = MAKE_COMMAND_ID(0x01);
|
static const Command_t CMD_MODE_COMMAND_FORCED = MAKE_COMMAND_ID(
|
||||||
//!> Command to set the specified Mode, regardless of external control flag, replies
|
0xF1); //!> Command to set the specified Mode, regardless of external control flag, replies
|
||||||
//! are: REPLY_MODE_REPLY, REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any
|
//! are: REPLY_MODE_REPLY, REPLY_WRONG_MODE_REPLY, and REPLY_REJECTED; don't add any
|
||||||
//! replies, as this will break the subsystem mode machine!!
|
//! replies, as this will break the subsystem mode machine!!
|
||||||
static const Command_t CMD_MODE_COMMAND_FORCED = MAKE_COMMAND_ID(0xF1);
|
static const Command_t REPLY_MODE_REPLY =
|
||||||
//!> Reply to a CMD_MODE_COMMAND or CMD_MODE_READ
|
MAKE_COMMAND_ID(0x02); //!> Reply to a CMD_MODE_COMMAND or CMD_MODE_READ
|
||||||
static const Command_t REPLY_MODE_REPLY = MAKE_COMMAND_ID(0x02);
|
static const Command_t REPLY_MODE_INFO =
|
||||||
//!> Unrequested info about the current mode (used for composites to
|
MAKE_COMMAND_ID(0x03); //!> Unrequested info about the current mode (used for composites to
|
||||||
//! inform their container of a changed mode)
|
//! inform their container of a changed mode)
|
||||||
static const Command_t REPLY_MODE_INFO = MAKE_COMMAND_ID(0x03);
|
static const Command_t REPLY_CANT_REACH_MODE = MAKE_COMMAND_ID(
|
||||||
//!> Reply in case a mode command can't be executed. Par1: returnCode, Par2: 0
|
0x04); //!> Reply in case a mode command can't be executed. Par1: returnCode, Par2: 0
|
||||||
static const Command_t REPLY_CANT_REACH_MODE = MAKE_COMMAND_ID(0x04);
|
static const Command_t REPLY_WRONG_MODE_REPLY =
|
||||||
//!> Reply to a CMD_MODE_COMMAND, indicating that a mode was commanded
|
MAKE_COMMAND_ID(0x05); //!> Reply to a CMD_MODE_COMMAND, indicating that a mode was commanded
|
||||||
//! and a transition started but was aborted; the parameters contain
|
//! and a transition started but was aborted; the parameters contain
|
||||||
//! the mode that was reached
|
//! the mode that was reached
|
||||||
static const Command_t REPLY_WRONG_MODE_REPLY = MAKE_COMMAND_ID(0x05);
|
static const Command_t CMD_MODE_READ = MAKE_COMMAND_ID(
|
||||||
//!> Command to read the current mode and reply with a REPLY_MODE_REPLY
|
0x06); //!> Command to read the current mode and reply with a REPLY_MODE_REPLY
|
||||||
static const Command_t CMD_MODE_READ = MAKE_COMMAND_ID(0x06);
|
static const Command_t CMD_MODE_ANNOUNCE = MAKE_COMMAND_ID(
|
||||||
//!> Command to trigger an ModeInfo Event. This command does NOT have a reply.
|
0x07); //!> Command to trigger an ModeInfo Event. This command does NOT have a reply.
|
||||||
static const Command_t CMD_MODE_ANNOUNCE = MAKE_COMMAND_ID(0x07);
|
static const Command_t CMD_MODE_ANNOUNCE_RECURSIVELY =
|
||||||
//!> Command to trigger an ModeInfo Event and to send this command to
|
MAKE_COMMAND_ID(0x08); //!> Command to trigger an ModeInfo Event and to send this command to
|
||||||
//! every child. This command does NOT have a reply.
|
//! every child. This command does NOT have a reply.
|
||||||
static const Command_t CMD_MODE_ANNOUNCE_RECURSIVELY = MAKE_COMMAND_ID(0x08);
|
|
||||||
|
|
||||||
ModeMessage() = delete;
|
|
||||||
|
|
||||||
static Mode_t getMode(const CommandMessage* message);
|
static Mode_t getMode(const CommandMessage* message);
|
||||||
static Submode_t getSubmode(const CommandMessage* message);
|
static Submode_t getSubmode(const CommandMessage* message);
|
||||||
|
@ -32,9 +32,9 @@ class AbsLimitMonitor : public MonitorBase<T> {
|
|||||||
return returnvalue::OK; // We're not out of range.
|
return returnvalue::OK; // We're not out of range.
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,
|
ReturnValue_t getParameter(uint8_t domainId, uint8_t parameterId,
|
||||||
ParameterWrapper *parameterWrapper,
|
ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues,
|
||||||
const ParameterWrapper *newValues, uint16_t startAtIndex) {
|
uint16_t startAtIndex) override {
|
||||||
ReturnValue_t result = this->MonitorBase<T>::getParameter(
|
ReturnValue_t result = this->MonitorBase<T>::getParameter(
|
||||||
domainId, parameterId, parameterWrapper, newValues, startAtIndex);
|
domainId, parameterId, parameterWrapper, newValues, startAtIndex);
|
||||||
// We'll reuse the DOMAIN_ID of MonitorReporter,
|
// We'll reuse the DOMAIN_ID of MonitorReporter,
|
||||||
|
@ -13,6 +13,7 @@ class MonitoringMessage : public CommandMessage {
|
|||||||
static const Command_t LIMIT_VIOLATION_REPORT = MAKE_COMMAND_ID(10);
|
static const Command_t LIMIT_VIOLATION_REPORT = MAKE_COMMAND_ID(10);
|
||||||
virtual ~MonitoringMessage();
|
virtual ~MonitoringMessage();
|
||||||
static void setLimitViolationReport(CommandMessage* message, store_address_t storeId);
|
static void setLimitViolationReport(CommandMessage* message, store_address_t storeId);
|
||||||
|
using CommandMessage::clear;
|
||||||
static void clear(CommandMessage* message);
|
static void clear(CommandMessage* message);
|
||||||
static store_address_t getStoreId(const CommandMessage* message);
|
static store_address_t getStoreId(const CommandMessage* message);
|
||||||
static void setTypicalMessage(CommandMessage* message, Command_t type, store_address_t storeId);
|
static void setTypicalMessage(CommandMessage* message, Command_t type, store_address_t storeId);
|
||||||
|
@ -109,16 +109,13 @@ void ObjectManager::initialize() {
|
|||||||
for (auto const& it : objectList) {
|
for (auto const& it : objectList) {
|
||||||
result = it.second->initialize();
|
result = it.second->initialize();
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
object_id_t var = it.first;
|
||||||
sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8)
|
sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8)
|
||||||
<< std::setfill('0') << it.first << " failed to initialize with code 0x" << result
|
<< std::setfill('0') << var
|
||||||
<< std::dec << std::setfill(' ') << std::endl;
|
<< " failed to "
|
||||||
#else
|
"initialize with code 0x"
|
||||||
sif::printError(
|
<< result << std::dec << std::setfill(' ') << std::endl;
|
||||||
"ObjectManager::initialize: Object 0x%08x failed to initialize with code 0x%04x\n", var,
|
|
||||||
it.first);
|
|
||||||
#endif
|
|
||||||
#endif
|
#endif
|
||||||
errorCount++;
|
errorCount++;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ enum framework_objects : object_id_t {
|
|||||||
PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008,
|
PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008,
|
||||||
PUS_SERVICE_9_TIME_MGMT = 0x53000009,
|
PUS_SERVICE_9_TIME_MGMT = 0x53000009,
|
||||||
PUS_SERVICE_11_TC_SCHEDULER = 0x53000011,
|
PUS_SERVICE_11_TC_SCHEDULER = 0x53000011,
|
||||||
PUS_SERVICE_15_TM_STORAGE = 0x53000015,
|
|
||||||
PUS_SERVICE_17_TEST = 0x53000017,
|
PUS_SERVICE_17_TEST = 0x53000017,
|
||||||
PUS_SERVICE_20_PARAMETERS = 0x53000020,
|
PUS_SERVICE_20_PARAMETERS = 0x53000020,
|
||||||
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
||||||
|
@ -40,8 +40,9 @@ int TcpIpBase::closeSocket(socket_t socket) {
|
|||||||
return closesocket(socket);
|
return closesocket(socket);
|
||||||
#elif defined(PLATFORM_UNIX)
|
#elif defined(PLATFORM_UNIX)
|
||||||
return close(socket);
|
return close(socket);
|
||||||
#endif
|
#else
|
||||||
return -1;
|
return -1;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int TcpIpBase::getLastSocketError() {
|
int TcpIpBase::getLastSocketError() {
|
||||||
@ -49,6 +50,7 @@ int TcpIpBase::getLastSocketError() {
|
|||||||
return WSAGetLastError();
|
return WSAGetLastError();
|
||||||
#elif defined(PLATFORM_UNIX)
|
#elif defined(PLATFORM_UNIX)
|
||||||
return errno;
|
return errno;
|
||||||
#endif
|
#else
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -283,8 +283,6 @@ ReturnValue_t TcpTmTcServer::handleTmSending(socket_t connSocket, bool& tmSent)
|
|||||||
ConstStorageAccessor storeAccessor(storeId);
|
ConstStorageAccessor storeAccessor(storeId);
|
||||||
ReturnValue_t result = tmStore->getData(storeId, storeAccessor);
|
ReturnValue_t result = tmStore->getData(storeId, storeAccessor);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
// Invalid entry, pop FIFO
|
|
||||||
tmtcBridge->tmFifo->pop();
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (wiretappingEnabled) {
|
if (wiretappingEnabled) {
|
||||||
|
@ -79,7 +79,6 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb
|
|||||||
*/
|
*/
|
||||||
bool reusePort = false;
|
bool reusePort = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ReceptionModes { SPACE_PACKETS };
|
enum class ReceptionModes { SPACE_PACKETS };
|
||||||
|
|
||||||
static const std::string DEFAULT_SERVER_PORT;
|
static const std::string DEFAULT_SERVER_PORT;
|
||||||
|
@ -47,32 +47,7 @@ ReturnValue_t Clock::setClock(const timeval* time) {
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Clock::getClockMonotonic(timeval* time) {
|
ReturnValue_t Clock::getClock_timeval(timeval* time) {
|
||||||
#if defined(PLATFORM_WIN)
|
|
||||||
// TODO: Implement with std::chrono::steady_clock.. or in some other way. I am not even sure
|
|
||||||
// whether this is possible with steady_clock. The conversion we have to do here just to be
|
|
||||||
// generic is kind of awkward..
|
|
||||||
return returnvalue::FAILED;
|
|
||||||
#elif defined(PLATFORM_UNIX)
|
|
||||||
timespec timeMonotonic;
|
|
||||||
int status = clock_gettime(CLOCK_MONOTONIC_RAW, &timeMonotonic);
|
|
||||||
if (status != 0) {
|
|
||||||
return returnvalue::FAILED;
|
|
||||||
}
|
|
||||||
time->tv_sec = timeMonotonic.tv_sec;
|
|
||||||
time->tv_usec = timeMonotonic.tv_nsec / 1000.0;
|
|
||||||
return returnvalue::OK;
|
|
||||||
#else
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "Clock::getUptime: Not implemented for found OS!" << std::endl;
|
|
||||||
#else
|
|
||||||
sif::printWarning("Clock::getUptime: Not implemented for found OS!\n");
|
|
||||||
#endif
|
|
||||||
return returnvalue::FAILED;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t Clock::getClock(timeval* time) {
|
|
||||||
#if defined(PLATFORM_WIN)
|
#if defined(PLATFORM_WIN)
|
||||||
auto now = std::chrono::system_clock::now();
|
auto now = std::chrono::system_clock::now();
|
||||||
auto secondsChrono = std::chrono::time_point_cast<std::chrono::seconds>(now);
|
auto secondsChrono = std::chrono::time_point_cast<std::chrono::seconds>(now);
|
||||||
@ -100,8 +75,6 @@ ReturnValue_t Clock::getClock(timeval* time) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Clock::getClock_timeval(timeval* time) { return Clock::getClock(time); }
|
|
||||||
|
|
||||||
ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
|
ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
|
||||||
if (time == nullptr) {
|
if (time == nullptr) {
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "fsfw/objectmanager/ObjectManagerIF.h"
|
#include "fsfw/objectmanager/ObjectManagerIF.h"
|
||||||
#include "fsfw/tasks/FixedSlotSequence.h"
|
#include "fsfw/tasks/FixedSlotSequence.h"
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include "fsfw/objectmanager/ObjectManagerIF.h"
|
#include "fsfw/objectmanager/ObjectManagerIF.h"
|
||||||
#include "fsfw/tasks/PeriodicTaskBase.h"
|
#include "fsfw/tasks/PeriodicTaskBase.h"
|
||||||
|
@ -20,18 +20,16 @@ TaskFactory::~TaskFactory() = default;
|
|||||||
|
|
||||||
TaskFactory* TaskFactory::instance() { return TaskFactory::factoryInstance; }
|
TaskFactory* TaskFactory::instance() { return TaskFactory::factoryInstance; }
|
||||||
|
|
||||||
PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_, TaskPriority taskPriority_,
|
PeriodicTaskIF* TaskFactory::createPeriodicTask(
|
||||||
TaskStackSize stackSize_,
|
TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_,
|
||||||
TaskPeriod periodInSeconds_,
|
TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_) {
|
||||||
TaskDeadlineMissedFunction deadLineMissedFunction_,
|
|
||||||
void* args) {
|
|
||||||
return new PeriodicTask(name_, taskPriority_, stackSize_, periodInSeconds_,
|
return new PeriodicTask(name_, taskPriority_, stackSize_, periodInSeconds_,
|
||||||
deadLineMissedFunction_);
|
deadLineMissedFunction_);
|
||||||
}
|
}
|
||||||
|
|
||||||
FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(
|
FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(
|
||||||
TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_,
|
TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_,
|
||||||
TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_, void* args) {
|
TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_) {
|
||||||
return new FixedTimeslotTask(name_, taskPriority_, stackSize_, periodInSeconds_,
|
return new FixedTimeslotTask(name_, taskPriority_, stackSize_, periodInSeconds_,
|
||||||
deadLineMissedFunction_);
|
deadLineMissedFunction_);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include <fsfw/returnvalues/returnvalue.h>
|
#include <fsfw/returnvalues/returnvalue.h>
|
||||||
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace tasks {
|
namespace tasks {
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ ReturnValue_t Clock::setClock(const timeval* time) {
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Clock::getClock(timeval* time) {
|
ReturnValue_t Clock::getClock_timeval(timeval* time) {
|
||||||
timespec timeUnix{};
|
timespec timeUnix{};
|
||||||
int status = clock_gettime(CLOCK_REALTIME, &timeUnix);
|
int status = clock_gettime(CLOCK_REALTIME, &timeUnix);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
@ -53,8 +53,6 @@ ReturnValue_t Clock::getClock(timeval* time) {
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Clock::getClock_timeval(timeval* time) { return Clock::getClock(time); }
|
|
||||||
|
|
||||||
ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
|
ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
|
||||||
timeval timeVal{};
|
timeval timeVal{};
|
||||||
ReturnValue_t result = getClock_timeval(&timeVal);
|
ReturnValue_t result = getClock_timeval(&timeVal);
|
||||||
@ -66,17 +64,6 @@ ReturnValue_t Clock::getClock_usecs(uint64_t* time) {
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Clock::getClockMonotonic(timeval* time) {
|
|
||||||
timespec timeMonotonic{};
|
|
||||||
int status = clock_gettime(CLOCK_MONOTONIC_RAW, &timeMonotonic);
|
|
||||||
if (status != 0) {
|
|
||||||
return returnvalue::FAILED;
|
|
||||||
}
|
|
||||||
time->tv_sec = timeMonotonic.tv_sec;
|
|
||||||
time->tv_usec = timeMonotonic.tv_nsec / 1000.0;
|
|
||||||
return returnvalue::OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
timeval Clock::getUptime() {
|
timeval Clock::getUptime() {
|
||||||
timeval uptime{};
|
timeval uptime{};
|
||||||
auto result = getUptime(&uptime);
|
auto result = getUptime(&uptime);
|
||||||
|
@ -7,15 +7,10 @@
|
|||||||
const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = PTHREAD_STACK_MIN;
|
const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = PTHREAD_STACK_MIN;
|
||||||
|
|
||||||
FixedTimeslotTask::FixedTimeslotTask(const char* name_, TaskPriority priority_, size_t stackSize_,
|
FixedTimeslotTask::FixedTimeslotTask(const char* name_, TaskPriority priority_, size_t stackSize_,
|
||||||
TaskPeriod periodSeconds_, TaskDeadlineMissedFunction dlmFunc_,
|
TaskPeriod periodSeconds_, TaskDeadlineMissedFunction dlmFunc_)
|
||||||
PosixThreadArgs* args)
|
|
||||||
: FixedTimeslotTaskBase(periodSeconds_, dlmFunc_),
|
: FixedTimeslotTaskBase(periodSeconds_, dlmFunc_),
|
||||||
posixThread(name_, SchedulingPolicy::REGULAR, priority_, stackSize_),
|
posixThread(name_, priority_, stackSize_),
|
||||||
started(false) {
|
started(false) {}
|
||||||
if (args != nullptr) {
|
|
||||||
posixThread.setSchedPolicy(args->policy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void* FixedTimeslotTask::taskEntryPoint(void* arg) {
|
void* FixedTimeslotTask::taskEntryPoint(void* arg) {
|
||||||
// The argument is re-interpreted as PollingTask.
|
// The argument is re-interpreted as PollingTask.
|
||||||
|
@ -23,8 +23,7 @@ class FixedTimeslotTask : public FixedTimeslotTaskBase {
|
|||||||
* @param deadlineMissedFunc_
|
* @param deadlineMissedFunc_
|
||||||
*/
|
*/
|
||||||
FixedTimeslotTask(const char* name_, TaskPriority priority_, size_t stackSize_,
|
FixedTimeslotTask(const char* name_, TaskPriority priority_, size_t stackSize_,
|
||||||
TaskPeriod periodSeconds_, TaskDeadlineMissedFunction dlmFunc_,
|
TaskPeriod periodSeconds_, TaskDeadlineMissedFunction dlmFunc_);
|
||||||
PosixThreadArgs* args);
|
|
||||||
~FixedTimeslotTask() override = default;
|
~FixedTimeslotTask() override = default;
|
||||||
|
|
||||||
ReturnValue_t startTask() override;
|
ReturnValue_t startTask() override;
|
||||||
|
@ -4,15 +4,10 @@
|
|||||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||||
|
|
||||||
PeriodicPosixTask::PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_,
|
PeriodicPosixTask::PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_,
|
||||||
TaskPeriod period_, TaskDeadlineMissedFunction dlmFunc_,
|
TaskPeriod period_, TaskDeadlineMissedFunction dlmFunc_)
|
||||||
PosixThreadArgs* args)
|
|
||||||
: PeriodicTaskBase(period_, dlmFunc_),
|
: PeriodicTaskBase(period_, dlmFunc_),
|
||||||
posixThread(name_, SchedulingPolicy::REGULAR, priority_, stackSize_),
|
posixThread(name_, priority_, stackSize_),
|
||||||
started(false) {
|
started(false) {}
|
||||||
if (args != nullptr) {
|
|
||||||
posixThread.setSchedPolicy(args->policy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void* PeriodicPosixTask::taskEntryPoint(void* arg) {
|
void* PeriodicPosixTask::taskEntryPoint(void* arg) {
|
||||||
// The argument is re-interpreted as PollingTask.
|
// The argument is re-interpreted as PollingTask.
|
||||||
|
@ -24,7 +24,7 @@ class PeriodicPosixTask : public PeriodicTaskBase {
|
|||||||
* @param deadlineMissedFunc_
|
* @param deadlineMissedFunc_
|
||||||
*/
|
*/
|
||||||
PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_, TaskPeriod period_,
|
PeriodicPosixTask(const char* name_, int priority_, size_t stackSize_, TaskPeriod period_,
|
||||||
TaskDeadlineMissedFunction dlmFunc_, PosixThreadArgs* args);
|
TaskDeadlineMissedFunction dlmFunc_);
|
||||||
~PeriodicPosixTask() override = default;
|
~PeriodicPosixTask() override = default;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -7,9 +7,8 @@
|
|||||||
#include "fsfw/osal/linux/unixUtility.h"
|
#include "fsfw/osal/linux/unixUtility.h"
|
||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
PosixThread::PosixThread(const char* name_, SchedulingPolicy schedPolciy, int priority_,
|
PosixThread::PosixThread(const char* name_, int priority_, size_t stackSize_)
|
||||||
size_t stackSize_)
|
: thread(0), priority(priority_), stackSize(stackSize_) {
|
||||||
: thread(0), schedPolicy(schedPolciy), priority(priority_), stackSize(stackSize_) {
|
|
||||||
name[0] = '\0';
|
name[0] = '\0';
|
||||||
std::strncat(name, name_, PTHREAD_MAX_NAMELEN - 1);
|
std::strncat(name, name_, PTHREAD_MAX_NAMELEN - 1);
|
||||||
}
|
}
|
||||||
@ -179,30 +178,20 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
|||||||
#ifndef FSFW_USE_REALTIME_FOR_LINUX
|
#ifndef FSFW_USE_REALTIME_FOR_LINUX
|
||||||
#error "Please define FSFW_USE_REALTIME_FOR_LINUX with either 0 or 1"
|
#error "Please define FSFW_USE_REALTIME_FOR_LINUX with either 0 or 1"
|
||||||
#endif
|
#endif
|
||||||
if (schedPolicy == SchedulingPolicy::RR) {
|
|
||||||
// RR -> This needs root privileges for the process
|
|
||||||
#if FSFW_USE_REALTIME_FOR_LINUX == 1
|
#if FSFW_USE_REALTIME_FOR_LINUX == 1
|
||||||
status = pthread_attr_setschedpolicy(&attributes, SCHED_RR);
|
// FIFO -> This needs root privileges for the process
|
||||||
|
status = pthread_attr_setschedpolicy(&attributes, SCHED_FIFO);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_setschedpolicy");
|
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_setschedpolicy");
|
||||||
}
|
}
|
||||||
|
|
||||||
sched_param scheduleParams;
|
sched_param scheduleParams;
|
||||||
scheduleParams.sched_priority = priority;
|
scheduleParams.__sched_priority = priority;
|
||||||
status = pthread_attr_setschedparam(&attributes, &scheduleParams);
|
status = pthread_attr_setschedparam(&attributes, &scheduleParams);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_setschedparam");
|
||||||
sif::warning << "PosixThread: Setting priority failed" << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning
|
|
||||||
<< "Real time priorities are only allowed if FSFW_USE_REALTIME_FOR_LINUX is set to 1"
|
|
||||||
<< std::endl;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set Signal Mask for suspend until startTask is called
|
// Set Signal Mask for suspend until startTask is called
|
||||||
sigset_t waitSignal;
|
sigset_t waitSignal;
|
||||||
sigemptyset(&waitSignal);
|
sigemptyset(&waitSignal);
|
||||||
@ -254,5 +243,3 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
|||||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_destroy");
|
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_destroy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PosixThread::setSchedPolicy(SchedulingPolicy policy) { this->schedPolicy = policy; }
|
|
||||||
|
@ -9,15 +9,10 @@
|
|||||||
|
|
||||||
#include "../../returnvalues/returnvalue.h"
|
#include "../../returnvalues/returnvalue.h"
|
||||||
|
|
||||||
enum SchedulingPolicy { REGULAR, RR };
|
|
||||||
struct PosixThreadArgs {
|
|
||||||
SchedulingPolicy policy = SchedulingPolicy::REGULAR;
|
|
||||||
};
|
|
||||||
|
|
||||||
class PosixThread {
|
class PosixThread {
|
||||||
public:
|
public:
|
||||||
static constexpr uint8_t PTHREAD_MAX_NAMELEN = 16;
|
static constexpr uint8_t PTHREAD_MAX_NAMELEN = 16;
|
||||||
PosixThread(const char* name_, SchedulingPolicy schedPolicy, int priority_, size_t stackSize_);
|
PosixThread(const char* name_, int priority_, size_t stackSize_);
|
||||||
virtual ~PosixThread();
|
virtual ~PosixThread();
|
||||||
/**
|
/**
|
||||||
* Set the Thread to sleep state
|
* Set the Thread to sleep state
|
||||||
@ -25,9 +20,6 @@ class PosixThread {
|
|||||||
* @return Returns Failed if sleep fails
|
* @return Returns Failed if sleep fails
|
||||||
*/
|
*/
|
||||||
static ReturnValue_t sleep(uint64_t ns);
|
static ReturnValue_t sleep(uint64_t ns);
|
||||||
|
|
||||||
void setSchedPolicy(SchedulingPolicy policy);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Function to suspend the task until SIGUSR1 was received
|
* @brief Function to suspend the task until SIGUSR1 was received
|
||||||
*
|
*
|
||||||
@ -80,7 +72,6 @@ class PosixThread {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
char name[PTHREAD_MAX_NAMELEN];
|
char name[PTHREAD_MAX_NAMELEN];
|
||||||
SchedulingPolicy schedPolicy;
|
|
||||||
int priority;
|
int priority;
|
||||||
size_t stackSize = 0;
|
size_t stackSize = 0;
|
||||||
|
|
||||||
|
@ -12,20 +12,18 @@ TaskFactory::~TaskFactory() = default;
|
|||||||
|
|
||||||
TaskFactory* TaskFactory::instance() { return TaskFactory::factoryInstance; }
|
TaskFactory* TaskFactory::instance() { return TaskFactory::factoryInstance; }
|
||||||
|
|
||||||
PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_, TaskPriority taskPriority_,
|
PeriodicTaskIF* TaskFactory::createPeriodicTask(
|
||||||
TaskStackSize stackSize_,
|
TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_,
|
||||||
TaskPeriod periodInSeconds_,
|
TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_) {
|
||||||
TaskDeadlineMissedFunction deadLineMissedFunction_,
|
|
||||||
void* args) {
|
|
||||||
return new PeriodicPosixTask(name_, taskPriority_, stackSize_, periodInSeconds_,
|
return new PeriodicPosixTask(name_, taskPriority_, stackSize_, periodInSeconds_,
|
||||||
deadLineMissedFunction_, reinterpret_cast<PosixThreadArgs*>(args));
|
deadLineMissedFunction_);
|
||||||
}
|
}
|
||||||
|
|
||||||
FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(
|
FixedTimeslotTaskIF* TaskFactory::createFixedTimeslotTask(
|
||||||
TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_,
|
TaskName name_, TaskPriority taskPriority_, TaskStackSize stackSize_,
|
||||||
TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_, void* args) {
|
TaskPeriod periodInSeconds_, TaskDeadlineMissedFunction deadLineMissedFunction_) {
|
||||||
return new FixedTimeslotTask(name_, taskPriority_, stackSize_, periodInSeconds_,
|
return new FixedTimeslotTask(name_, taskPriority_, stackSize_, periodInSeconds_,
|
||||||
deadLineMissedFunction_, reinterpret_cast<PosixThreadArgs*>(args));
|
deadLineMissedFunction_);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) {
|
ReturnValue_t TaskFactory::deleteTask(PeriodicTaskIF* task) {
|
||||||
|
@ -19,12 +19,12 @@ class CpuUsage : public SerializeIF {
|
|||||||
float timeRunning;
|
float timeRunning;
|
||||||
float percentUsage;
|
float percentUsage;
|
||||||
|
|
||||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
Endianness streamEndianness) const override;
|
Endianness streamEndianness) const override;
|
||||||
|
|
||||||
virtual size_t getSerializedSize() const override;
|
size_t getSerializedSize() const override;
|
||||||
|
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
Endianness streamEndianness) override;
|
Endianness streamEndianness) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,8 +66,7 @@ class HasParametersIF {
|
|||||||
* @param newValues
|
* @param newValues
|
||||||
* @param startAtIndex Linear index, runs left to right, top to bottom for
|
* @param startAtIndex Linear index, runs left to right, top to bottom for
|
||||||
* matrix indexes.
|
* matrix indexes.
|
||||||
* @return returnvalue::OK if parameter is valid and a set function of the parameter wrapper was
|
* @return
|
||||||
* called.
|
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier,
|
virtual ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier,
|
||||||
ParameterWrapper *parameterWrapper,
|
ParameterWrapper *parameterWrapper,
|
||||||
|
@ -211,13 +211,9 @@ ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from,
|
|||||||
if (data == nullptr) {
|
if (data == nullptr) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "ParameterWrapper::copyFrom: Called on read-only variable or "
|
sif::warning << "ParameterWrapper::copyFrom: Called on read-only variable!" << std::endl;
|
||||||
"data pointer not set"
|
|
||||||
<< std::endl;
|
|
||||||
#else
|
#else
|
||||||
sif::printWarning(
|
sif::printWarning("ParameterWrapper::copyFrom: Called on read-only variable!\n");
|
||||||
"ParameterWrapper::copyFrom: Called on read-only variable "
|
|
||||||
"or data pointer not set\n");
|
|
||||||
#endif
|
#endif
|
||||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return READONLY;
|
return READONLY;
|
||||||
@ -226,9 +222,9 @@ ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from,
|
|||||||
if (from->readonlyData == nullptr) {
|
if (from->readonlyData == nullptr) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "ParameterWrapper::copyFrom: Source not set" << std::endl;
|
sif::warning << "ParameterWrapper::copyFrom: Source not set!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("ParameterWrapper::copyFrom: Source not set\n");
|
sif::printWarning("ParameterWrapper::copyFrom: Source not set!\n");
|
||||||
#endif
|
#endif
|
||||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return SOURCE_NOT_SET;
|
return SOURCE_NOT_SET;
|
||||||
@ -237,9 +233,9 @@ ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from,
|
|||||||
if (type != from->type) {
|
if (type != from->type) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "ParameterWrapper::copyFrom: Datatype missmatch" << std::endl;
|
sif::warning << "ParameterWrapper::copyFrom: Datatype missmatch!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("ParameterWrapper::copyFrom: Datatype missmatch\n");
|
sif::printWarning("ParameterWrapper::copyFrom: Datatype missmatch!\n");
|
||||||
#endif
|
#endif
|
||||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return DATATYPE_MISSMATCH;
|
return DATATYPE_MISSMATCH;
|
||||||
@ -249,9 +245,9 @@ ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from,
|
|||||||
if (rows == 0 or columns == 0) {
|
if (rows == 0 or columns == 0) {
|
||||||
#if FSFW_VERBOSE_LEVEL >= 1
|
#if FSFW_VERBOSE_LEVEL >= 1
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "ParameterWrapper::copyFrom: Columns or rows zero" << std::endl;
|
sif::warning << "ParameterWrapper::copyFrom: Columns or rows zero!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning("ParameterWrapper::copyFrom: Columns or rows zero\n");
|
sif::printWarning("ParameterWrapper::copyFrom: Columns or rows zero!\n");
|
||||||
#endif
|
#endif
|
||||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||||
return COLUMN_OR_ROWS_ZERO;
|
return COLUMN_OR_ROWS_ZERO;
|
||||||
|
@ -40,12 +40,14 @@ class ParameterWrapper : public SerializeIF {
|
|||||||
ParameterWrapper(Type type, uint8_t rows, uint8_t columns, const void *data);
|
ParameterWrapper(Type type, uint8_t rows, uint8_t columns, const void *data);
|
||||||
virtual ~ParameterWrapper();
|
virtual ~ParameterWrapper();
|
||||||
|
|
||||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
ReturnValue_t serialize(uint8_t **buffer, size_t *size, size_t maxSize,
|
||||||
Endianness streamEndianness) const override;
|
Endianness streamEndianness) const override;
|
||||||
|
|
||||||
virtual size_t getSerializedSize() const override;
|
size_t getSerializedSize() const override;
|
||||||
|
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
using SerializeIF::deSerialize; // we overloaded this function, so this is needed to unconfuse
|
||||||
|
// the compiler
|
||||||
|
ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||||
Endianness streamEndianness) override;
|
Endianness streamEndianness) override;
|
||||||
|
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||||
|
@ -6,11 +6,7 @@ DummyPowerSwitcher::DummyPowerSwitcher(object_id_t objectId, size_t numberOfSwit
|
|||||||
: SystemObject(objectId, registerGlobally),
|
: SystemObject(objectId, registerGlobally),
|
||||||
switcherList(numberOfSwitches),
|
switcherList(numberOfSwitches),
|
||||||
fuseList(numberOfFuses),
|
fuseList(numberOfFuses),
|
||||||
switchDelayMs(switchDelayMs) {
|
switchDelayMs(switchDelayMs) {}
|
||||||
for (auto &switchState : switcherList) {
|
|
||||||
switchState = PowerSwitchIF::SWITCH_UNKNOWN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DummyPowerSwitcher::setInitialSwitcherList(std::vector<ReturnValue_t> switcherList) {
|
void DummyPowerSwitcher::setInitialSwitcherList(std::vector<ReturnValue_t> switcherList) {
|
||||||
this->switcherList = switcherList;
|
this->switcherList = switcherList;
|
||||||
|
@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
#include <fsfw/ipc/QueueFactory.h>
|
#include <fsfw/ipc/QueueFactory.h>
|
||||||
#include <fsfw/power/PowerSwitchIF.h>
|
#include <fsfw/power/PowerSwitchIF.h>
|
||||||
#include <fsfw/subsystem/helper.h>
|
|
||||||
|
|
||||||
PowerSwitcherComponent::PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF* pwrSwitcher,
|
PowerSwitcherComponent::PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF *pwrSwitcher,
|
||||||
power::Switch_t pwrSwitch)
|
power::Switch_t pwrSwitch)
|
||||||
: SystemObject(objectId),
|
: SystemObject(objectId),
|
||||||
switcher(pwrSwitcher, pwrSwitch),
|
switcher(pwrSwitcher, pwrSwitch),
|
||||||
@ -29,9 +28,6 @@ ReturnValue_t PowerSwitcherComponent::performOperation(uint8_t opCode) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getHealth() == FAULTY) {
|
|
||||||
performFaultyOperation();
|
|
||||||
}
|
|
||||||
if (switcher.active()) {
|
if (switcher.active()) {
|
||||||
switcher.doStateMachine();
|
switcher.doStateMachine();
|
||||||
auto currState = switcher.getState();
|
auto currState = switcher.getState();
|
||||||
@ -58,7 +54,7 @@ ReturnValue_t PowerSwitcherComponent::initialize() {
|
|||||||
|
|
||||||
MessageQueueId_t PowerSwitcherComponent::getCommandQueue() const { return queue->getId(); }
|
MessageQueueId_t PowerSwitcherComponent::getCommandQueue() const { return queue->getId(); }
|
||||||
|
|
||||||
void PowerSwitcherComponent::getMode(Mode_t* mode, Submode_t* submode) {
|
void PowerSwitcherComponent::getMode(Mode_t *mode, Submode_t *submode) {
|
||||||
*mode = this->mode;
|
*mode = this->mode;
|
||||||
*submode = this->submode;
|
*submode = this->submode;
|
||||||
}
|
}
|
||||||
@ -69,7 +65,7 @@ ReturnValue_t PowerSwitcherComponent::setHealth(HealthState health) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PowerSwitcherComponent::checkModeCommand(Mode_t mode, Submode_t submode,
|
ReturnValue_t PowerSwitcherComponent::checkModeCommand(Mode_t mode, Submode_t submode,
|
||||||
uint32_t* msToReachTheMode) {
|
uint32_t *msToReachTheMode) {
|
||||||
*msToReachTheMode = 5000;
|
*msToReachTheMode = 5000;
|
||||||
if (mode != MODE_ON and mode != MODE_OFF) {
|
if (mode != MODE_ON and mode != MODE_OFF) {
|
||||||
return TRANS_NOT_ALLOWED;
|
return TRANS_NOT_ALLOWED;
|
||||||
@ -109,17 +105,3 @@ void PowerSwitcherComponent::setMode(Mode_t newMode, Submode_t newSubmode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HasHealthIF::HealthState PowerSwitcherComponent::getHealth() { return healthHelper.getHealth(); }
|
HasHealthIF::HealthState PowerSwitcherComponent::getHealth() { return healthHelper.getHealth(); }
|
||||||
|
|
||||||
const HasHealthIF* PowerSwitcherComponent::getOptHealthIF() const { return this; }
|
|
||||||
|
|
||||||
const HasModesIF& PowerSwitcherComponent::getModeIF() const { return *this; }
|
|
||||||
|
|
||||||
ReturnValue_t PowerSwitcherComponent::connectModeTreeParent(HasModeTreeChildrenIF& parent) {
|
|
||||||
return modetree::connectModeTreeParent(parent, *this, &healthHelper, modeHelper);
|
|
||||||
}
|
|
||||||
|
|
||||||
object_id_t PowerSwitcherComponent::getObjectId() const { return SystemObject::getObjectId(); }
|
|
||||||
|
|
||||||
ModeTreeChildIF& PowerSwitcherComponent::getModeTreeChildIF() { return *this; }
|
|
||||||
|
|
||||||
void PowerSwitcherComponent::performFaultyOperation() {}
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#pragma once
|
#ifndef _FSFW_POWER_POWERSWITCHERCOMPONENT_H_
|
||||||
|
#define _FSFW_POWER_POWERSWITCHERCOMPONENT_H_
|
||||||
|
|
||||||
#include <fsfw/health/HasHealthIF.h>
|
#include <fsfw/health/HasHealthIF.h>
|
||||||
#include <fsfw/health/HealthHelper.h>
|
#include <fsfw/health/HealthHelper.h>
|
||||||
@ -7,8 +8,6 @@
|
|||||||
#include <fsfw/objectmanager/SystemObject.h>
|
#include <fsfw/objectmanager/SystemObject.h>
|
||||||
#include <fsfw/power/PowerSwitcher.h>
|
#include <fsfw/power/PowerSwitcher.h>
|
||||||
#include <fsfw/power/definitions.h>
|
#include <fsfw/power/definitions.h>
|
||||||
#include <fsfw/subsystem/ModeTreeChildIF.h>
|
|
||||||
#include <fsfw/subsystem/ModeTreeConnectionIF.h>
|
|
||||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||||
|
|
||||||
class PowerSwitchIF;
|
class PowerSwitchIF;
|
||||||
@ -25,24 +24,17 @@ class PowerSwitchIF;
|
|||||||
*/
|
*/
|
||||||
class PowerSwitcherComponent : public SystemObject,
|
class PowerSwitcherComponent : public SystemObject,
|
||||||
public ExecutableObjectIF,
|
public ExecutableObjectIF,
|
||||||
public ModeTreeChildIF,
|
|
||||||
public ModeTreeConnectionIF,
|
|
||||||
public HasModesIF,
|
public HasModesIF,
|
||||||
public HasHealthIF {
|
public HasHealthIF {
|
||||||
public:
|
public:
|
||||||
PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF *pwrSwitcher,
|
PowerSwitcherComponent(object_id_t objectId, PowerSwitchIF *pwrSwitcher,
|
||||||
power::Switch_t pwrSwitch);
|
power::Switch_t pwrSwitch);
|
||||||
|
|
||||||
ReturnValue_t connectModeTreeParent(HasModeTreeChildrenIF &parent) override;
|
|
||||||
ModeTreeChildIF &getModeTreeChildIF() override;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
PowerSwitcher switcher;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MessageQueueIF *queue = nullptr;
|
MessageQueueIF *queue = nullptr;
|
||||||
|
PowerSwitcher switcher;
|
||||||
|
|
||||||
Mode_t mode = MODE_UNDEFINED;
|
Mode_t mode = MODE_OFF;
|
||||||
Submode_t submode = 0;
|
Submode_t submode = 0;
|
||||||
|
|
||||||
ModeHelper modeHelper;
|
ModeHelper modeHelper;
|
||||||
@ -50,23 +42,20 @@ class PowerSwitcherComponent : public SystemObject,
|
|||||||
|
|
||||||
void setMode(Mode_t newMode, Submode_t newSubmode);
|
void setMode(Mode_t newMode, Submode_t newSubmode);
|
||||||
|
|
||||||
ReturnValue_t performOperation(uint8_t opCode) override;
|
virtual ReturnValue_t performOperation(uint8_t opCode) override;
|
||||||
|
|
||||||
ReturnValue_t initialize() override;
|
ReturnValue_t initialize() override;
|
||||||
|
|
||||||
[[nodiscard]] MessageQueueId_t getCommandQueue() const override;
|
MessageQueueId_t getCommandQueue() const override;
|
||||||
void getMode(Mode_t *mode, Submode_t *submode) override;
|
void getMode(Mode_t *mode, Submode_t *submode) 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;
|
||||||
void startTransition(Mode_t mode, Submode_t submode) override;
|
void startTransition(Mode_t mode, Submode_t submode) override;
|
||||||
virtual void performFaultyOperation();
|
|
||||||
void setToExternalControl() override;
|
void setToExternalControl() override;
|
||||||
void announceMode(bool recursive) override;
|
void announceMode(bool recursive) override;
|
||||||
|
|
||||||
ReturnValue_t setHealth(HealthState health) override;
|
ReturnValue_t setHealth(HealthState health) override;
|
||||||
HasHealthIF::HealthState getHealth() override;
|
HasHealthIF::HealthState getHealth() override;
|
||||||
|
|
||||||
[[nodiscard]] object_id_t getObjectId() const override;
|
|
||||||
[[nodiscard]] const HasHealthIF *getOptHealthIF() const override;
|
|
||||||
[[nodiscard]] const HasModesIF &getModeIF() const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif /* _FSFW_POWER_POWERSWITCHERCOMPONENT_H_ */
|
||||||
|
@ -79,7 +79,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::performService
|
|||||||
// NOTE: The iterator is increased in the loop here. Increasing the iterator as for-loop arg
|
// NOTE: The iterator is increased in the loop here. Increasing the iterator as for-loop arg
|
||||||
// does not work in this case as we are deleting the current element here.
|
// does not work in this case as we are deleting the current element here.
|
||||||
for (auto it = telecommandMap.begin(); it != telecommandMap.end();) {
|
for (auto it = telecommandMap.begin(); it != telecommandMap.end();) {
|
||||||
if (it->first <= static_cast<uint32_t>(tNow.tv_sec)) {
|
if (it->first <= tNow.tv_sec) {
|
||||||
if (schedulingEnabled) {
|
if (schedulingEnabled) {
|
||||||
// release tc
|
// release tc
|
||||||
TmTcMessage releaseMsg(it->second.storeAddr);
|
TmTcMessage releaseMsg(it->second.storeAddr);
|
||||||
@ -160,7 +160,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doInsertActivi
|
|||||||
// (See requirement for Time margin)
|
// (See requirement for Time margin)
|
||||||
timeval tNow = {};
|
timeval tNow = {};
|
||||||
Clock::getClock_timeval(&tNow);
|
Clock::getClock_timeval(&tNow);
|
||||||
if (timestamp < static_cast<uint32_t>(tNow.tv_sec + RELEASE_TIME_MARGIN_SECONDS)) {
|
if (timestamp - tNow.tv_sec <= RELEASE_TIME_MARGIN_SECONDS) {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "Service11TelecommandScheduling::doInsertActivity: Release time too close to "
|
sif::warning << "Service11TelecommandScheduling::doInsertActivity: Release time too close to "
|
||||||
"current time"
|
"current time"
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
#include "fsfw/pus/Service17Test.h"
|
#include "fsfw/pus/Service17Test.h"
|
||||||
|
|
||||||
#include <fsfw/serialize/SerializeElement.h>
|
|
||||||
|
|
||||||
#include "fsfw/FSFW.h"
|
#include "fsfw/FSFW.h"
|
||||||
#include "fsfw/objectmanager/ObjectManager.h"
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
#include "fsfw/objectmanager/SystemObject.h"
|
#include "fsfw/objectmanager/SystemObject.h"
|
||||||
@ -33,15 +31,6 @@ ReturnValue_t Service17Test::handleRequest(uint8_t subservice) {
|
|||||||
}
|
}
|
||||||
return tmHelper.storeAndSendTmPacket();
|
return tmHelper.storeAndSendTmPacket();
|
||||||
}
|
}
|
||||||
case Subservice::PING_WITH_DATA: {
|
|
||||||
SerializeElement<uint32_t> receivedDataLen = currentPacket.getUserDataLen();
|
|
||||||
ReturnValue_t result =
|
|
||||||
tmHelper.prepareTmPacket(Subservice::PING_WITH_DATA_REPORT_WITH_SIZE, receivedDataLen);
|
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return tmHelper.storeAndSendTmPacket();
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
|
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,6 @@ class Service17Test : public PusServiceBase {
|
|||||||
CONNECTION_TEST_REPORT = 2,
|
CONNECTION_TEST_REPORT = 2,
|
||||||
//! [EXPORT] : [COMMAND] Trigger test reply and test event
|
//! [EXPORT] : [COMMAND] Trigger test reply and test event
|
||||||
EVENT_TRIGGER_TEST = 128,
|
EVENT_TRIGGER_TEST = 128,
|
||||||
PING_WITH_DATA = 129,
|
|
||||||
//! [EXPORT] : [COMMAND] Report which reports the sent user data size
|
|
||||||
PING_WITH_DATA_REPORT_WITH_SIZE = 130
|
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit Service17Test(PsbParams params);
|
explicit Service17Test(PsbParams params);
|
||||||
|
@ -4,10 +4,9 @@
|
|||||||
#include "fsfw/objectmanager/ObjectManager.h"
|
#include "fsfw/objectmanager/ObjectManager.h"
|
||||||
#include "fsfw/pus/servicepackets/Service3Packets.h"
|
#include "fsfw/pus/servicepackets/Service3Packets.h"
|
||||||
|
|
||||||
Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId,
|
Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId)
|
||||||
uint32_t queueDepth, uint8_t numParallelCommands)
|
: CommandingServiceBase(objectId, apid, "PUS 3 HK", serviceId, NUM_OF_PARALLEL_COMMANDS,
|
||||||
: CommandingServiceBase(objectId, apid, "PUS 3 HK", serviceId, numParallelCommands,
|
COMMAND_TIMEOUT_SECONDS) {}
|
||||||
COMMAND_TIMEOUT_SECONDS, queueDepth) {}
|
|
||||||
|
|
||||||
Service3Housekeeping::~Service3Housekeeping() {}
|
Service3Housekeeping::~Service3Housekeeping() {}
|
||||||
|
|
||||||
@ -209,17 +208,17 @@ ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply,
|
|||||||
ReturnValue_t error = returnvalue::FAILED;
|
ReturnValue_t error = returnvalue::FAILED;
|
||||||
HousekeepingMessage::getHkRequestFailureReply(reply, &error);
|
HousekeepingMessage::getHkRequestFailureReply(reply, &error);
|
||||||
failureParameter2 = error;
|
failureParameter2 = error;
|
||||||
return returnvalue::FAILED;
|
return CommandingServiceBase::EXECUTION_COMPLETE;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "Service3Housekeeping::handleReply: Invalid reply with "
|
sif::warning << "Service3Housekeeping::handleReply: Invalid reply with "
|
||||||
<< "reply command " << command << std::endl;
|
<< "reply command " << command << "!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning(
|
sif::printWarning(
|
||||||
"Service3Housekeeping::handleReply: Invalid reply with "
|
"Service3Housekeeping::handleReply: Invalid reply with "
|
||||||
"reply command %hu\n",
|
"reply command %hu!\n",
|
||||||
command);
|
command);
|
||||||
#endif
|
#endif
|
||||||
return CommandingServiceBase::INVALID_REPLY;
|
return CommandingServiceBase::INVALID_REPLY;
|
||||||
@ -249,28 +248,19 @@ void Service3Housekeeping::handleUnrequestedReply(CommandMessage* reply) {
|
|||||||
case (HousekeepingMessage::HK_REQUEST_FAILURE): {
|
case (HousekeepingMessage::HK_REQUEST_FAILURE): {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case (CommandMessage::REPLY_REJECTED): {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::warning << "Service3Housekeeping::handleUnrequestedReply: Unexpected reply "
|
|
||||||
"rejected with error code"
|
|
||||||
<< reply->getParameter() << std::endl;
|
|
||||||
#else
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
sif::warning << "Service3Housekeeping::handleUnrequestedReply: Invalid reply with reply "
|
sif::warning << "Service3Housekeeping::handleUnrequestedReply: Invalid reply with reply "
|
||||||
"command "
|
"command "
|
||||||
<< command << "" << std::endl;
|
<< command << "!" << std::endl;
|
||||||
#else
|
#else
|
||||||
sif::printWarning(
|
sif::printWarning(
|
||||||
"Service3Housekeeping::handleUnrequestedReply: Invalid reply with "
|
"Service3Housekeeping::handleUnrequestedReply: Invalid reply with "
|
||||||
"reply command %hu\n",
|
"reply command %hu!\n",
|
||||||
command);
|
command);
|
||||||
#endif
|
#endif
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,7 +275,6 @@ void Service3Housekeeping::handleUnrequestedReply(CommandMessage* reply) {
|
|||||||
"Could not generate reply!\n");
|
"Could not generate reply!\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CommandingServiceBase::handleUnrequestedReply(reply);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueId_t Service3Housekeeping::getHkQueue() const { return commandQueue->getId(); }
|
MessageQueueId_t Service3Housekeeping::getHkQueue() const { return commandQueue->getId(); }
|
||||||
|
@ -28,8 +28,7 @@ class Service3Housekeeping : public CommandingServiceBase, public AcceptsHkPacke
|
|||||||
static constexpr uint8_t NUM_OF_PARALLEL_COMMANDS = 4;
|
static constexpr uint8_t NUM_OF_PARALLEL_COMMANDS = 4;
|
||||||
static constexpr uint16_t COMMAND_TIMEOUT_SECONDS = 60;
|
static constexpr uint16_t COMMAND_TIMEOUT_SECONDS = 60;
|
||||||
|
|
||||||
Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId, uint32_t queueDepth,
|
Service3Housekeeping(object_id_t objectId, uint16_t apid, uint8_t serviceId);
|
||||||
uint8_t numParallelCommands);
|
|
||||||
virtual ~Service3Housekeeping();
|
virtual ~Service3Housekeeping();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -13,10 +13,8 @@ Service5EventReporting::Service5EventReporting(PsbParams params, size_t maxNumbe
|
|||||||
storeHelper(params.apid),
|
storeHelper(params.apid),
|
||||||
tmHelper(params.serviceId, storeHelper, sendHelper),
|
tmHelper(params.serviceId, storeHelper, sendHelper),
|
||||||
maxNumberReportsPerCycle(maxNumberReportsPerCycle) {
|
maxNumberReportsPerCycle(maxNumberReportsPerCycle) {
|
||||||
auto mqArgs = MqArgs(getObjectId(), static_cast<void*>(this));
|
|
||||||
psbParams.name = "PUS 5 Event Reporting";
|
psbParams.name = "PUS 5 Event Reporting";
|
||||||
eventQueue = QueueFactory::instance()->createMessageQueue(
|
eventQueue = QueueFactory::instance()->createMessageQueue(messageQueueDepth);
|
||||||
messageQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Service5EventReporting::~Service5EventReporting() {
|
Service5EventReporting::~Service5EventReporting() {
|
||||||
@ -40,6 +38,9 @@ ReturnValue_t Service5EventReporting::performService() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||||
|
sif::warning << "Service5EventReporting::generateEventReport: Too many events" << std::endl;
|
||||||
|
#endif
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@
|
|||||||
class Service5EventReporting : public PusServiceBase {
|
class Service5EventReporting : public PusServiceBase {
|
||||||
public:
|
public:
|
||||||
Service5EventReporting(PsbParams params, size_t maxNumberReportsPerCycle = 10,
|
Service5EventReporting(PsbParams params, size_t maxNumberReportsPerCycle = 10,
|
||||||
uint32_t messageQueueDepth = 20);
|
uint32_t messageQueueDepth = 10);
|
||||||
~Service5EventReporting() override;
|
~Service5EventReporting() override;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
@ -9,11 +9,11 @@
|
|||||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||||
|
|
||||||
Service8FunctionManagement::Service8FunctionManagement(object_id_t objectId, uint16_t apid,
|
Service8FunctionManagement::Service8FunctionManagement(object_id_t objectId, uint16_t apid,
|
||||||
uint8_t serviceId, size_t queueDepth,
|
uint8_t serviceId,
|
||||||
uint8_t numParallelCommands,
|
uint8_t numParallelCommands,
|
||||||
uint16_t commandTimeoutSeconds)
|
uint16_t commandTimeoutSeconds)
|
||||||
: CommandingServiceBase(objectId, apid, "PUS 8 Functional Commanding", serviceId,
|
: CommandingServiceBase(objectId, apid, "PUS 8 Functional Commanding", serviceId,
|
||||||
numParallelCommands, commandTimeoutSeconds, queueDepth) {}
|
numParallelCommands, commandTimeoutSeconds) {}
|
||||||
|
|
||||||
Service8FunctionManagement::~Service8FunctionManagement() {}
|
Service8FunctionManagement::~Service8FunctionManagement() {}
|
||||||
|
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
class Service8FunctionManagement : public CommandingServiceBase {
|
class Service8FunctionManagement : public CommandingServiceBase {
|
||||||
public:
|
public:
|
||||||
Service8FunctionManagement(object_id_t objectId, uint16_t apid, uint8_t serviceId,
|
Service8FunctionManagement(object_id_t objectId, uint16_t apid, uint8_t serviceId,
|
||||||
size_t queueDepth, uint8_t numParallelCommands = 4,
|
uint8_t numParallelCommands = 4, uint16_t commandTimeoutSeconds = 60);
|
||||||
uint16_t commandTimeoutSeconds = 60);
|
|
||||||
~Service8FunctionManagement() override;
|
~Service8FunctionManagement() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_
|
#ifndef FSFW_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_
|
||||||
#define FSFW_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_
|
#define FSFW_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_
|
||||||
|
|
||||||
#include "fsfw/modes/ModeMessage.h"
|
#include "../../modes/ModeMessage.h"
|
||||||
#include "fsfw/serialize/SerialLinkedListAdapter.h"
|
#include "../../serialize/SerialLinkedListAdapter.h"
|
||||||
#include "fsfw/serialize/SerializeIF.h"
|
#include "../../serialize/SerializeIF.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Subservice 1, 2, 3, 4, 5
|
* @brief Subservice 1, 2, 3, 4, 5
|
||||||
|
@ -24,7 +24,7 @@ class EventReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 2, 3,
|
|||||||
parameter1(parameter1_),
|
parameter1(parameter1_),
|
||||||
parameter2(parameter2_) {}
|
parameter2(parameter2_) {}
|
||||||
|
|
||||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
SerializeIF::Endianness streamEndianness) const override {
|
SerializeIF::Endianness streamEndianness) const override {
|
||||||
ReturnValue_t result =
|
ReturnValue_t result =
|
||||||
SerializeAdapter::serialize(&reportId, buffer, size, maxSize, streamEndianness);
|
SerializeAdapter::serialize(&reportId, buffer, size, maxSize, streamEndianness);
|
||||||
@ -46,7 +46,7 @@ class EventReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 2, 3,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_t getSerializedSize() const override {
|
size_t getSerializedSize() const override {
|
||||||
uint32_t size = 0;
|
uint32_t size = 0;
|
||||||
size += SerializeAdapter::getSerializedSize(&reportId);
|
size += SerializeAdapter::getSerializedSize(&reportId);
|
||||||
size += SerializeAdapter::getSerializedSize(&objectId);
|
size += SerializeAdapter::getSerializedSize(&objectId);
|
||||||
@ -55,7 +55,7 @@ class EventReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 2, 3,
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
SerializeIF::Endianness streamEndianness) override {
|
SerializeIF::Endianness streamEndianness) override {
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,10 @@ class SerialArrayListAdapter : public SerializeIF {
|
|||||||
public:
|
public:
|
||||||
SerialArrayListAdapter(ArrayList<T, count_t>* adaptee) : adaptee(adaptee) {}
|
SerialArrayListAdapter(ArrayList<T, count_t>* adaptee) : adaptee(adaptee) {}
|
||||||
|
|
||||||
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
using SerializeIF::serialize; // we overload this function as well, so this is needed to uncofuse
|
||||||
Endianness streamEndianness) const {
|
// the compiler
|
||||||
|
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
|
||||||
|
Endianness streamEndianness) const override {
|
||||||
return serialize(adaptee, buffer, size, maxSize, streamEndianness);
|
return serialize(adaptee, buffer, size, maxSize, streamEndianness);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -34,7 +36,7 @@ class SerialArrayListAdapter : public SerializeIF {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual size_t getSerializedSize() const { return getSerializedSize(adaptee); }
|
size_t getSerializedSize() const override { return getSerializedSize(adaptee); }
|
||||||
|
|
||||||
static uint32_t getSerializedSize(const ArrayList<T, count_t>* list) {
|
static uint32_t getSerializedSize(const ArrayList<T, count_t>* list) {
|
||||||
uint32_t printSize = sizeof(count_t);
|
uint32_t printSize = sizeof(count_t);
|
||||||
@ -47,8 +49,10 @@ class SerialArrayListAdapter : public SerializeIF {
|
|||||||
return printSize;
|
return printSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
using SerializeIF::deSerialize; // we overload this function as well, so this is needed to
|
||||||
Endianness streamEndianness) {
|
// uncofuse the compiler
|
||||||
|
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
|
||||||
|
Endianness streamEndianness) override {
|
||||||
return deSerialize(adaptee, buffer, size, streamEndianness);
|
return deSerialize(adaptee, buffer, size, streamEndianness);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user