several bugfixes amd improvements
This commit is contained in:
parent
5e3f40a2c1
commit
33e7cca23c
@ -144,8 +144,11 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
||||
case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES):
|
||||
//return generateSetStructurePacket(message->getSid());
|
||||
case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT):
|
||||
return generateHousekeepingPacket(HousekeepingMessage::getSid(message),
|
||||
false, true);
|
||||
case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT):
|
||||
//return generateHousekeepingPacket(message->getSid());
|
||||
return generateHousekeepingPacket(HousekeepingMessage::getSid(message),
|
||||
true, true);
|
||||
default:
|
||||
return CommandMessageIF::UNKNOWN_COMMAND;
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ ReturnValue_t Service3Housekeeping::isValidSubservice(uint8_t subservice) {
|
||||
ReturnValue_t Service3Housekeeping::getMessageQueueAndObject(uint8_t subservice,
|
||||
const uint8_t *tcData, size_t tcDataLen,
|
||||
MessageQueueId_t *id, object_id_t *objectId) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
ReturnValue_t result = checkAndAcquireTargetID(objectId,tcData,tcDataLen);
|
||||
if(result != RETURN_OK) {
|
||||
return result;
|
||||
@ -55,7 +54,7 @@ ReturnValue_t Service3Housekeeping::checkAndAcquireTargetID(
|
||||
|
||||
ReturnValue_t Service3Housekeeping::checkInterfaceAndAcquireMessageQueue(
|
||||
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
|
||||
// check OwnsLocalDataPoolIF property of target
|
||||
// check HasLocalDataPoolIF property of target
|
||||
HasLocalDataPoolIF* possibleTarget =
|
||||
objectManager->get<HasLocalDataPoolIF>(*objectId);
|
||||
if(possibleTarget == nullptr){
|
||||
@ -71,33 +70,35 @@ ReturnValue_t Service3Housekeeping::prepareCommand(CommandMessage* message,
|
||||
uint32_t *state, object_id_t objectId) {
|
||||
switch(static_cast<Subservice>(subservice)) {
|
||||
case Subservice::ENABLE_PERIODIC_HK_REPORT_GENERATION:
|
||||
return prepareReportingTogglingCommand(message, true, false,
|
||||
return prepareReportingTogglingCommand(message, objectId, true, false,
|
||||
tcData, tcDataLen);
|
||||
case Subservice::DISABLE_PERIODIC_HK_REPORT_GENERATION:
|
||||
return prepareReportingTogglingCommand(message, false, false,
|
||||
return prepareReportingTogglingCommand(message, objectId, false, false,
|
||||
tcData, tcDataLen);
|
||||
case Subservice::ENABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION:
|
||||
return prepareReportingTogglingCommand(message, true, true,
|
||||
return prepareReportingTogglingCommand(message, objectId, true, true,
|
||||
tcData, tcDataLen);
|
||||
case Subservice::DISABLE_PERIODIC_DIAGNOSTICS_REPORT_GENERATION:
|
||||
return prepareReportingTogglingCommand(message, false, true,
|
||||
return prepareReportingTogglingCommand(message, objectId, false, true,
|
||||
tcData, tcDataLen);
|
||||
case Subservice::REPORT_HK_REPORT_STRUCTURES:
|
||||
return prepareStructureReportingCommand(message, false, tcData,
|
||||
return prepareStructureReportingCommand(message, objectId, false, tcData,
|
||||
tcDataLen);
|
||||
case Subservice::REPORT_DIAGNOSTICS_REPORT_STRUCTURES:
|
||||
return prepareStructureReportingCommand(message, true, tcData,
|
||||
return prepareStructureReportingCommand(message, objectId, true, tcData,
|
||||
tcDataLen);
|
||||
case Subservice::GENERATE_ONE_PARAMETER_REPORT:
|
||||
return prepareOneShotReportCommand(message, false, tcData, tcDataLen);
|
||||
return prepareOneShotReportCommand(message, objectId, false,
|
||||
tcData, tcDataLen);
|
||||
case Subservice::GENERATE_ONE_DIAGNOSTICS_REPORT:
|
||||
return prepareOneShotReportCommand(message, true, tcData, tcDataLen);
|
||||
return prepareOneShotReportCommand(message, objectId, true,
|
||||
tcData, tcDataLen);
|
||||
case Subservice::MODIFY_PARAMETER_REPORT_COLLECTION_INTERVAL:
|
||||
return prepareCollectionIntervalModificationCommand(message, false,
|
||||
tcData, tcDataLen);
|
||||
return prepareCollectionIntervalModificationCommand(message, objectId,
|
||||
false, tcData, tcDataLen);
|
||||
case Subservice::MODIFY_DIAGNOSTICS_REPORT_COLLECTION_INTERVAL:
|
||||
return prepareCollectionIntervalModificationCommand(message, true,
|
||||
tcData, tcDataLen);
|
||||
return prepareCollectionIntervalModificationCommand(message, objectId,
|
||||
true, tcData, tcDataLen);
|
||||
case Subservice::HK_DEFINITIONS_REPORT:
|
||||
case Subservice::DIAGNOSTICS_DEFINITION_REPORT:
|
||||
case Subservice::HK_REPORT:
|
||||
@ -111,103 +112,59 @@ ReturnValue_t Service3Housekeeping::prepareCommand(CommandMessage* message,
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply,
|
||||
Command_t previousCommand, uint32_t *state,
|
||||
CommandMessage* optionalNextCommand, object_id_t objectId,
|
||||
bool *isStep) {
|
||||
switch(reply->getCommand()) {
|
||||
case(HousekeepingMessage::HK_REQUEST_SUCCESS): {
|
||||
return CommandingServiceBase::EXECUTION_COMPLETE;
|
||||
}
|
||||
case(HousekeepingMessage::HK_REQUEST_FAILURE): {
|
||||
failureParameter1 = objectId;
|
||||
// also provide failure reason (returnvalue)
|
||||
// will be most commonly invalid SID or the set already has the desired
|
||||
// reporting status.
|
||||
return CommandingServiceBase::EXECUTION_COMPLETE;
|
||||
}
|
||||
default:
|
||||
sif::error << "Service3Housekeeping::handleReply: Invalid reply!"
|
||||
<< std::endl;
|
||||
return CommandingServiceBase::INVALID_REPLY;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Service3Housekeeping::prepareReportingTogglingCommand(
|
||||
CommandMessage *command, bool enableReporting, bool isDiagnostics,
|
||||
CommandMessage *command, object_id_t objectId,
|
||||
bool enableReporting, bool isDiagnostics,
|
||||
const uint8_t* tcData, size_t tcDataLen) {
|
||||
if(tcDataLen < sizeof(sid_t)) {
|
||||
// It is assumed the full SID is sent for now (even if that means
|
||||
// 4 bytes are redundant)
|
||||
if(tcDataLen < sizeof(object_id_t)) {
|
||||
// TC data should consist of object ID and set ID.
|
||||
return CommandingServiceBase::INVALID_TC;
|
||||
}
|
||||
|
||||
sid_t targetSid;
|
||||
SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
|
||||
sid_t targetSid = buildSid(objectId, tcData, tcDataLen);
|
||||
HousekeepingMessage::setToggleReportingCommand(command, targetSid,
|
||||
enableReporting, isDiagnostics);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Service3Housekeeping::prepareStructureReportingCommand(
|
||||
CommandMessage *command, bool isDiagnostics, const uint8_t* tcData,
|
||||
size_t tcDataLen) {
|
||||
CommandMessage *command, object_id_t objectId, bool isDiagnostics,
|
||||
const uint8_t* tcData, size_t tcDataLen) {
|
||||
if(tcDataLen < sizeof(sid_t)) {
|
||||
// It is assumed the full SID is sent for now (even if that means
|
||||
// 4 bytes are redundant)
|
||||
// TC data should consist of object ID and set ID.
|
||||
return CommandingServiceBase::INVALID_TC;
|
||||
}
|
||||
|
||||
sid_t targetSid;
|
||||
SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
|
||||
sid_t targetSid = buildSid(objectId, tcData, tcDataLen);
|
||||
HousekeepingMessage::setStructureReportingCommand(command, targetSid,
|
||||
isDiagnostics);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Service3Housekeeping::prepareOneShotReportCommand(
|
||||
CommandMessage *command, bool isDiagnostics, const uint8_t *tcData,
|
||||
size_t tcDataLen) {
|
||||
CommandMessage *command, object_id_t objectId, bool isDiagnostics,
|
||||
const uint8_t *tcData, size_t tcDataLen) {
|
||||
if(tcDataLen < sizeof(sid_t)) {
|
||||
// It is assumed the full SID is sent for now (even if that means
|
||||
// 4 bytes are redundant)
|
||||
// TC data should consist of object ID and set ID.
|
||||
return CommandingServiceBase::INVALID_TC;
|
||||
}
|
||||
|
||||
sid_t targetSid;
|
||||
SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
sid_t targetSid = buildSid(objectId, tcData, tcDataLen);
|
||||
HousekeepingMessage::setOneShotReportCommand(command, targetSid,
|
||||
isDiagnostics);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand(
|
||||
CommandMessage *command, bool isDiagnostics, const uint8_t *tcData,
|
||||
size_t tcDataLen) {
|
||||
CommandMessage *command, object_id_t objectId, bool isDiagnostics,
|
||||
const uint8_t *tcData, size_t tcDataLen) {
|
||||
if(tcDataLen < sizeof(sid_t) + sizeof(float)) {
|
||||
// It is assumed the full SID and the new collection interval as a float
|
||||
// is sent for now (even if that means 4 bytes are redundant)
|
||||
// SID plus the size of the new collection intervL.
|
||||
return CommandingServiceBase::INVALID_TC;
|
||||
}
|
||||
|
||||
sid_t targetSid;
|
||||
sid_t targetSid = buildSid(objectId, tcData, tcDataLen);
|
||||
float newCollectionInterval = 0;
|
||||
SerializeAdapter::deSerialize(&targetSid.objectId, &tcData, &tcDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(&newCollectionInterval, &tcData, &tcDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
HousekeepingMessage::setCollectionIntervalModificationCommand(command,
|
||||
@ -215,25 +172,76 @@ ReturnValue_t Service3Housekeeping::prepareCollectionIntervalModificationCommand
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t Service3Housekeeping::handleReply(const CommandMessage* reply,
|
||||
Command_t previousCommand, uint32_t *state,
|
||||
CommandMessage* optionalNextCommand, object_id_t objectId,
|
||||
bool *isStep) {
|
||||
Command_t command = reply->getCommand();
|
||||
switch(command) {
|
||||
|
||||
case(HousekeepingMessage::HK_REPORT): {
|
||||
ReturnValue_t result = generateHkReport(reply,
|
||||
static_cast<uint8_t>(Subservice::HK_REPORT));
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return CommandingServiceBase::EXECUTION_COMPLETE;
|
||||
}
|
||||
|
||||
case(HousekeepingMessage::DIAGNOSTICS_REPORT): {
|
||||
ReturnValue_t result = generateHkReport(reply,
|
||||
static_cast<uint8_t>(Subservice::DIAGNOSTICS_REPORT));
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
return CommandingServiceBase::EXECUTION_COMPLETE;
|
||||
}
|
||||
|
||||
case(HousekeepingMessage::HK_REQUEST_SUCCESS): {
|
||||
return CommandingServiceBase::EXECUTION_COMPLETE;
|
||||
}
|
||||
|
||||
case(HousekeepingMessage::HK_REQUEST_FAILURE): {
|
||||
failureParameter1 = objectId;
|
||||
// also provide failure reason (returnvalue)
|
||||
// will be most commonly invalid SID or the set already has the desired
|
||||
// reporting status.
|
||||
return CommandingServiceBase::EXECUTION_COMPLETE;
|
||||
}
|
||||
|
||||
default:
|
||||
sif::error << "Service3Housekeeping::handleReply: Invalid reply with "
|
||||
<< "reply command " << command << "!" << std::endl;
|
||||
return CommandingServiceBase::INVALID_REPLY;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void Service3Housekeeping::handleUnrequestedReply(
|
||||
CommandMessage* reply) {
|
||||
CommandMessage* reply) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
switch(reply->getCommand()) {
|
||||
case(HousekeepingMessage::DIAGNOSTICS_REPORT): {
|
||||
result = generateHkReport(reply,
|
||||
static_cast<uint8_t>(Subservice::DIAGNOSTICS_REPORT));
|
||||
break;
|
||||
}
|
||||
case(HousekeepingMessage::HK_REPORT): {
|
||||
result = generateHkReport(reply,
|
||||
static_cast<uint8_t>(Subservice::HK_REPORT));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
sif::error << "Service3Housekeeping::handleUnrequestedReply: "
|
||||
<< "Invalid reply!" << std::endl;
|
||||
}
|
||||
}
|
||||
Command_t command = reply->getCommand();
|
||||
|
||||
switch(command) {
|
||||
|
||||
case(HousekeepingMessage::DIAGNOSTICS_REPORT): {
|
||||
result = generateHkReport(reply,
|
||||
static_cast<uint8_t>(Subservice::DIAGNOSTICS_REPORT));
|
||||
break;
|
||||
}
|
||||
|
||||
case(HousekeepingMessage::HK_REPORT): {
|
||||
result = generateHkReport(reply,
|
||||
static_cast<uint8_t>(Subservice::HK_REPORT));
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
sif::error << "Service3Housekeeping::handleReply: Invalid reply with "
|
||||
<< "reply command " << command << "!" << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
// Configuration error
|
||||
@ -260,3 +268,16 @@ ReturnValue_t Service3Housekeeping::generateHkReport(
|
||||
return sendTmPacket(static_cast<uint8_t>(subserviceId),
|
||||
hkPacket.hkData, hkPacket.hkSize, nullptr, 0);
|
||||
}
|
||||
|
||||
sid_t Service3Housekeeping::buildSid(object_id_t objectId,
|
||||
const uint8_t* tcData, size_t tcDataLen) {
|
||||
sid_t targetSid;
|
||||
targetSid.objectId = objectId;
|
||||
// skip deserialization of object ID, was already done.
|
||||
tcData += sizeof(object_id_t);
|
||||
tcDataLen -= sizeof(object_id_t);
|
||||
// size check is expected to be performed beforehand!
|
||||
SerializeAdapter::deSerialize(&targetSid.ownerSetId, &tcData, &tcDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
return targetSid;
|
||||
}
|
||||
|
@ -85,17 +85,21 @@ private:
|
||||
ReturnValue_t generateHkReport(const CommandMessage* hkMessage,
|
||||
uint8_t subserviceId);
|
||||
ReturnValue_t prepareReportingTogglingCommand(CommandMessage* command,
|
||||
bool enableReporting, bool isDiagnostics, const uint8_t* tcData,
|
||||
size_t tcDataLen);
|
||||
object_id_t objectId, bool enableReporting, bool isDiagnostics,
|
||||
const uint8_t* tcData, size_t tcDataLen);
|
||||
ReturnValue_t prepareStructureReportingCommand(CommandMessage* command,
|
||||
bool isDiagnostics, const uint8_t* tcData, size_t tcDataLen);
|
||||
ReturnValue_t prepareOneShotReportCommand(CommandMessage* command,
|
||||
bool isDiagnostics, const uint8_t* tcData, size_t tcDataLen);
|
||||
ReturnValue_t prepareCollectionIntervalModificationCommand(
|
||||
CommandMessage* command, bool isDiagnostics, const uint8_t* tcData,
|
||||
object_id_t objectId, bool isDiagnostics, const uint8_t* tcData,
|
||||
size_t tcDataLen);
|
||||
ReturnValue_t prepareOneShotReportCommand(CommandMessage* command,
|
||||
object_id_t objectId, bool isDiagnostics, const uint8_t* tcData,
|
||||
size_t tcDataLen);
|
||||
ReturnValue_t prepareCollectionIntervalModificationCommand(
|
||||
CommandMessage* command, object_id_t objectId, bool isDiagnostics,
|
||||
const uint8_t* tcData, size_t tcDataLen);
|
||||
|
||||
void handleUnrequestedReply(CommandMessage* reply) override;
|
||||
sid_t buildSid(object_id_t objectId, const uint8_t* tcData,
|
||||
size_t tcDataLen);
|
||||
};
|
||||
|
||||
#endif /* FSFW_PUS_SERVICE3HOUSEKEEPINGSERVICE_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user