Merge remote-tracking branch 'origin/master' into gaisser_fixes_fixedMap

This commit is contained in:
Steffen Gaisser 2020-08-12 10:10:39 +02:00
commit 7dbab61ab7
19 changed files with 1628 additions and 32 deletions

View File

@ -18,6 +18,8 @@ enum {
SYSTEM_MANAGER = 74, SYSTEM_MANAGER = 74,
SYSTEM_MANAGER_1 = 75, SYSTEM_MANAGER_1 = 75,
SYSTEM_1 = 79, SYSTEM_1 = 79,
PUS_SERVICE_1 = 80,
FW_SUBSYSTEM_ID_RANGE
}; };
} }

View File

@ -34,7 +34,7 @@ CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/FreeRTOS/*.cpp)
else ifeq ($(OS_FSFW),host) else ifeq ($(OS_FSFW),host)
CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/host/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/osal/host/*.cpp)
else else
$(error invalid OS specified, valid OS are rtems, linux, freeRTOS, host) $(error invalid OS_FSFW specified, valid OS_FSFW are rtems, linux, freeRTOS, host)
endif endif
CXXSRC += $(wildcard $(FRAMEWORK_PATH)/parameters/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/parameters/*.cpp)
@ -55,3 +55,4 @@ CXXSRC += $(wildcard $(FRAMEWORK_PATH)/tmtcpacket/*.cpp)
CXXSRC += $(wildcard $(FRAMEWORK_PATH)/tmtcpacket/packetmatcher/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/tmtcpacket/packetmatcher/*.cpp)
CXXSRC += $(wildcard $(FRAMEWORK_PATH)/tmtcpacket/pus/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/tmtcpacket/pus/*.cpp)
CXXSRC += $(wildcard $(FRAMEWORK_PATH)/tmtcservices/*.cpp) CXXSRC += $(wildcard $(FRAMEWORK_PATH)/tmtcservices/*.cpp)
CXXSRC += $(wildcard $(FRAMEWORK_PATH)/pus/*.cpp)

View File

@ -0,0 +1,119 @@
#include <framework/pus/CService200ModeCommanding.h>
#include <framework/pus/servicepackets/Service200Packets.h>
#include <framework/modes/HasModesIF.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/serialize/SerialLinkedListAdapter.h>
#include <framework/modes/ModeMessage.h>
CService200ModeCommanding::CService200ModeCommanding(object_id_t objectId,
uint16_t apid, uint8_t serviceId):
CommandingServiceBase(objectId, apid, serviceId,
NUMBER_OF_PARALLEL_COMMANDS,COMMAND_TIMEOUT_SECONDS) {}
CService200ModeCommanding::~CService200ModeCommanding() {}
ReturnValue_t CService200ModeCommanding::isValidSubservice(uint8_t subservice) {
switch(subservice) {
case(Subservice::COMMAND_MODE_COMMAND):
case(Subservice::COMMAND_MODE_READ):
case(Subservice::COMMAND_MODE_ANNCOUNCE):
return RETURN_OK;
default:
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
}
}
ReturnValue_t CService200ModeCommanding::getMessageQueueAndObject(
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
MessageQueueId_t *id, object_id_t *objectId) {
if(tcDataLen < sizeof(object_id_t)) {
return CommandingServiceBase::INVALID_TC;
}
SerializeAdapter::deSerialize(objectId, &tcData, &tcDataLen,
SerializeIF::Endianness::BIG);
return checkInterfaceAndAcquireMessageQueue(id,objectId);
}
ReturnValue_t CService200ModeCommanding::checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
HasModesIF * destination = objectManager->get<HasModesIF>(*objectId);
if(destination == nullptr) {
return CommandingServiceBase::INVALID_OBJECT;
}
*messageQueueToSet = destination->getCommandQueue();
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t CService200ModeCommanding::prepareCommand(
CommandMessage* message,uint8_t subservice, const uint8_t *tcData,
size_t tcDataLen, uint32_t *state, object_id_t objectId) {
ModePacket modeCommandPacket;
ReturnValue_t result = modeCommandPacket.deSerialize(&tcData,
&tcDataLen, SerializeIF::Endianness::BIG);
if (result != RETURN_OK) {
return result;
}
ModeMessage::setModeMessage(dynamic_cast<CommandMessage*>(message),
ModeMessage::CMD_MODE_COMMAND, modeCommandPacket.getMode(),
modeCommandPacket.getSubmode());
return result;
}
ReturnValue_t CService200ModeCommanding::handleReply(
const CommandMessage* reply, Command_t previousCommand,
uint32_t *state, CommandMessage* optionalNextCommand,
object_id_t objectId, bool *isStep) {
Command_t replyId = reply->getCommand();
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
switch(replyId) {
case(ModeMessage::REPLY_MODE_REPLY): {
result = prepareModeReply(reply, objectId);
break;
}
case(ModeMessage::REPLY_WRONG_MODE_REPLY): {
result = prepareWrongModeReply(reply, objectId);
break;
}
case(ModeMessage::REPLY_CANT_REACH_MODE): {
result = prepareCantReachModeReply(reply, objectId);
break;
}
case(ModeMessage::REPLY_MODE_INFO):
result = INVALID_REPLY;
break;
default:
result = RETURN_FAILED;
}
return result;
}
ReturnValue_t CService200ModeCommanding::prepareModeReply(
const CommandMessage *reply, object_id_t objectId) {
ModePacket modeReplyPacket(objectId,
ModeMessage::getMode(reply),
ModeMessage::getSubmode(reply));
return sendTmPacket(Subservice::REPLY_MODE_REPLY, &modeReplyPacket);
}
ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(
const CommandMessage *reply, object_id_t objectId) {
ModePacket wrongModeReply(objectId, ModeMessage::getMode(reply),
ModeMessage::getSubmode(reply));
return sendTmPacket(Subservice::REPLY_WRONG_MODE_REPLY, &wrongModeReply);
}
ReturnValue_t CService200ModeCommanding::prepareCantReachModeReply(
const CommandMessage *reply, object_id_t objectId) {
CantReachModePacket cantReachModePacket(objectId,
ModeMessage::getCantReachModeReason(reply));
return sendTmPacket(Subservice::REPLY_CANT_REACH_MODE,
&cantReachModePacket);
}

View File

@ -0,0 +1,85 @@
#ifndef FRAMEWORK_PUS_CSERVICE200MODECOMMANDING_H_
#define FRAMEWORK_PUS_CSERVICE200MODECOMMANDING_H_
#include <framework/tmtcservices/CommandingServiceBase.h>
/**
* @brief Custom PUS service to set mode of all objects implementing HasModesIF
*
* Examples: Device Handlers, Assemblies or Subsystems.
* Full Documentation: ECSS-E-ST-70-41C or ECSS-E-70-41A
* Dissertation Baetz p. 115, 116, 165-167.
*
* This is a gateway service. It relays device commands using the software bus.
* @ingroup pus_services
*/
class CService200ModeCommanding: public CommandingServiceBase {
public:
static constexpr uint8_t NUMBER_OF_PARALLEL_COMMANDS = 4;
static constexpr uint16_t COMMAND_TIMEOUT_SECONDS = 60;
CService200ModeCommanding(object_id_t objectId,
uint16_t apid, uint8_t serviceId);
virtual~ CService200ModeCommanding();
protected:
//! CommandingServiceBase (CSB) abstract functions. See CSB documentation.
ReturnValue_t isValidSubservice(uint8_t subservice) override;
ReturnValue_t getMessageQueueAndObject(uint8_t subservice,
const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id,
object_id_t *objectId) override;
ReturnValue_t prepareCommand(CommandMessage* message,
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
uint32_t *state, object_id_t objectId) override;
ReturnValue_t handleReply(const CommandMessage* reply,
Command_t previousCommand, uint32_t *state,
CommandMessage* optionalNextCommand, object_id_t objectId,
bool *isStep) override;
private:
ReturnValue_t checkAndAcquireTargetID(object_id_t* objectIdToSet,
const uint8_t* tcData, uint32_t tcDataLen);
ReturnValue_t checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t* MessageQueueToSet, object_id_t* objectId);
ReturnValue_t prepareModeReply(const CommandMessage *reply,
object_id_t objectId);
ReturnValue_t prepareWrongModeReply(const CommandMessage *reply,
object_id_t objectId);
ReturnValue_t prepareCantReachModeReply(const CommandMessage *reply,
object_id_t objectId);
enum Subservice { //!< [EXPORT] : [COMMENT] Mode Commanding Subservices
//!< [EXPORT] : [COMMAND] Command assembly, subsystem or device mode
COMMAND_MODE_COMMAND = 1,
//!< [EXPORT] : [COMMAND] Command to set the specified Mode,
//! regardless of external control flag
COMMAND_MODE_COMMAND_FORCED = 2,
//!< [EXPORT] : [COMMAND] Read the current mode and
//! reply with a REPLY_MODE_REPLY
COMMAND_MODE_READ = 3,
//!< [EXPORT] : [COMMAND] Trigger an ModeInfo Event.
//! This command does NOT have a reply
COMMAND_MODE_ANNCOUNCE = 4,
//!< [EXPORT] : [COMMAND] Trigger a ModeInfo Event and to send this
//! command to every child. This command does NOT have a reply.
COMMAND_MODE_ANNOUNCE_RECURSIVELY = 5,
//!< [EXPORT] : [REPLY] Reply to a CMD_MODE_COMMAND or CMD_MODE_READ
REPLY_MODE_REPLY = 6,
//!< [EXPORT] : [REPLY] Reply in case a mode command can't be executed.
REPLY_CANT_REACH_MODE = 7,
//!< [EXPORT] : [REPLY] Reply to a CMD_MODE_COMMAND, indicating that a
//! mode was commanded and a transition started but was aborted,
//! the parameters contain the mode that was reached
REPLY_WRONG_MODE_REPLY = 8
};
enum modeParameters {
MODE_OFF = 0,
MODE_ON = 1,
MODE_NORMAL = 2,
MODE_RAW = 3
};
};
#endif /* FRAMEWORK_PUS_CSERVICE200MODECOMMANDING_H_ */

View File

@ -0,0 +1,100 @@
#include <framework/pus/Service1TelecommandVerification.h>
#include <framework/pus/servicepackets/Service1Packets.h>
#include <framework/ipc/QueueFactory.h>
#include <framework/tmtcservices/PusVerificationReport.h>
#include <framework/tmtcpacket/pus/TmPacketStored.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/tmtcservices/AcceptsTelemetryIF.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
Service1TelecommandVerification::Service1TelecommandVerification(
object_id_t objectId, uint16_t apid, uint8_t serviceId,
object_id_t targetDestination):
SystemObject(objectId), apid(apid), serviceId(serviceId),
targetDestination(targetDestination) {
tmQueue = QueueFactory::instance()->createMessageQueue();
}
Service1TelecommandVerification::~Service1TelecommandVerification() {}
MessageQueueId_t Service1TelecommandVerification::getVerificationQueue(){
return tmQueue->getId();
}
ReturnValue_t Service1TelecommandVerification::performOperation(
uint8_t operationCode){
PusVerificationMessage message;
ReturnValue_t status = tmQueue->receiveMessage(&message);
while(status == HasReturnvaluesIF::RETURN_OK) {
status = sendVerificationReport(&message);
if(status != HasReturnvaluesIF::RETURN_OK) {
return status;
}
status = tmQueue->receiveMessage(&message);
}
if (status == MessageQueueIF::EMPTY) {
return HasReturnvaluesIF::RETURN_OK;
}
else {
return status;
}
}
ReturnValue_t Service1TelecommandVerification::sendVerificationReport(
PusVerificationMessage* message) {
ReturnValue_t result;
if(message->getReportId() % 2 == 0) {
result = generateFailureReport(message);
} else {
result = generateSuccessReport(message);
}
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "Service1TelecommandVerification::initialize: "
"Sending verification packet failed !" << std::endl;
}
return result;
}
ReturnValue_t Service1TelecommandVerification::generateFailureReport(
PusVerificationMessage *message) {
FailureReport report(
message->getReportId(), message->getTcPacketId(),
message->getTcSequenceControl(), message->getStep(),
message->getErrorCode(), message->getParameter1(),
message->getParameter2());
TmPacketStored tmPacket(apid, serviceId, message->getReportId(),
packetSubCounter++, &report);
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(),
tmQueue->getId());
return result;
}
ReturnValue_t Service1TelecommandVerification::generateSuccessReport(
PusVerificationMessage *message) {
SuccessReport report(message->getReportId(),message->getTcPacketId(),
message->getTcSequenceControl(),message->getStep());
TmPacketStored tmPacket(apid, serviceId, message->getReportId(),
packetSubCounter++, &report);
ReturnValue_t result = tmPacket.sendPacket(tmQueue->getDefaultDestination(),
tmQueue->getId());
return result;
}
ReturnValue_t Service1TelecommandVerification::initialize() {
// Get target object for TC verification messages
AcceptsTelemetryIF* funnel = objectManager->
get<AcceptsTelemetryIF>(targetDestination);
if(funnel == nullptr){
sif::error << "Service1TelecommandVerification::initialize: Specified"
" TM funnel invalid. Make sure it is set up and implements"
" AcceptsTelemetryIF." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tmQueue->setDefaultDestination(funnel->getReportReceptionQueue());
return SystemObject::initialize();
}

View File

@ -0,0 +1,94 @@
#ifndef MISSION_PUS_SERVICE1TELECOMMANDVERIFICATION_H_
#define MISSION_PUS_SERVICE1TELECOMMANDVERIFICATION_H_
#include <framework/objectmanager/SystemObject.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/tasks/ExecutableObjectIF.h>
#include <framework/tmtcservices/AcceptsVerifyMessageIF.h>
#include <framework/tmtcservices/PusVerificationReport.h>
#include <framework/ipc/MessageQueueIF.h>
/**
* @brief Verify TC acceptance, start, progress and execution.
*
* Full Documentation: ECSS-E70-41A p.51
*
* The telecommand verification service provides the capability for
* explicit verification of each distinct stage of execution of a telecommand
* packet, from on-board acceptance through to completion of execution.
*
* Minimum capabilities of this service:
*
* - TM[1,1]: Telecommand Acceptance Report - Success.
* - TM[1,2]: Telecommand Acceptance Report - Failure.
*
* Additional capabilities of this service:
*
* - TM[1,3]: Telecommand Execution Started Report - Success (Req. 4).
* - TM[1,4]: Telecommand Execution Started Report - Failure (Req. 3).
* - TM[1,5]: Telecommand Execution Progress Report - Success (Req. 6).
* - TM[1,6]: Telecommand Execution Progress Report - Failure (Req. 5).
* - TM[1,7]: Telecommand Execution Completed Report - Success (Req. 8).
* - TM[1,8]: Telecommand Execution Completed Report - Failure (Req. 7).
*
* This Service is not inherited from PUSServiceBase unlike other PUS Services
* because all services implementing PUSServiceBase use this service to
* generate verification reports.
* @ingroup pus_services
*/
class Service1TelecommandVerification: public AcceptsVerifyMessageIF,
public SystemObject,
public ExecutableObjectIF,
public HasReturnvaluesIF {
public:
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_1;
Service1TelecommandVerification(object_id_t objectId,
uint16_t apid, uint8_t serviceId, object_id_t targetDestination);
virtual ~Service1TelecommandVerification();
/**
*
* @return ID of Verification Queue
*/
virtual MessageQueueId_t getVerificationQueue();
/**
* Performs the service periodically as specified in init_mission().
* Triggers the handlePacket function to send TC verification messages
* @param operationCode
* @return
*/
ReturnValue_t performOperation(uint8_t operationCode = 0) override;
/**
* Initializes the destination for TC verification messages and initializes
* Service 1 as a system object
* @return
*/
ReturnValue_t initialize() override;
private:
uint16_t apid = 0;
uint8_t serviceId = 0;
object_id_t targetDestination = objects::NO_OBJECT;
ReturnValue_t sendVerificationReport(PusVerificationMessage* message);
ReturnValue_t generateFailureReport(PusVerificationMessage* message);
ReturnValue_t generateSuccessReport(PusVerificationMessage* message);
uint16_t packetSubCounter = 0;
MessageQueueIF* tmQueue = nullptr;
enum class Subservice: uint8_t {
VERIFY_ACCEPTANCE_SUCCESS = 1, //!< [EXPORT] : [TM]
VERIFY_ACCEPTANCE_FAILED = 2, //!< [EXPORT] : [TM]
VERIFY_START_SUCCESS = 3, //!< [EXPORT] : [TM]
VERIFY_START_FAILED = 4, //!< [EXPORT] : [TM]
VERIFY_STEP_SUCCESS = 5, //!< [EXPORT] : [TM]
VERIFY_STEP_FAILED = 6 //!< [EXPORT] : [TM]
};
};
#endif /* MISSION_PUS_SERVICE1TELECOMMANDVERIFICATION_H_ */

View File

@ -0,0 +1,167 @@
#include <framework/pus/Service2DeviceAccess.h>
#include <framework/pus/servicepackets/Service2Packets.h>
#include <framework/devicehandlers/DeviceHandlerIF.h>
#include <framework/storagemanager/StorageManagerIF.h>
#include <framework/devicehandlers/DeviceHandlerMessage.h>
#include <framework/serialize/EndianConverter.h>
#include <framework/action/ActionMessage.h>
#include <framework/serialize/SerializeAdapter.h>
#include <framework/serialize/SerialLinkedListAdapter.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
Service2DeviceAccess::Service2DeviceAccess(object_id_t objectId,
uint16_t apid, uint8_t serviceId, uint8_t numberOfParallelCommands,
uint16_t commandTimeoutSeconds):
CommandingServiceBase(objectId, apid, serviceId,
numberOfParallelCommands, commandTimeoutSeconds) {}
Service2DeviceAccess::~Service2DeviceAccess() {}
ReturnValue_t Service2DeviceAccess::isValidSubservice(uint8_t subservice) {
switch(static_cast<Subservice>(subservice)){
case Subservice::RAW_COMMANDING:
case Subservice::TOGGLE_WIRETAPPING:
return HasReturnvaluesIF::RETURN_OK;
default:
sif::error << "Invalid Subservice" << std::endl;
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
}
}
ReturnValue_t Service2DeviceAccess::getMessageQueueAndObject(
uint8_t subservice, const uint8_t* tcData, size_t tcDataLen,
MessageQueueId_t* id, object_id_t* objectId) {
if(tcDataLen < sizeof(object_id_t)) {
return CommandingServiceBase::INVALID_TC;
}
SerializeAdapter::deSerialize(objectId, &tcData,
&tcDataLen, SerializeIF::Endianness::BIG);
ReturnValue_t result = checkInterfaceAndAcquireMessageQueue(id,objectId);
return result;
}
ReturnValue_t Service2DeviceAccess::checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t * messageQueueToSet, object_id_t *objectId) {
DeviceHandlerIF* possibleTarget =
objectManager->get<DeviceHandlerIF>(*objectId);
if(possibleTarget == nullptr) {
return CommandingServiceBase::INVALID_OBJECT;
}
*messageQueueToSet = possibleTarget->getCommandQueue();
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Service2DeviceAccess::prepareCommand(CommandMessage* message,
uint8_t subservice, const uint8_t* tcData, size_t tcDataLen,
uint32_t* state, object_id_t objectId) {
switch(static_cast<Subservice>(subservice)){
case Subservice::RAW_COMMANDING: {
return prepareRawCommand(dynamic_cast<CommandMessage*>(message),
tcData, tcDataLen);
}
break;
case Subservice::TOGGLE_WIRETAPPING: {
return prepareWiretappingCommand(dynamic_cast<CommandMessage*>(message),
tcData, tcDataLen);
}
break;
default:
return HasReturnvaluesIF::RETURN_FAILED;
}
}
ReturnValue_t Service2DeviceAccess::prepareRawCommand(
CommandMessage* messageToSet, const uint8_t *tcData,size_t tcDataLen) {
RawCommand RawCommand(tcData,tcDataLen);
// store command into the Inter Process Communication Store
store_address_t storeAddress;
ReturnValue_t result = IPCStore->addData(&storeAddress,
RawCommand.getCommand(), RawCommand.getCommandSize());
DeviceHandlerMessage::setDeviceHandlerRawCommandMessage(messageToSet,
storeAddress);
return result;
}
ReturnValue_t Service2DeviceAccess::prepareWiretappingCommand(
CommandMessage *messageToSet, const uint8_t *tcData,
size_t tcDataLen) {
if(tcDataLen != WiretappingToggle::WIRETAPPING_COMMAND_SIZE) {
return CommandingServiceBase::INVALID_TC;
}
WiretappingToggle command;
ReturnValue_t result = command.deSerialize(&tcData, &tcDataLen,
SerializeIF::Endianness::BIG);
DeviceHandlerMessage::setDeviceHandlerWiretappingMessage(messageToSet,
command.getWiretappingMode());
return result;
}
ReturnValue_t Service2DeviceAccess::handleReply(const CommandMessage* reply,
Command_t previousCommand, uint32_t* state,
CommandMessage* optionalNextCommand, object_id_t objectId,
bool* isStep) {
switch(reply->getCommand()) {
case CommandMessage::REPLY_COMMAND_OK:
return HasReturnvaluesIF::RETURN_OK;
case CommandMessage::REPLY_REJECTED:
return reply->getReplyRejectedReason();
default:
return CommandingServiceBase::INVALID_REPLY;
}
}
// All device handlers set service 2 as default raw receiver for wiretapping
// so we have to handle those unrequested messages.
void Service2DeviceAccess::handleUnrequestedReply(CommandMessage* reply) {
switch(reply->getCommand()) {
case DeviceHandlerMessage::REPLY_RAW_COMMAND:
sendWiretappingTm(reply,
static_cast<uint8_t>(Subservice::WIRETAPPING_RAW_TC));
break;
case DeviceHandlerMessage::REPLY_RAW_REPLY:
sendWiretappingTm(reply,
static_cast<uint8_t>(Subservice::RAW_REPLY));
break;
default:
sif::error << "Unknown message in Service2DeviceAccess::"
"handleUnrequestedReply with command ID " <<
reply->getCommand() << std::endl;
break;
}
//Must be reached by all cases to clear message
reply->clear();
}
void Service2DeviceAccess::sendWiretappingTm(CommandMessage *reply,
uint8_t subservice) {
// Raw Wiretapping
// Get Address of Data from Message
store_address_t storeAddress = DeviceHandlerMessage::getStoreAddress(reply);
const uint8_t* data = nullptr;
size_t size = 0;
ReturnValue_t result = IPCStore->getData(storeAddress, &data, &size);
if(result != HasReturnvaluesIF::RETURN_OK){
sif::error << "Service2DeviceAccess::sendWiretappingTm: Data Lost in "
"handleUnrequestedReply with failure ID "<< result
<< std::endl;
return;
}
// Init our dummy packet and correct endianness of object ID before
// sending it back.
WiretappingPacket TmPacket(DeviceHandlerMessage::getDeviceObjectId(reply),
data);
TmPacket.objectId = EndianConverter::convertBigEndian(TmPacket.objectId);
sendTmPacket(subservice, TmPacket.data,size, reinterpret_cast<uint8_t*>(
&TmPacket.objectId), sizeof(TmPacket.objectId));
}
MessageQueueId_t Service2DeviceAccess::getDeviceQueue() {
return commandQueue->getId();
}

View File

@ -0,0 +1,92 @@
#ifndef FRAMEWORK_PUS_SERVICE2DEVICEACCESS_H_
#define FRAMEWORK_PUS_SERVICE2DEVICEACCESS_H_
#include <framework/objectmanager/SystemObjectIF.h>
#include <framework/devicehandlers/AcceptsDeviceResponsesIF.h>
#include <framework/tmtcservices/CommandingServiceBase.h>
/**
* @brief Raw Commanding and Wiretapping of devices.
* @details
* Full Documentation: ECSS-E-ST-70-41C or ECSS-E-70-41A
* Dissertation Baetz p. 115, 116, 165-167.
*
* This service provides the capability to communicate with devices in their
* native protocols with raw commands through the DeviceHandlerIF.
*
* This is a gateway service. It relays device commands to the software bus.
* This service is very closely tied to the CommandingServiceBase
* template class.
*
* There are 4 adaption points for component implementation through the
* CommandingServiceBase.
*
* This service employs custom subservices exclusively. This includes a
* wiretapping subservice to monitor all traffic between target devices and
* this service.
*
* - TC[2,128]: Raw Commanding
* - TC[2,129]: Toggle Wiretapping
* - TM[2,130]: Wiretapping Packet TM
* - TM[2,131]: Wiretapping Packet TC
* @ingroup pus_services
*/
class Service2DeviceAccess : public CommandingServiceBase,
public AcceptsDeviceResponsesIF
{
public:
Service2DeviceAccess(object_id_t objectId, uint16_t apid,
uint8_t serviceId, uint8_t numberOfParallelCommands = 4,
uint16_t commandTimeoutSeconds = 60);
virtual ~Service2DeviceAccess();
protected:
//! CommandingServiceBase (CSB) abstract functions. See CSB documentation.
ReturnValue_t isValidSubservice(uint8_t subservice) override;
ReturnValue_t getMessageQueueAndObject(uint8_t subservice,
const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id,
object_id_t *objectId) override;
ReturnValue_t prepareCommand(CommandMessage* message, uint8_t subservice,
const uint8_t *tcData, size_t tcDataLen, uint32_t *state,
object_id_t objectId) override;
ReturnValue_t handleReply(const CommandMessage* reply,
Command_t previousCommand, uint32_t *state,
CommandMessage* optionalNextCommand, object_id_t objectId,
bool *isStep) override;
/**
* @brief Generates TM packets containing either the TC wiretapping
* packets or the TM wiretapping packets.
* Note that for service 2, all telemetry will be treated as an
* unrequested reply regardless of wiretapping mode.
* @param reply
*/
void handleUnrequestedReply(CommandMessage* reply) override;
MessageQueueId_t getDeviceQueue() override;
private:
/**
* Generates TM packets for Wiretapping Service
* @param reply
* @param subservice
*/
void sendWiretappingTm(CommandMessage* reply,uint8_t subservice);
ReturnValue_t checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t* messageQueueToSet, object_id_t* objectId);
ReturnValue_t prepareRawCommand(CommandMessage* messageToSet,
const uint8_t* tcData, size_t tcDataLen);
ReturnValue_t prepareWiretappingCommand(CommandMessage* messageToSet,
const uint8_t* tcData, size_t tcDataLen);
enum class Subservice {
RAW_COMMANDING = 128, //!< [EXPORT] : [COMMAND] Command in device native protocol
TOGGLE_WIRETAPPING = 129, //!< [EXPORT] : [COMMAND] Toggle wiretapping of raw communication
RAW_REPLY = 130, //!< [EXPORT] : [REPLY] Includes wiretapping TM and normal TM raw replies from device
WIRETAPPING_RAW_TC = 131 //!< [EXPORT] : [REPLY] Wiretapping packets of commands built by device handler
};
};
#endif /* MISSION_PUS_DEVICE2DEVICECOMMANDING_H_ */

View File

@ -0,0 +1,91 @@
#include <framework/pus/Service5EventReporting.h>
#include <framework/pus/servicepackets/Service5Packets.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/events/EventManagerIF.h>
#include <framework/ipc/QueueFactory.h>
#include <framework/tmtcpacket/pus/TmPacketStored.h>
Service5EventReporting::Service5EventReporting(object_id_t objectId,
uint16_t apid, uint8_t serviceId, size_t maxNumberReportsPerCycle):
PusServiceBase(objectId, apid, serviceId),
maxNumberReportsPerCycle(maxNumberReportsPerCycle) {
eventQueue = QueueFactory::instance()->createMessageQueue();
}
Service5EventReporting::~Service5EventReporting(){}
ReturnValue_t Service5EventReporting::performService() {
EventMessage message;
ReturnValue_t status = RETURN_OK;
for(uint8_t counter = 0;
counter < maxNumberReportsPerCycle;
counter++)
{
// Receive messages even if reporting is disabled for now.
status = eventQueue->receiveMessage(&message);
if(status == MessageQueueIF::EMPTY) {
return HasReturnvaluesIF::RETURN_OK;
}
if(enableEventReport) {
status = generateEventReport(message);
if(status != HasReturnvaluesIF::RETURN_OK) {
return status;
}
}
}
sif::debug << "Service5EventReporting::generateEventReport:"
" Too many events" << std::endl;
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Service5EventReporting::generateEventReport(
EventMessage message)
{
EventReport report(message.getEventId(),message.getReporter(),
message.getParameter1(),message.getParameter2());
TmPacketStored tmPacket(PusServiceBase::apid, PusServiceBase::serviceId,
message.getSeverity(), packetSubCounter++, &report);
ReturnValue_t result = tmPacket.sendPacket(
requestQueue->getDefaultDestination(),requestQueue->getId());
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "Service5EventReporting::generateEventReport:"
" Could not send TM packet" << std::endl;
}
return result;
}
ReturnValue_t Service5EventReporting::handleRequest(uint8_t subservice) {
switch(subservice) {
case Subservice::ENABLE: {
enableEventReport = true;
return HasReturnvaluesIF::RETURN_OK;
}
case Subservice::DISABLE: {
enableEventReport = false;
return HasReturnvaluesIF::RETURN_OK;
}
default:
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
}
}
// In addition to the default PUSServiceBase initialization, this service needs
// to be registered to the event manager to listen for events.
ReturnValue_t Service5EventReporting::initialize() {
EventManagerIF* manager = objectManager->get<EventManagerIF>(
objects::EVENT_MANAGER);
if (manager == NULL) {
return RETURN_FAILED;
}
// register Service 5 as listener for events
ReturnValue_t result = manager->registerListener(eventQueue->getId(),true);
if(result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return PusServiceBase::initialize();
}

View File

@ -0,0 +1,86 @@
#ifndef FRAMEWORK_PUS_SERVICE5EVENTREPORTING_H_
#define FRAMEWORK_PUS_SERVICE5EVENTREPORTING_H_
#include <framework/tmtcservices/PusServiceBase.h>
#include <framework/events/EventMessage.h>
/**
* @brief Report on-board events like information or errors
* @details
* Full Documentation: ECSS-E70-41A p.79
* Implements the PusServiceBase template class.
* Documentation: Dissertation Baetz p.135,136
*
* This service provides for the reporting to the service user of information of
* operational significance.
* 1. reporting of failures or anomalies detected on-board;
* 2. reporting of autonomous on-board actions;
* 3. reporting of normal progress of operations and activities, e.g.
* detection of events which are not anomalous (such as payload events),
* reaching of predefined steps in an operation. Some reports can combine
* more than one of these events.
*
* Minimum capabilities of this service:
*
* - TM[5,1]: Normal/Progress Report
* - TM[5,2]: Error/Anomaly Report - Low Severity
* - TM[5,3]: Error/Anomaly Report - Medium Severity
* - TM[5,4]: Error/Anomaly Report - High Severity
*
* Events can be translated by using translator files located in
* /config/objects/ and /config/events/. Description to events can be added by
* adding a comment behind the event definition with [//!<] as leading string
*
* Additional capabilities of this service:
*
* - TC[5,5]: Enable Event Report Generation (Req. 6)
* - TC[5,6]: Disable Event Report Generation (Req. 5)
* @author R. Mueller
* @ingroup pus_services
*/
class Service5EventReporting: public PusServiceBase {
public:
Service5EventReporting(object_id_t objectId, uint16_t apid,
uint8_t serviceId, size_t maxNumberReportsPerCycle = 10);
virtual ~Service5EventReporting();
/***
* Check for events and generate event reports if required.
* @return
*/
ReturnValue_t performService() override;
/***
* Turn event generation on or off.
* @return
*/
ReturnValue_t handleRequest(uint8_t subservice) override;
/**
* The default PusServiceBase initialize has been overridden but is still
* executed. Registers this service as a listener for events at the
* EventManager.
* @return
*/
ReturnValue_t initialize() override;
enum Subservice: uint8_t {
NORMAL_REPORT = 1, //!< [EXPORT] : [REPLY] Generate normal report
ERROR_LOW_SEVERITY = 2, //!< [EXPORT] : [REPLY] Generate error report with low severity
ERROR_MED_SEVERITY = 3, //!< [EXPORT] : [REPLY] Generate error report with medium severity
ERROR_HIGH_SEVERITY = 4, //!< [EXPORT] : [REPLY] Generate error report with high severity
ENABLE = 5, //!< [EXPORT] : [COMMAND] Enable report generation
DISABLE = 6 //!< [EXPORT] : [COMMAND] Disable report generation
};
private:
uint16_t packetSubCounter = 0;
MessageQueueIF* eventQueue = nullptr;
bool enableEventReport = true;
const uint8_t maxNumberReportsPerCycle;
ReturnValue_t generateEventReport(EventMessage message);
};
#endif /* MISSION_PUS_SERVICE5EVENTREPORTING_H_ */

View File

@ -0,0 +1,142 @@
#include <framework/pus/Service8FunctionManagement.h>
#include <framework/pus/servicepackets/Service8Packets.h>
#include <framework/objectmanager/SystemObjectIF.h>
#include <framework/action/HasActionsIF.h>
#include <framework/devicehandlers/DeviceHandlerIF.h>
#include <framework/serialize/SerializeAdapter.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
Service8FunctionManagement::Service8FunctionManagement(object_id_t object_id,
uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands,
uint16_t commandTimeoutSeconds):
CommandingServiceBase(object_id, apid, serviceId, numParallelCommands,
commandTimeoutSeconds) {}
Service8FunctionManagement::~Service8FunctionManagement() {}
ReturnValue_t Service8FunctionManagement::isValidSubservice(
uint8_t subservice) {
switch(static_cast<Subservice>(subservice)) {
case Subservice::DIRECT_COMMANDING:
return HasReturnvaluesIF::RETURN_OK;
default:
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
}
}
ReturnValue_t Service8FunctionManagement::getMessageQueueAndObject(
uint8_t subservice, const uint8_t* tcData, size_t tcDataLen,
MessageQueueId_t* id, object_id_t* objectId) {
if(tcDataLen < sizeof(object_id_t)) {
return CommandingServiceBase::INVALID_TC;
}
SerializeAdapter::deSerialize(objectId, &tcData,
&tcDataLen, SerializeIF::Endianness::BIG);
return checkInterfaceAndAcquireMessageQueue(id,objectId);
}
ReturnValue_t Service8FunctionManagement::checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
// check HasActionIF property of target
HasActionsIF* possibleTarget = objectManager->get<HasActionsIF>(*objectId);
if(possibleTarget == nullptr){
return CommandingServiceBase::INVALID_OBJECT;
}
*messageQueueToSet = possibleTarget->getCommandQueue();
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t Service8FunctionManagement::prepareCommand(
CommandMessage* message, uint8_t subservice, const uint8_t* tcData,
size_t tcDataLen, uint32_t* state, object_id_t objectId) {
return prepareDirectCommand(dynamic_cast<CommandMessage*>(message),
tcData, tcDataLen);
}
ReturnValue_t Service8FunctionManagement::prepareDirectCommand(
CommandMessage *message, const uint8_t *tcData, size_t tcDataLen) {
if(tcDataLen < sizeof(object_id_t) + sizeof(ActionId_t)) {
sif::debug << "Service8FunctionManagement::prepareDirectCommand:"
<< " TC size smaller thant minimum size of direct command."
<< std::endl;
return CommandingServiceBase::INVALID_TC;
}
// Create direct command instance by extracting data from Telecommand
DirectCommand command(tcData, tcDataLen);
// store additional parameters into the IPC Store
store_address_t parameterAddress;
ReturnValue_t result = IPCStore->addData(&parameterAddress,
command.getParameters(),command.getParametersSize());
// setCommand expects a Command Message, an Action ID and a store adress
// pointing to additional parameters
ActionMessage::setCommand(message,command.getActionId(),parameterAddress);
return result;
}
ReturnValue_t Service8FunctionManagement::handleReply(
const CommandMessage* reply, Command_t previousCommand,
uint32_t* state, CommandMessage* optionalNextCommand,
object_id_t objectId, bool* isStep) {
Command_t replyId = reply->getCommand();
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
ActionId_t actionId = ActionMessage::getActionId(reply);
ReturnValue_t returnCode = ActionMessage::getReturnCode(reply);
switch(replyId) {
case ActionMessage::COMPLETION_SUCCESS: {
DirectReply completionReply(objectId, actionId,returnCode);
result = CommandingServiceBase::EXECUTION_COMPLETE;
break;
}
case ActionMessage::STEP_SUCCESS: {
*isStep = true;
result = HasReturnvaluesIF::RETURN_OK;
break;
}
case ActionMessage::DATA_REPLY: {
result = handleDataReply(reply, objectId, actionId);
break;
}
case ActionMessage::STEP_FAILED:
*isStep = true;
/*No break, falls through*/
case ActionMessage::COMPLETION_FAILED:
result = ActionMessage::getReturnCode(reply);
break;
default:
result = INVALID_REPLY;
}
return result;
}
ReturnValue_t Service8FunctionManagement::handleDataReply(
const CommandMessage* reply, object_id_t objectId,
ActionId_t actionId) {
store_address_t storeId = ActionMessage::getStoreId(reply);
size_t size = 0;
const uint8_t * buffer = nullptr;
ReturnValue_t result = IPCStore->getData(storeId, &buffer, &size);
if(result != RETURN_OK) {
sif::error << "Service 8: Could not retrieve data for data reply"
<< std::endl;
return result;
}
DataReply dataReply(objectId, actionId, buffer, size);
result = sendTmPacket(static_cast<uint8_t>(
Subservice::DIRECT_COMMANDING_DATA_REPLY), &dataReply);
auto deletionResult = IPCStore->deleteData(storeId);
if(deletionResult != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Service8FunctionManagement::handleReply: Deletion"
<< " of data in pool failed." << std::endl;
}
return result;
}

View File

@ -0,0 +1,67 @@
#ifndef FRAMEWORK_PUS_SERVICE8FUNCTIONMANAGEMENT_H_
#define FRAMEWORK_PUS_SERVICE8FUNCTIONMANAGEMENT_H_
#include <framework/action/ActionMessage.h>
#include <framework/tmtcservices/CommandingServiceBase.h>
/**
* @brief Functional commanding.
* Full Documentation: ECSS-E-ST-70-41C p.64, p. 451
* Dissertation Baetz p. 115, 116, 165-167
*
* This service provides the capability to perform functions of an
* application process and provides high-level commanding as opposed to the
* Raw Access provided by Service 2. Examples for these functions can include
* control and operation of payload or the AOCS subsystem.
* This service will be the primary means to control the spacecraft as it is
* considered safer than the Raw Access provided
* by Service 2 and is generally sufficient for most tasks.
*
* This is a gateway service. It relays device commands using the software bus.
* This service is very closely tied to the Commanding Service Base template
* class. There is constant interaction between this Service Base und a
* subclass like this service.
*
* Service Capability:
* - TC[8,128]: Direct Commanding
* - TM[8,130]: Direct Commanding Data Reply
*
* @ingroup pus_services
*/
class Service8FunctionManagement : public CommandingServiceBase
{
public:
Service8FunctionManagement(object_id_t objectId, uint16_t apid,
uint8_t serviceId, uint8_t numParallelCommands = 4,
uint16_t commandTimeoutSeconds = 60);
virtual ~Service8FunctionManagement();
protected:
/* CSB abstract functions implementation . See CSB documentation. */
ReturnValue_t isValidSubservice(uint8_t subservice) override;
ReturnValue_t getMessageQueueAndObject(uint8_t subservice,
const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id,
object_id_t *objectId) override;
ReturnValue_t prepareCommand(CommandMessage* message,
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
uint32_t *state, object_id_t objectId) override;
ReturnValue_t handleReply(const CommandMessage* reply,
Command_t previousCommand, uint32_t *state,
CommandMessage* optionalNextCommand, object_id_t objectId,
bool *isStep) override;
private:
enum class Subservice {
DIRECT_COMMANDING = 128, //!< [EXPORT] : [COMMAND] Functional commanding
DIRECT_COMMANDING_DATA_REPLY = 130, //!< [EXPORT] : [REPLY] Data reply
};
ReturnValue_t checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t* messageQueueToSet, object_id_t* objectId);
ReturnValue_t prepareDirectCommand(CommandMessage* message,
const uint8_t* tcData, size_t tcDataLen);
ReturnValue_t handleDataReply(const CommandMessage* reply,
object_id_t objectId, ActionId_t actionId);
};
#endif /* FRAMEWORK_PUS_SERVICE8FUNCTIONMANAGEMENT_H_ */

View File

@ -0,0 +1,166 @@
/**
* @defgroup spacepackets PUS Packet Definitions
* This group contains all implemented TM or TM packages that are sent to
* or sent by the OBC.They are exported later to display
* packet structures in Mission Information Base (MIB).
*/
#ifndef MISSION_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_
#define MISSION_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_
#include <framework/serialize/SerializeAdapter.h>
#include <framework/tmtcservices/VerificationCodes.h>
/**
* @brief FailureReport class to serialize a failure report
* @brief Subservice 1, 3, 5, 7
* @ingroup spacepackets
*/
class FailureReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 3, 5, 7
public:
FailureReport(uint8_t failureSubtype_, uint16_t packetId_,
uint16_t packetSequenceControl_, uint8_t stepNumber_,
ReturnValue_t errorCode_, uint32_t errorParameter1_,
uint32_t errorParameter2_) :
packetId(packetId_), packetSequenceControl(packetSequenceControl_),
stepNumber(stepNumber_), errorCode(errorCode_),
errorParameter1(errorParameter1_), errorParameter2(errorParameter2_),
failureSubtype(failureSubtype_) {}
/**
* This function is called by the FSFW when calling the tm packet send
* function and supplying the SerializeIF* as parameter
* @param buffer Object content is serialized into the buffer
* @param size
* @param max_size
* @param bigEndian
* @return
*/
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
size_t maxSize, SerializeIF::Endianness streamEndianness
) const override {
ReturnValue_t result = SerializeAdapter::serialize(&packetId, buffer,
size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = SerializeAdapter::serialize(&packetSequenceControl, buffer,
size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (failureSubtype == TC_VERIFY::PROGRESS_FAILURE) {
result = SerializeAdapter::serialize(&stepNumber, buffer, size,
maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
}
result = SerializeAdapter::serialize(&errorCode, buffer, size,
maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = SerializeAdapter::serialize(&errorParameter1, buffer, size,
maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = SerializeAdapter::serialize(&errorParameter2, buffer, size,
maxSize, streamEndianness);
return result;
}
virtual size_t getSerializedSize() const {
size_t size = 0;
size += SerializeAdapter::getSerializedSize(&packetId);
size += sizeof(packetSequenceControl);
if(failureSubtype==TC_VERIFY::PROGRESS_FAILURE){
size += SerializeAdapter::getSerializedSize(&stepNumber);
}
size += SerializeAdapter::getSerializedSize(&errorCode);
size += SerializeAdapter::getSerializedSize(&errorParameter1);
size += SerializeAdapter::getSerializedSize(&errorParameter2);
return size;
}
/**
* Deserialization is not allowed for a report.
* @param buffer
* @param size
* @param bigEndian
* @return
*/
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) override {
return HasReturnvaluesIF::RETURN_FAILED;
}
private:
uint16_t packetId; //!< [EXPORT] : [COMMENT] Packet ID of respective Telecommand
uint16_t packetSequenceControl; //!< [EXPORT] : [COMMENT] Packet SSC of respective Telecommand
uint8_t stepNumber; //!< [EXPORT] : [OPTIONAL][SUBSERVICE] 6
ReturnValue_t errorCode; //!< [EXPORT] : [COMMENT] Error code which can be looked up in generated error code file
uint32_t errorParameter1;
uint32_t errorParameter2;
const uint8_t failureSubtype; //!< [EXPORT] : [IGNORE]
};
/**
* @brief Subservices 2, 4, 6, 8
* @ingroup spacepackets
*/
class SuccessReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 2, 4, 6, 8
public:
SuccessReport(uint8_t subtype_, uint16_t packetId_,
uint16_t packetSequenceControl_,uint8_t stepNumber_) :
packetId(packetId_), packetSequenceControl(packetSequenceControl_),
stepNumber(stepNumber_), subtype(subtype_) {}
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
size_t maxSize, SerializeIF::Endianness streamEndianness
) const override {
ReturnValue_t result = SerializeAdapter::serialize(&packetId, buffer,
size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = SerializeAdapter::serialize(&packetSequenceControl, buffer,
size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (subtype == TC_VERIFY::PROGRESS_SUCCESS) {
result = SerializeAdapter::serialize(&stepNumber, buffer, size,
maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
}
return result;
}
virtual size_t getSerializedSize() const override {
size_t size = 0;
size += SerializeAdapter::getSerializedSize(&packetId);
size += sizeof(packetSequenceControl);
if(subtype == TC_VERIFY::PROGRESS_SUCCESS){
size += SerializeAdapter::getSerializedSize(&stepNumber);
}
return size;
}
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) override {
return HasReturnvaluesIF::RETURN_FAILED;
}
private:
uint16_t packetId; //!< [EXPORT] : [COMMENT] Packet ID of respective Telecommand
uint16_t packetSequenceControl; //!< [EXPORT] : [COMMENT] Packet SSC of respective Telecommand
uint8_t stepNumber; //!< [EXPORT] : [OPTIONAL][SUBSERVICE] 6
const uint8_t subtype; //!< [EXPORT] : [IGNORE]
};
#endif /* MISSION_PUS_SERVICEPACKETS_SERVICE1PACKETS_H_ */

View File

@ -0,0 +1,63 @@
#ifndef FRAMEWORK_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_
#define FRAMEWORK_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_
#include <framework/serialize/SerialLinkedListAdapter.h>
#include <framework/modes/ModeMessage.h>
#include <framework/serialize/SerializeIF.h>
/**
* @brief Subservice 1, 2, 3, 4, 5
* @ingroup spacepackets
*/
class ModePacket : public SerialLinkedListAdapter<SerializeIF> { //!< [EXPORT] : [SUBSERVICE] 1, 2, 6
public:
ModePacket() {
setLinks();
}
ModePacket(object_id_t objectId, Mode_t mode, Submode_t submode) :
objectId(objectId), mode(mode), submode(submode) {
setLinks();
}
Mode_t getMode() {
return mode.entry;
}
Submode_t getSubmode() {
return submode.entry;
}
// Forbid copying, pointers are used.
ModePacket(const ModePacket&) = delete;
ModePacket& operator=(const ModePacket&) = delete;
private:
void setLinks() {
setStart(&objectId);
objectId.setNext(&mode);
mode.setNext(&submode);
}
SerializeElement<object_id_t> objectId; //!< [EXPORT] : [COMMENT] Target or source object
SerializeElement<Mode_t> mode; //!< [EXPORT] : [COMMENT] 0: MODE_OFF, 1: MODE_ON, 2: MODE_NORMAL, 3: MODE_RAW
SerializeElement<Submode_t> submode; //!< [EXPORT] : [COMMENT] Usually 0, device specific submode possible
};
/**
* @brief Subservice 7
* @ingroup spacepackets
*/
class CantReachModePacket: public SerialLinkedListAdapter<SerializeIF> { //!< [EXPORT] : [SUBSERVICE] 7
public:
CantReachModePacket(object_id_t objectId, ReturnValue_t reason):
objectId(objectId), reason(reason) {
setStart(&this->objectId);
this->objectId.setNext(&this->reason);
}
SerializeElement<object_id_t> objectId; //!< [EXPORT] : [COMMENT] Reply source object
SerializeElement<ReturnValue_t> reason; //!< [EXPORT] : [COMMENT] Reason the mode could not be reached
};
#endif /* FRAMEWORK_PUS_SERVICEPACKETS_SERVICE200PACKETS_H_ */

View File

@ -0,0 +1,76 @@
#ifndef FRAMEWORK_PUS_SERVICEPACKETS_SERVICE2PACKETS_H_
#define FRAMEWORK_PUS_SERVICEPACKETS_SERVICE2PACKETS_H_
#include <framework/action/ActionMessage.h>
#include <framework/objectmanager/SystemObjectIF.h>
#include <framework/serialize/SerialLinkedListAdapter.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
/**
* @brief Subservice 128
* @ingroup spacepackets
*/
class RawCommand { //!< [EXPORT] : [SUBSERVICE] 128
public:
RawCommand(const uint8_t* buffer, size_t size) {
// Deserialize Adapter to get correct endianness
SerializeAdapter::deSerialize(&objectId, &buffer, &size,
SerializeIF::Endianness::BIG);
commandBuffer = buffer;
// size is decremented by AutoSerializeAdapter,
// remaining size is data size
dataSize = size;
}
object_id_t getObjectId() const {
return objectId;
}
const uint8_t* getCommand() {
return commandBuffer;
}
size_t getCommandSize() const {
return dataSize;
}
private:
object_id_t objectId = 0;
const uint8_t* commandBuffer = nullptr; //!< [EXPORT] : [MAXSIZE] 256 Bytes
size_t dataSize = 0; //!< [EXPORT] : [IGNORE]
};
/**
* @brief Subservice 129: Command packet to set wiretapping mode
* @ingroup spacepackets
*/
class WiretappingToggle: public SerialLinkedListAdapter<SerializeIF>{ //!< [EXPORT] : [SUBSERVICE] 129
public:
static const size_t WIRETAPPING_COMMAND_SIZE = 5;
WiretappingToggle(){
setStart(&objectId);
objectId.setNext(&wiretappingMode);
}
uint8_t getWiretappingMode() const {
return wiretappingMode.entry;
}
private:
SerializeElement<object_id_t> objectId;
SerializeElement<uint8_t> wiretappingMode; //!< [EXPORT] : [INPUT] Mode 0: OFF, Mode 1: RAW
};
/**
* @brief Subservices 130 and 131: TM packets
* @ingroup spacepackets
*/
class WiretappingPacket { //!< [EXPORT] : [SUBSERVICE] 130, 131
public:
object_id_t objectId; //!< [EXPORT] : [COMMENT] Object ID of source object
const uint8_t* data; //!< [EXPORT] : [MAXSIZE] Raw Command Max. Size
WiretappingPacket(object_id_t objectId, const uint8_t* buffer):
objectId(objectId), data(buffer) {
}
};
#endif /* FRAMEWORK_PUS_SERVICEPACKETS_SERVICE2PACKETS_H_ */

View File

@ -0,0 +1,76 @@
#ifndef MISSION_PUS_SERVICEPACKETS_SERVICE5PACKETS_H_
#define MISSION_PUS_SERVICEPACKETS_SERVICE5PACKETS_H_
#include <framework/serialize/SerializeAdapter.h>
#include <framework/tmtcservices/VerificationCodes.h>
/**
* @brief Subservice 1, 2, 3, 4
* Structure of Event Report.
* It consists of:
* 1. Report ID(RID). This is the Event ID in the FSFW
* 2. Object ID of the reporter (e.g. subsystem)
* 2. Parameter 1
* 3. Parameter 2
*
* @ingroup spacepackets
*/
class EventReport: public SerializeIF { //!< [EXPORT] : [SUBSERVICE] 1, 2, 3, 4
public:
EventReport(EventId_t reportId_, object_id_t objectId_, uint32_t parameter1_,
uint32_t parameter2_):
reportId(reportId_),objectId(objectId_), parameter1(parameter1_),
parameter2(parameter2_) {}
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size,
size_t maxSize,
SerializeIF::Endianness streamEndianness) const override
{
ReturnValue_t result = SerializeAdapter::serialize(&reportId, buffer,
size, maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = SerializeAdapter::serialize(&objectId, buffer, size,
maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = SerializeAdapter::serialize(&parameter1, buffer, size,
maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
result = SerializeAdapter::serialize(&parameter2, buffer, size,
maxSize, streamEndianness);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
return result;
}
virtual size_t getSerializedSize() const override {
uint32_t size = 0;
size += SerializeAdapter::getSerializedSize(&reportId);
size += SerializeAdapter::getSerializedSize(&objectId);
size += SerializeAdapter::getSerializedSize(&parameter1);
size += SerializeAdapter::getSerializedSize(&parameter2);
return size;
}
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
SerializeIF::Endianness streamEndianness) override {
return HasReturnvaluesIF::RETURN_FAILED;
}
private:
EventId_t reportId;
object_id_t objectId;
uint32_t parameter1;
uint32_t parameter2;
};
#endif /* MISSION_PUS_SERVICEPACKETS_SERVICE5PACKETS_H_ */

View File

@ -0,0 +1,121 @@
#ifndef FRAMEWORK_PUS_SERVICEPACKETS_SERVICE8PACKETS_H_
#define FRAMEWORK_PUS_SERVICEPACKETS_SERVICE8PACKETS_H_
#include <framework/action/ActionMessage.h>
#include <framework/objectmanager/SystemObjectIF.h>
#include <framework/serialize/SerialBufferAdapter.h>
#include <framework/serialize/SerializeElement.h>
#include <framework/serialize/SerialLinkedListAdapter.h>
#include <framework/serialize/SerialFixedArrayListAdapter.h>
/**
* @brief Subservice 128
* @ingroup spacepackets
*/
class DirectCommand: public SerialLinkedListAdapter<SerializeIF> { //!< [EXPORT] : [SUBSERVICE] 128
public:
DirectCommand(const uint8_t* tcData, size_t size) {
SerializeAdapter::deSerialize(&objectId, &tcData, &size,
SerializeIF::Endianness::BIG);
SerializeAdapter::deSerialize(&actionId, &tcData, &size,
SerializeIF::Endianness::BIG);
parameterBuffer = tcData;
parametersSize = size;
}
ActionId_t getActionId() const {
return actionId;
}
object_id_t getObjectId() const {
return objectId;
}
const uint8_t* getParameters() {
return parameterBuffer;
}
uint32_t getParametersSize() const {
return parametersSize;
}
private:
DirectCommand(const DirectCommand &command);
object_id_t objectId;
ActionId_t actionId;
uint32_t parametersSize; //!< [EXPORT] : [IGNORE]
const uint8_t * parameterBuffer; //!< [EXPORT] : [MAXSIZE] 65535 Bytes
};
/**
* @brief Subservice 130
* Data reply (subservice 130) consists of
* 1. Target Object ID
* 2. Action ID
* 3. Data
* @ingroup spacepackets
*/
class DataReply: public SerialLinkedListAdapter<SerializeIF> { //!< [EXPORT] : [SUBSERVICE] 130
public:
typedef uint16_t typeOfMaxDataSize;
static const uint16_t MAX_DATA_LENGTH = sizeof(typeOfMaxDataSize);
DataReply(object_id_t objectId_, ActionId_t actionId_,
const uint8_t * replyDataBuffer_ = NULL, uint16_t replyDataSize_ = 0):
objectId(objectId_), actionId(actionId_), replyData(replyDataBuffer_,replyDataSize_){
setLinks();
}
private:
DataReply(const DataReply &reply);
void setLinks() {
setStart(&objectId);
objectId.setNext(&actionId);
actionId.setNext(&replyData);
}
SerializeElement<object_id_t> objectId;
SerializeElement<ActionId_t> actionId;
SerializeElement<SerialBufferAdapter<uint16_t>> replyData;
};
/**
* @brief Subservice 132
* @details
* Not used yet. Telecommand Verification takes care of this.
* @ingroup spacepackets
*/
class DirectReply: public SerialLinkedListAdapter<SerializeIF> { //!< [EXPORT] : [SUBSERVICE] 132
public:
typedef uint16_t typeOfMaxDataSize;
static const uint16_t MAX_DATA_LENGTH = sizeof(typeOfMaxDataSize);
DirectReply(object_id_t objectId_, ActionId_t actionId_, ReturnValue_t returnCode_,
bool isStep_ = false, uint8_t step_ = 0):
isStep(isStep_), objectId(objectId_), actionId(actionId_),
returnCode(returnCode_),step(step_) {
setLinks();
}
private:
void setLinks() {
setStart(&objectId);
objectId.setNext(&actionId);
actionId.setNext(&returnCode);
if(isStep) {
returnCode.setNext(&step);
}
}
bool isStep; //!< [EXPORT] : [IGNORE]
SerializeElement<object_id_t> objectId; //!< [EXPORT] : [IGNORE]
SerializeElement<ActionId_t> actionId; //!< [EXPORT] : [IGNORE]
SerializeElement<ReturnValue_t> returnCode; //!< [EXPORT] : [IGNORE]
SerializeElement<uint8_t> step; //!< [EXPORT] : [OPTIONAL] [IGNORE]
};
#endif /* FRAMEWORK_PUS_SERVICEPACKETS_SERVICE8PACKETS_H_ */

View File

@ -8,18 +8,28 @@
#include <framework/tmtcpacket/pus/TcPacketStored.h> #include <framework/tmtcpacket/pus/TcPacketStored.h>
#include <framework/tmtcpacket/pus/TmPacketStored.h> #include <framework/tmtcpacket/pus/TmPacketStored.h>
object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT;
CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId,
uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands, uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands,
uint16_t commandTimeoutSeconds, object_id_t setPacketSource, uint16_t commandTimeoutSeconds, size_t queueDepth) :
object_id_t setPacketDestination, size_t queueDepth) :
SystemObject(setObjectId), apid(apid), service(service), SystemObject(setObjectId), apid(apid), service(service),
timeoutSeconds(commandTimeoutSeconds), timeoutSeconds(commandTimeoutSeconds),
commandMap(numberOfParallelCommands), packetSource(setPacketSource), commandMap(numberOfParallelCommands) {
packetDestination(setPacketDestination) {
commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
} }
void CommandingServiceBase::setPacketSource(object_id_t packetSource) {
this->packetSource = packetSource;
}
void CommandingServiceBase::setPacketDestination(
object_id_t packetDestination) {
this->packetDestination = packetDestination;
}
CommandingServiceBase::~CommandingServiceBase() { CommandingServiceBase::~CommandingServiceBase() {
QueueFactory::instance()->deleteMessageQueue(commandQueue); QueueFactory::instance()->deleteMessageQueue(commandQueue);
@ -52,10 +62,18 @@ ReturnValue_t CommandingServiceBase::initialize() {
return result; return result;
} }
if(packetDestination == objects::NO_OBJECT) {
packetDestination = defaultPacketDestination;
}
AcceptsTelemetryIF* packetForwarding = AcceptsTelemetryIF* packetForwarding =
objectManager->get<AcceptsTelemetryIF>(packetDestination); objectManager->get<AcceptsTelemetryIF>(packetDestination);
if(packetSource == objects::NO_OBJECT) {
packetSource = defaultPacketSource;
}
PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>( PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>(
packetSource); packetSource);
if (packetForwarding == nullptr or distributor == nullptr) { if (packetForwarding == nullptr or distributor == nullptr) {
sif::error << "CommandingServiceBase::intialize: Packet source or " sif::error << "CommandingServiceBase::intialize: Packet source or "
"packet destination invalid!" << std::endl; "packet destination invalid!" << std::endl;
@ -108,11 +126,11 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
&nextCommand, iter->second.objectId, &isStep); &nextCommand, iter->second.objectId, &isStep);
/* If the child implementation does not implement special handling for /* If the child implementation does not implement special handling for
* rejected replies (RETURN_FAILED is returned), a failure verification * rejected replies (RETURN_FAILED or INVALID_REPLY is returned), a
* will be generated with the reason as the return code and the initial * failure verification will be generated with the reason as the
* command as failure parameter 1 */ * return code and the initial command as failure parameter 1 */
if(reply->getCommand() == CommandMessage::REPLY_REJECTED and if((reply->getCommand() == CommandMessage::REPLY_REJECTED) and
result == RETURN_FAILED) { (result == RETURN_FAILED or result == INVALID_REPLY)) {
result = reply->getReplyRejectedReason(); result = reply->getReplyRejectedReason();
failureParameter1 = iter->second.command; failureParameter1 = iter->second.command;
} }

View File

@ -15,6 +15,10 @@
class TcPacketStored; class TcPacketStored;
namespace Factory{
void setStaticFrameworkObjectIds();
}
/** /**
* @brief This class is the basis for all PUS Services, which have to * @brief This class is the basis for all PUS Services, which have to
* relay Telecommands to software bus. * relay Telecommands to software bus.
@ -33,6 +37,7 @@ class CommandingServiceBase: public SystemObject,
public AcceptsTelecommandsIF, public AcceptsTelecommandsIF,
public ExecutableObjectIF, public ExecutableObjectIF,
public HasReturnvaluesIF { public HasReturnvaluesIF {
friend void (Factory::setStaticFrameworkObjectIds)();
public: public:
static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE; static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE;
static const ReturnValue_t EXECUTION_COMPLETE = MAKE_RETURN_CODE(1); static const ReturnValue_t EXECUTION_COMPLETE = MAKE_RETURN_CODE(1);
@ -57,10 +62,24 @@ public:
*/ */
CommandingServiceBase(object_id_t setObjectId, uint16_t apid, CommandingServiceBase(object_id_t setObjectId, uint16_t apid,
uint8_t service, uint8_t numberOfParallelCommands, uint8_t service, uint8_t numberOfParallelCommands,
uint16_t commandTimeoutSeconds, object_id_t setPacketSource, uint16_t commandTimeoutSeconds, size_t queueDepth = 20);
object_id_t setPacketDestination, size_t queueDepth = 20);
virtual ~CommandingServiceBase(); virtual ~CommandingServiceBase();
/**
* This setter can be used to set the packet source individually instead
* of using the default static framework ID set in the factory.
* This should be called at object initialization and not during run-time!
* @param packetSource
*/
void setPacketSource(object_id_t packetSource);
/**
* This setter can be used to set the packet destination individually
* instead of using the default static framework ID set in the factory.
* This should be called at object initialization and not during run-time!
* @param packetDestination
*/
void setPacketDestination(object_id_t packetDestination);
/*** /***
* This is the periodically called function. * This is the periodically called function.
* Handle request queue for external commands. * Handle request queue for external commands.
@ -68,7 +87,7 @@ public:
* @param opCode is unused here at the moment * @param opCode is unused here at the moment
* @return RETURN_OK * @return RETURN_OK
*/ */
virtual ReturnValue_t performOperation(uint8_t opCode); virtual ReturnValue_t performOperation(uint8_t opCode) override;
virtual uint16_t getIdentifier(); virtual uint16_t getIdentifier();
@ -89,22 +108,23 @@ public:
*/ */
virtual MessageQueueId_t getCommandQueue(); virtual MessageQueueId_t getCommandQueue();
virtual ReturnValue_t initialize(); virtual ReturnValue_t initialize() override;
/** /**
* Implementation of ExecutableObjectIF function * Implementation of ExecutableObjectIF function
* *
* Used to setup the reference of the task, that executes this component * Used to setup the reference of the task, that executes this component
* @param task_ Pointer to the taskIF of this task * @param task Pointer to the taskIF of this task
*/ */
virtual void setTaskIF(PeriodicTaskIF* task_); virtual void setTaskIF(PeriodicTaskIF* task) override;
protected: protected:
/** /**
* Check the target subservice * Check the target subservice
* @param subservice[in] * @param subservice[in]
* @return -@c RETURN_OK on success * @return
* -@c INVALID_SUBSERVICE if service is not known * -@c RETURN_OK Subservice valid, continue message handling
* -@c INVALID_SUBSERVICE if service is not known, rejects packet.
*/ */
virtual ReturnValue_t isValidSubservice(uint8_t subservice) = 0; virtual ReturnValue_t isValidSubservice(uint8_t subservice) = 0;
@ -117,9 +137,10 @@ protected:
* @param tcDataLen * @param tcDataLen
* @param id MessageQueue ID is stored here * @param id MessageQueue ID is stored here
* @param objectId Object ID is extracted and stored here * @param objectId Object ID is extracted and stored here
* @return - @c RETURN_OK on success * @return
* - @c RETURN_FAILED * - @c RETURN_OK Cotinue message handling
* - @c CSB or implementation specific return codes * - @c RETURN_FAILED Reject the packet and generates a start failure
* verification
*/ */
virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice, virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice,
const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id, const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id,
@ -138,6 +159,11 @@ protected:
* communication * communication
* @param objectId Target object ID * @param objectId Target object ID
* @return * @return
* - @c RETURN_OK to generate a verification start message
* - @c EXECUTION_COMPELTE Fire-and-forget command. Generate a completion
* verification message.
* - @c Anything else rejects the packets and generates a start failure
* verification.
*/ */
virtual ReturnValue_t prepareCommand(CommandMessage* message, virtual ReturnValue_t prepareCommand(CommandMessage* message,
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
@ -160,11 +186,12 @@ protected:
* @return * @return
* - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to * - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to
* generate TC verification success * generate TC verification success
* - @c INVALID_REPLY calls handleUnrequestedReply * - @c INVALID_REPLY Calls handleUnrequestedReply
* - Anything else triggers a TC verification failure. If RETURN_FAILED * - Anything else triggers a TC verification failure. If RETURN_FAILED or
* is returned and the command ID is CommandMessage::REPLY_REJECTED, * INVALID_REPLY is returned and the command ID is
* a failure verification message with the reason as the error parameter * CommandMessage::REPLY_REJECTED, a failure verification message with
* and the initial command as failure parameter 1. * the reason as the error parameter and the initial command as
* failure parameter 1 is generated.
*/ */
virtual ReturnValue_t handleReply(const CommandMessage* reply, virtual ReturnValue_t handleReply(const CommandMessage* reply,
Command_t previousCommand, uint32_t *state, Command_t previousCommand, uint32_t *state,
@ -227,9 +254,10 @@ protected:
uint32_t failureParameter1 = 0; uint32_t failureParameter1 = 0;
uint32_t failureParameter2 = 0; uint32_t failureParameter2 = 0;
object_id_t packetSource; static object_id_t defaultPacketSource;
object_id_t packetSource = objects::NO_OBJECT;
object_id_t packetDestination; static object_id_t defaultPacketDestination;
object_id_t packetDestination = objects::NO_OBJECT;
/** /**
* Pointer to the task which executes this component, * Pointer to the task which executes this component,
@ -274,7 +302,6 @@ protected:
void checkAndExecuteFifo(CommandMapIter iter); void checkAndExecuteFifo(CommandMapIter iter);
private: private:
/** /**
* This method handles internal execution of a command, * This method handles internal execution of a command,
* once it has been started by @sa{startExecution()} in the request * once it has been started by @sa{startExecution()} in the request
@ -294,10 +321,13 @@ private:
void handleCommandQueue(); void handleCommandQueue();
/** /**
* @brief Handler function for request queue
* @details
* Sequence of request queue handling: * Sequence of request queue handling:
* isValidSubservice -> getMessageQueueAndObject -> startExecution * isValidSubservice -> getMessageQueueAndObject -> startExecution
* Generates Start Success Reports TM[1,3] in subfunction @sa{startExecution()} * Generates a Start Success Reports TM[1,3] in subfunction
* or Start Failure Report TM[1,4] by using the TC Verification Service * @sa{startExecution()} or a Start Failure Report TM[1,4] by using the
* TC Verification Service.
*/ */
void handleRequestQueue(); void handleRequestQueue();