some fixes

This commit is contained in:
Robin Müller 2022-07-21 13:48:58 +02:00
parent d8b6cb39ac
commit e5ee96259d
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
22 changed files with 195 additions and 174 deletions

View File

@ -3,7 +3,7 @@
#include "fsfw/FSFW.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/objectmanager/SystemObject.h"
#include "fsfw/tmtcservices/sendAndStoreHelper.h"
#include "fsfw/tmtcservices/tmHelpers.h"
Service17Test::Service17Test(object_id_t objectId, uint16_t apid, uint8_t serviceId)
: PusServiceBase(objectId, apid, serviceId),

View File

@ -6,7 +6,7 @@
#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
#include "fsfw/tmtcservices/PusVerificationReport.h"
#include "fsfw/tmtcservices/sendAndStoreHelper.h"
#include "fsfw/tmtcservices/tmHelpers.h"
Service1TelecommandVerification::Service1TelecommandVerification(object_id_t objectId,
uint16_t apid, uint8_t serviceId,

View File

@ -6,7 +6,7 @@
#include "fsfw/pus/servicepackets/Service5Packets.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h"
#include "fsfw/tmtcservices/sendAndStoreHelper.h"
#include "fsfw/tmtcservices/tmHelpers.h"
Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t apid,
uint8_t serviceId, size_t maxNumberReportsPerCycle,

View File

@ -50,7 +50,7 @@ class FailureReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (failureSubtype == tc_verification::PROGRESS_FAILURE) {
if (failureSubtype == tcverif::PROGRESS_FAILURE) {
result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
@ -73,7 +73,7 @@ class FailureReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6
size_t size = 0;
size += SerializeAdapter::getSerializedSize(&packetId);
size += sizeof(packetSequenceControl);
if (failureSubtype == tc_verification::PROGRESS_FAILURE) {
if (failureSubtype == tcverif::PROGRESS_FAILURE) {
size += SerializeAdapter::getSerializedSize(&stepNumber);
}
size += SerializeAdapter::getSerializedSize(&errorCode);
@ -130,7 +130,7 @@ class SuccessReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (subtype == tc_verification::PROGRESS_SUCCESS) {
if (subtype == tcverif::PROGRESS_SUCCESS) {
result = SerializeAdapter::serialize(&stepNumber, buffer, size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
@ -143,7 +143,7 @@ class SuccessReport : public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5
size_t size = 0;
size += SerializeAdapter::getSerializedSize(&packetId);
size += sizeof(packetSequenceControl);
if (subtype == tc_verification::PROGRESS_SUCCESS) {
if (subtype == tcverif::PROGRESS_SUCCESS) {
size += SerializeAdapter::getSerializedSize(&stepNumber);
}
return size;

View File

@ -121,13 +121,13 @@ ReturnValue_t PusDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
tcStatus = queueStatus;
}
if (tcStatus != RETURN_OK) {
this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE, &reader, tcStatus);
this->verifyChannel.sendFailureReport(tcverif::ACCEPTANCE_FAILURE, &reader, tcStatus);
// A failed packet is deleted immediately after reporting,
// otherwise it will block memory.
store->deleteData(currentMessage.getStorageId());
return RETURN_FAILED;
} else {
this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS, &reader);
this->verifyChannel.sendSuccessReport(tcverif::ACCEPTANCE_SUCCESS, &reader);
return RETURN_OK;
}
}

View File

@ -1,6 +1,7 @@
#ifndef FSFW_TMTCPACKET_PUS_TC_H_
#define FSFW_TMTCPACKET_PUS_TC_H_
#include "tc/TcPacketPus.h"
#include "tc/PusTcCreator.h"
#include "tc/PusTcReader.h"
#endif /* FSFW_TMTCPACKET_PUS_TC_H_ */

View File

@ -11,7 +11,11 @@ PusTcReader::PusTcReader(const uint8_t* data, size_t size) { setReadOnlyData(dat
PusTcReader::~PusTcReader() = default;
ReturnValue_t PusTcReader::parseData() {
ReturnValue_t PusTcReader::parseDataWithCrcCheck() { return parseData(true); }
ReturnValue_t PusTcReader::parseDataWithoutCrcCheck() { return parseData(false); }
ReturnValue_t PusTcReader::parseData(bool withCrc) {
if (pointers.spHeaderStart == nullptr or spReader.isNull()) {
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -31,11 +35,13 @@ ReturnValue_t PusTcReader::parseData() {
pointers.userDataStart = pointers.spHeaderStart + currentOffset;
appDataSize = spReader.getFullPacketLen() - currentOffset - sizeof(ecss::PusChecksumT);
pointers.crcStart = pointers.userDataStart + appDataSize;
if (withCrc) {
uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen());
if (crc16 != 0) {
// Checksum failure
return PusIF::INVALID_CRC_16;
}
}
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -34,7 +34,9 @@ class PusTcReader : public PusTcIF,
*/
PusTcReader(const uint8_t* setData, size_t size);
ReturnValue_t parseData();
ReturnValue_t parseDataWithCrcCheck();
ReturnValue_t parseDataWithoutCrcCheck();
/**
* This is the empty default destructor.
*/
@ -70,6 +72,7 @@ class PusTcReader : public PusTcIF,
* @param p_data A pointer to another PUS Telecommand Packet.
*/
ReturnValue_t setData(uint8_t* pData, size_t size, void* args) override;
ReturnValue_t parseData(bool withCrc);
SpacePacketReader spReader;
ecss::PusPointers pointers{};

View File

@ -11,44 +11,10 @@ PusTmReader::PusTmReader(TimeReaderIF *timeReader, const uint8_t *data, size_t s
setReadOnlyData(data, size);
}
ReturnValue_t PusTmReader::parseData() {
// Time reader is required to read the time stamp length at run-time
if (pointers.spHeaderStart == nullptr or spReader.isNull() or timeReader == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t result = spReader.checkSize();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (spReader.getBufSize() < PusTmIF::MIN_SIZE) {
return SerializeIF::STREAM_TOO_SHORT;
}
ReturnValue_t PusTmReader::parseDataWithCrcCheck() { return parseData(true); }
ReturnValue_t PusTmReader::parseDataWithoutCrcCheck() { return parseData(false); }
size_t currentOffset = SpacePacketReader::getHeaderLen();
pointers.secHeaderStart = pointers.spHeaderStart + currentOffset;
currentOffset += PusTmIF::MIN_SEC_HEADER_LEN;
size_t minTimestampLen = spReader.getBufSize() - currentOffset;
result = timeReader->readTimeStamp(pointers.secHeaderStart + PusTmIF::MIN_SEC_HEADER_LEN,
minTimestampLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
size_t timestampLen = timeReader->getTimestampLen();
if (currentOffset + timestampLen > spReader.getBufSize()) {
return SerializeIF::STREAM_TOO_SHORT;
}
currentOffset += timestampLen;
pointers.userDataStart = pointers.spHeaderStart + currentOffset;
sourceDataLen = spReader.getFullPacketLen() - currentOffset - sizeof(ecss::PusChecksumT);
currentOffset += sourceDataLen;
pointers.crcStart = pointers.spHeaderStart + currentOffset;
uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen());
if (crc16 != 0) {
// Checksum failure
return PusIF::INVALID_CRC_16;
}
return HasReturnvaluesIF::RETURN_OK;
}
const uint8_t *PusTmReader::getFullData() { return spReader.getFullData(); }
ReturnValue_t PusTmReader::setReadOnlyData(const uint8_t *data, size_t size) {
@ -81,3 +47,44 @@ uint16_t PusTmReader::getDestId() {
void PusTmReader::setTimeReader(TimeReaderIF *timeReader_) { timeReader = timeReader_; }
TimeReaderIF *PusTmReader::getTimeReader() { return timeReader; }
ReturnValue_t PusTmReader::parseData(bool crcCheck) {
// Time reader is required to read the time stamp length at run-time
if (pointers.spHeaderStart == nullptr or spReader.isNull() or timeReader == nullptr) {
return HasReturnvaluesIF::RETURN_FAILED;
}
ReturnValue_t result = spReader.checkSize();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (spReader.getBufSize() < PusTmIF::MIN_SIZE) {
return SerializeIF::STREAM_TOO_SHORT;
}
size_t currentOffset = SpacePacketReader::getHeaderLen();
pointers.secHeaderStart = pointers.spHeaderStart + currentOffset;
currentOffset += PusTmIF::MIN_SEC_HEADER_LEN;
size_t minTimestampLen = spReader.getBufSize() - currentOffset;
result = timeReader->readTimeStamp(pointers.secHeaderStart + PusTmIF::MIN_SEC_HEADER_LEN,
minTimestampLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
size_t timestampLen = timeReader->getTimestampLen();
if (currentOffset + timestampLen > spReader.getBufSize()) {
return SerializeIF::STREAM_TOO_SHORT;
}
currentOffset += timestampLen;
pointers.userDataStart = pointers.spHeaderStart + currentOffset;
sourceDataLen = spReader.getFullPacketLen() - currentOffset - sizeof(ecss::PusChecksumT);
currentOffset += sourceDataLen;
pointers.crcStart = pointers.spHeaderStart + currentOffset;
if (crcCheck) {
uint16_t crc16 = CRC::crc16ccitt(spReader.getFullData(), getFullPacketLen());
if (crc16 != 0) {
// Checksum failure
return PusIF::INVALID_CRC_16;
}
}
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -17,7 +17,8 @@ class PusTmReader : public PusTmIF,
PusTmReader(const uint8_t* data, size_t size);
PusTmReader(TimeReaderIF* timeReader, const uint8_t* data, size_t size);
ReturnValue_t parseData();
ReturnValue_t parseDataWithoutCrcCheck();
ReturnValue_t parseDataWithCrcCheck();
const uint8_t* getFullData() override;
void setTimeReader(TimeReaderIF* timeReader);
@ -37,7 +38,7 @@ class PusTmReader : public PusTmIF,
private:
ReturnValue_t setData(uint8_t* dataPtr, size_t size, void* args) override;
ReturnValue_t parseData(bool crcCheck);
SpacePacketReader spReader{};
size_t sourceDataLen = 0;
TimeReaderIF* timeReader{};

View File

@ -8,4 +8,6 @@ target_sources(
VerificationReporter.cpp
SpacePacketParser.cpp
TmStoreHelper.cpp
TmSendHelper.cpp)
TmSendHelper.cpp
tcHelpers.cpp
tmHelpers.cpp)

View File

@ -8,7 +8,8 @@
#include "fsfw/tmtcpacket/pus/tm.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
#include "fsfw/tmtcservices/sendAndStoreHelper.h"
#include "fsfw/tmtcservices/tcHelpers.h"
#include "fsfw/tmtcservices/tmHelpers.h"
object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT;
@ -176,12 +177,12 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
default:
if (isStep) {
verificationReporter.sendFailureReport(
tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, result,
++iter->second.step, failureParameter1, failureParameter2);
tcverif::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
iter->second.tcInfo.tcSequenceControl, result, ++iter->second.step, failureParameter1,
failureParameter2);
} else {
verificationReporter.sendFailureReport(
tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
tcverif::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, result, 0,
failureParameter1, failureParameter2);
}
@ -208,28 +209,27 @@ void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result, Comma
if (sendResult == RETURN_OK) {
if (isStep and result != NO_STEP_MESSAGE) {
verificationReporter.sendSuccessReport(
tc_verification::PROGRESS_SUCCESS, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
++iter->second.step);
tcverif::PROGRESS_SUCCESS, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
iter->second.tcInfo.tcSequenceControl, ++iter->second.step);
} else {
verificationReporter.sendSuccessReport(
tc_verification::COMPLETION_SUCCESS, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, 0);
tcverif::COMPLETION_SUCCESS, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
iter->second.tcInfo.tcSequenceControl, 0);
checkAndExecuteFifo(iter);
}
} else {
if (isStep) {
nextCommand->clearCommandMessage();
verificationReporter.sendFailureReport(
tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, sendResult,
++iter->second.step, failureParameter1, failureParameter2);
tcverif::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
iter->second.tcInfo.tcSequenceControl, sendResult, ++iter->second.step, failureParameter1,
failureParameter2);
} else {
nextCommand->clearCommandMessage();
verificationReporter.sendFailureReport(
tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, sendResult, 0,
failureParameter1, failureParameter2);
tcverif::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
iter->second.tcInfo.tcSequenceControl, sendResult, 0, failureParameter1,
failureParameter2);
}
failureParameter1 = 0;
failureParameter2 = 0;
@ -245,35 +245,22 @@ void CommandingServiceBase::handleRequestQueue() {
object_id_t objectId;
for (result = requestQueue->receiveMessage(&message); result == RETURN_OK;
result = requestQueue->receiveMessage(&message)) {
address = message.getStorageId();
const uint8_t* dataPtr;
size_t dataLen = 0;
result = tcStore->getData(message.getStorageId(), &dataPtr, &dataLen);
result = setUpTcReader(message.getStorageId());
if (result != HasReturnvaluesIF::RETURN_OK) {
// TODO: Warning?
rejectPacket(tcverif::START_FAILURE, address, &tcReader, result);
continue;
}
result = tcReader.setReadOnlyData(dataPtr, dataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
// TODO: Warning?
continue;
}
result = tcReader.parseData();
if (result != HasReturnvaluesIF::RETURN_OK) {
// TODO: Warning?
continue;
}
if ((tcReader.getSubService() == 0) or
(isValidSubservice(tcReader.getSubService()) != RETURN_OK)) {
rejectPacket(tc_verification::START_FAILURE, address, &tcReader, INVALID_SUBSERVICE);
rejectPacket(tcverif::START_FAILURE, address, &tcReader, INVALID_SUBSERVICE);
continue;
}
result = getMessageQueueAndObject(tcReader.getSubService(), tcReader.getUserData(),
tcReader.getUserDataLen(), &queue, &objectId);
if (result != HasReturnvaluesIF::RETURN_OK) {
rejectPacket(tc_verification::START_FAILURE, address, &tcReader, result);
rejectPacket(tcverif::START_FAILURE, address, &tcReader, result);
continue;
}
@ -284,16 +271,16 @@ void CommandingServiceBase::handleRequestQueue() {
if (iter != commandMap.end()) {
result = iter->second.fifo.insert(address);
if (result != RETURN_OK) {
rejectPacket(tc_verification::START_FAILURE, address, &tcReader, OBJECT_BUSY);
rejectPacket(tcverif::START_FAILURE, address, &tcReader, OBJECT_BUSY);
}
} else {
CommandInfo newInfo; // Info will be set by startExecution if neccessary
newInfo.objectId = objectId;
result = commandMap.insert(queue, newInfo, &iter);
if (result != RETURN_OK) {
rejectPacket(tc_verification::START_FAILURE, address, &tcReader, BUSY);
rejectPacket(tcverif::START_FAILURE, address, &tcReader, BUSY);
} else {
startExecution(address, &tcReader, iter);
startExecution(address, iter);
}
}
}
@ -332,17 +319,12 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice, SerializeI
return result;
}
void CommandingServiceBase::startExecution(store_address_t storeId, PusTcReader* storedPacket,
CommandMapIter iter) {
void CommandingServiceBase::startExecution(store_address_t storeId, CommandMapIter iter) {
ReturnValue_t result = RETURN_OK;
CommandMessage command;
if (storedPacket == nullptr) {
return;
}
iter->second.subservice = storedPacket->getSubService();
result =
prepareCommand(&command, iter->second.subservice, storedPacket->getUserData(),
storedPacket->getUserDataLen(), &iter->second.state, iter->second.objectId);
iter->second.subservice = tcReader.getSubService();
result = prepareCommand(&command, iter->second.subservice, tcReader.getUserData(),
tcReader.getUserDataLen(), &iter->second.state, iter->second.objectId);
ReturnValue_t sendResult = RETURN_OK;
switch (result) {
@ -353,15 +335,15 @@ void CommandingServiceBase::startExecution(store_address_t storeId, PusTcReader*
if (sendResult == RETURN_OK) {
Clock::getUptime(&iter->second.uptimeOfStart);
iter->second.step = 0;
iter->second.subservice = storedPacket->getSubService();
iter->second.subservice = tcReader.getSubService();
iter->second.command = command.getCommand();
iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags();
iter->second.tcInfo.tcPacketId = storedPacket->getPacketIdRaw();
iter->second.tcInfo.tcSequenceControl = storedPacket->getPacketSeqCtrlRaw();
acceptPacket(tc_verification::START_SUCCESS, storeId, storedPacket);
iter->second.tcInfo.ackFlags = tcReader.getAcknowledgeFlags();
iter->second.tcInfo.tcPacketId = tcReader.getPacketIdRaw();
iter->second.tcInfo.tcSequenceControl = tcReader.getPacketSeqCtrlRaw();
acceptPacket(tcverif::START_SUCCESS, storeId, &tcReader);
} else {
command.clearCommandMessage();
rejectPacket(tc_verification::START_FAILURE, storeId, storedPacket, sendResult);
rejectPacket(tcverif::START_FAILURE, storeId, &tcReader, sendResult);
checkAndExecuteFifo(iter);
}
break;
@ -371,17 +353,17 @@ void CommandingServiceBase::startExecution(store_address_t storeId, PusTcReader*
sendResult = commandQueue->sendMessage(iter.value->first, &command);
}
if (sendResult == RETURN_OK) {
verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS, storedPacket);
acceptPacket(tc_verification::COMPLETION_SUCCESS, storeId, storedPacket);
verificationReporter.sendSuccessReport(tcverif::START_SUCCESS, &tcReader);
acceptPacket(tcverif::COMPLETION_SUCCESS, storeId, &tcReader);
checkAndExecuteFifo(iter);
} else {
command.clearCommandMessage();
rejectPacket(tc_verification::START_FAILURE, storeId, storedPacket, sendResult);
rejectPacket(tcverif::START_FAILURE, storeId, &tcReader, sendResult);
checkAndExecuteFifo(iter);
}
break;
default:
rejectPacket(tc_verification::START_FAILURE, storeId, storedPacket, result);
rejectPacket(tcverif::START_FAILURE, storeId, &tcReader, result);
checkAndExecuteFifo(iter);
break;
}
@ -404,23 +386,12 @@ void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) {
if (iter->second.fifo.retrieve(&address) != RETURN_OK) {
commandMap.erase(&iter);
} else {
const uint8_t* dataPtr;
size_t dataLen = 0;
ReturnValue_t result = tcStore->getData(address, &dataPtr, &dataLen);
ReturnValue_t result = setUpTcReader(address);
if (result == HasReturnvaluesIF::RETURN_OK) {
result = tcReader.setReadOnlyData(dataPtr, dataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
// TODO: Warning?
return;
}
result = tcReader.parseData();
if (result != HasReturnvaluesIF::RETURN_OK) {
// TODO: Warning?
return;
}
startExecution(address, &tcReader, iter);
startExecution(address, iter);
} else {
// TODO: Warning?
rejectPacket(tcverif::START_FAILURE, address, &tcReader, result);
}
}
}
@ -440,8 +411,8 @@ void CommandingServiceBase::checkTimeout() {
for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) {
if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) {
verificationReporter.sendFailureReport(
tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl, TIMEOUT);
tcverif::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
iter->second.tcInfo.tcSequenceControl, TIMEOUT);
checkAndExecuteFifo(iter);
}
}
@ -452,3 +423,6 @@ void CommandingServiceBase::setTaskIF(PeriodicTaskIF* task_) { executingTask = t
void CommandingServiceBase::setCustomTmStore(StorageManagerIF* store) {
tmStoreHelper.setTmStore(store);
}
ReturnValue_t CommandingServiceBase::setUpTcReader(store_address_t storeId) {
return tc::prepareTcReader(tcStore, storeId, tcReader);
}

View File

@ -350,12 +350,14 @@ class CommandingServiceBase : public SystemObject,
*/
void handleRequestQueue();
ReturnValue_t setUpTcReader(store_address_t storeId);
void rejectPacket(uint8_t reportId, store_address_t tcStoreId, PusTcReader* tcPacket,
ReturnValue_t errorCode);
void acceptPacket(uint8_t reportId, store_address_t tcStoreId, PusTcReader* tcPacket);
void startExecution(store_address_t storeId, PusTcReader* storedPacket, CommandMapIter iter);
void startExecution(store_address_t storeId, CommandMapIter iter);
void handleCommandMessage(CommandMessage* reply);
void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter,

View File

@ -7,6 +7,7 @@
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
#include "fsfw/tmtcservices/PusVerificationReport.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
#include "fsfw/tmtcservices/tcHelpers.h"
object_id_t PusServiceBase::packetSource = 0;
object_id_t PusServiceBase::packetDestination = 0;
@ -62,34 +63,20 @@ void PusServiceBase::handleRequestQueue() {
#endif
break;
}
const uint8_t* dataPtr;
size_t dataLen = 0;
result = ipcStore->getData(message.getStorageId(), &dataPtr, &dataLen);
result = tc::prepareTcReader(tcStore, message.getStorageId(), currentPacket);
if (result != HasReturnvaluesIF::RETURN_OK) {
// TODO: Warning?
continue;
}
result = currentPacket.setReadOnlyData(dataPtr, dataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
// TODO: Warning?
continue;
}
result = currentPacket.parseData();
if (result != HasReturnvaluesIF::RETURN_OK) {
// TODO: Warning?
this->verifyReporter.sendFailureReport(tcverif::START_FAILURE, &this->currentPacket, result,
0, errorParameter1, errorParameter2);
continue;
}
result = this->handleRequest(currentPacket.getSubService());
if (result == RETURN_OK) {
this->verifyReporter.sendSuccessReport(tc_verification::COMPLETION_SUCCESS,
&this->currentPacket);
this->verifyReporter.sendSuccessReport(tcverif::COMPLETION_SUCCESS, &this->currentPacket);
} else {
this->verifyReporter.sendFailureReport(tc_verification::COMPLETION_FAILURE,
&this->currentPacket, result, 0, errorParameter1,
errorParameter2);
this->verifyReporter.sendFailureReport(tcverif::COMPLETION_FAILURE, &this->currentPacket,
result, 0, errorParameter1, errorParameter2);
}
ipcStore->deleteData(message.getStorageId());
tcStore->deleteData(message.getStorageId());
errorParameter1 = 0;
errorParameter2 = 0;
}
@ -116,9 +103,9 @@ ReturnValue_t PusServiceBase::initialize() {
}
this->requestQueue->setDefaultDestination(destService->getReportReceptionQueue());
distributor->registerService(this);
if (ipcStore == nullptr) {
ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (ipcStore == nullptr) {
if (tcStore == nullptr) {
tcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
if (tcStore == nullptr) {
return ObjectManagerIF::CHILD_INIT_FAILED;
}
}
@ -132,7 +119,7 @@ ReturnValue_t PusServiceBase::initializeAfterTaskCreation() {
return HasReturnvaluesIF::RETURN_OK;
}
void PusServiceBase::setCustomIpcStore(StorageManagerIF* ipcStore_) { ipcStore = ipcStore_; }
void PusServiceBase::setCustomTcStore(StorageManagerIF* tcStore_) { tcStore = tcStore_; }
void PusServiceBase::setCustomErrorReporter(InternalErrorReporterIF* errReporter_) {
errReporter = errReporter_;

View File

@ -59,7 +59,7 @@ class PusServiceBase : public ExecutableObjectIF,
*/
~PusServiceBase() override;
void setCustomIpcStore(StorageManagerIF* ipcStore);
void setCustomTcStore(StorageManagerIF* tcStore);
void setCustomErrorReporter(InternalErrorReporterIF* errReporter);
void initializeTmSendHelper(TmSendHelper& tmSendHelper);
@ -153,7 +153,7 @@ class PusServiceBase : public ExecutableObjectIF,
* It is deleted after handleRequest was executed.
*/
PusTcReader currentPacket;
StorageManagerIF* ipcStore = nullptr;
StorageManagerIF* tcStore = nullptr;
InternalErrorReporterIF* errReporter = nullptr;
static object_id_t packetSource;

View File

@ -1,9 +1,11 @@
#ifndef VERIFICATIONCODES_H_
#define VERIFICATIONCODES_H_
namespace tc_verification {
#include <cstdint>
enum verification_flags {
namespace tcverif {
enum VerifFlags : uint8_t {
NONE = 0b0000,
ACCEPTANCE = 0b0001,
START = 0b0010,
@ -11,7 +13,7 @@ enum verification_flags {
COMPLETION = 0b1000
};
enum subservice_ids {
enum Subservices : uint8_t {
NOTHING_TO_REPORT = 0,
ACCEPTANCE_SUCCESS = 1,
ACCEPTANCE_FAILURE = 2,
@ -23,6 +25,6 @@ enum subservice_ids {
COMPLETION_FAILURE = 8,
};
} // namespace tc_verification
} // namespace tcverif
#endif /* VERIFICATIONCODES_H_ */

View File

@ -51,7 +51,7 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id, uint8_t ackF
}
void VerificationReporter::sendFailureReport(uint8_t report_id, PusTcReader* correspondingTc,
ReturnValue_t error_code, uint8_t step,
ReturnValue_t errorCode, uint8_t step,
uint32_t parameter1, uint32_t parameter2) {
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
this->initialize();
@ -61,7 +61,7 @@ void VerificationReporter::sendFailureReport(uint8_t report_id, PusTcReader* cor
}
PusVerificationMessage message(
report_id, correspondingTc->getAcknowledgeFlags(), correspondingTc->getPacketIdRaw(),
correspondingTc->getPacketSeqCtrlRaw(), error_code, step, parameter1, parameter2);
correspondingTc->getPacketSeqCtrlRaw(), errorCode, step, parameter1, parameter2);
ReturnValue_t status = MessageQueueSenderIF::sendMessage(acknowledgeQueue, &message);
if (status != HasReturnvaluesIF::RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1

View File

@ -27,15 +27,17 @@ class VerificationReporter {
VerificationReporter();
virtual ~VerificationReporter();
// TODO: The API is a little bit bloated. It might be better to group all the parameters
// into a dedicated struct
void sendSuccessReport(uint8_t set_report_id, PusTcReader* correspondingTc, uint8_t set_step = 0);
void sendSuccessReport(uint8_t set_report_id, uint8_t ackFlags, uint16_t tcPacketId,
uint16_t tcSequenceControl, uint8_t set_step = 0);
void sendFailureReport(uint8_t report_id, PusTcReader* correspondingTc,
ReturnValue_t error_code = 0, uint8_t step = 0, uint32_t parameter1 = 0,
ReturnValue_t errorCode = 0, uint8_t step = 0, uint32_t parameter1 = 0,
uint32_t parameter2 = 0);
void sendFailureReport(uint8_t report_id, uint8_t ackFlags, uint16_t tcPacketId,
uint16_t tcSequenceControl, ReturnValue_t error_code = 0, uint8_t step = 0,
uint16_t tcSequenceControl, ReturnValue_t errorCode = 0, uint8_t step = 0,
uint32_t parameter1 = 0, uint32_t parameter2 = 0);
void initialize();

View File

@ -0,0 +1,16 @@
#include "tcHelpers.h"
ReturnValue_t tc::prepareTcReader(StorageManagerIF *tcStore, store_address_t storeId,
PusTcReader &tcReader) {
const uint8_t *dataPtr;
size_t dataLen = 0;
ReturnValue_t result = tcStore->getData(storeId, &dataPtr, &dataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = tcReader.setReadOnlyData(dataPtr, dataLen);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return tcReader.parseDataWithoutCrcCheck();
}

View File

@ -0,0 +1,15 @@
#ifndef FSFW_TMTCSERVICES_TCHELPERS_H
#define FSFW_TMTCSERVICES_TCHELPERS_H
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/tmtcpacket/pus/tc.h"
namespace tc {
ReturnValue_t prepareTcReader(StorageManagerIF* tcStore, store_address_t storeId,
PusTcReader& tcReader);
} // namespace tc
#endif // FSFW_TMTCSERVICES_TCHELPERS_H

View File

@ -0,0 +1,10 @@
#include "tmHelpers.h"
ReturnValue_t tm::storeAndSendTmPacket(TmStoreHelper &storeHelper, TmSendHelper &sendHelper) {
storeHelper.addPacketToStore();
ReturnValue_t result = sendHelper.sendPacket(storeHelper.getCurrentAddr());
if (result != HasReturnvaluesIF::RETURN_OK) {
storeHelper.deletePacket();
}
return result;
}

View File

@ -1,19 +1,12 @@
#ifndef FSFW_TMTCSERVICES_SENDANDSTOREHELPER_H
#define FSFW_TMTCSERVICES_SENDANDSTOREHELPER_H
#ifndef FSFW_TMTCSERVICES_TMHELPERS_H_
#define FSFW_TMTCSERVICES_TMHELPERS_H_
#include "TmSendHelper.h"
#include "TmStoreHelper.h"
namespace tm {
ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper) {
storeHelper.addPacketToStore();
ReturnValue_t result = sendHelper.sendPacket(storeHelper.getCurrentAddr());
if (result != HasReturnvaluesIF::RETURN_OK) {
storeHelper.deletePacket();
}
return result;
}
ReturnValue_t storeAndSendTmPacket(TmStoreHelper& storeHelper, TmSendHelper& sendHelper);
class SourceDataWithObjectIdPrefix : public SerializeIF {
public:
@ -51,4 +44,4 @@ class SourceDataWithObjectIdPrefix : public SerializeIF {
} // namespace tm
#endif // FSFW_TMTCSERVICES_SENDANDSTOREHELPER_H
#endif // FSFW_TMTCSERVICES_TMHELPERS_H_