added srv200, CSB doc
This commit is contained in:
parent
cdd877032f
commit
1fde3c2c99
133
pus/CService200ModeCommanding.cpp
Normal file
133
pus/CService200ModeCommanding.cpp
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
#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)
|
||||||
|
{
|
||||||
|
ReturnValue_t result = checkAndAcquireTargetID(objectId,tcData,tcDataLen);
|
||||||
|
if (result != RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = checkInterfaceAndAcquireMessageQueue(id,objectId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CService200ModeCommanding::checkAndAcquireTargetID(
|
||||||
|
object_id_t* objectIdToSet, const uint8_t* tcData, uint32_t tcDataLen) {
|
||||||
|
size_t size = tcDataLen;
|
||||||
|
if (SerializeAdapter::deSerialize(objectIdToSet, &tcData, &size,
|
||||||
|
SerializeIF::Endianness::BIG)
|
||||||
|
!= HasReturnvaluesIF::RETURN_OK)
|
||||||
|
return CommandingServiceBase::INVALID_TC;
|
||||||
|
else
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t CService200ModeCommanding::checkInterfaceAndAcquireMessageQueue(
|
||||||
|
MessageQueueId_t* MessageQueueToSet, object_id_t* objectId) {
|
||||||
|
HasModesIF * possibleTarget = objectManager->get<HasModesIF>(*objectId);
|
||||||
|
if(possibleTarget!=NULL){
|
||||||
|
*MessageQueueToSet = possibleTarget->getCommandQueue();
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
} else {
|
||||||
|
return CommandingServiceBase::INVALID_OBJECT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
85
pus/CService200ModeCommanding.h
Normal file
85
pus/CService200ModeCommanding.h
Normal 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_ */
|
56
pus/servicepackets/Service200Packets.h
Normal file
56
pus/servicepackets/Service200Packets.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Forbid copying because of next pointer to member
|
||||||
|
ModePacket(const ModePacket &command);
|
||||||
|
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
|
||||||
|
};
|
||||||
|
|
||||||
|
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_ */
|
@ -34,6 +34,7 @@ TmPacketStored::TmPacketStored(uint16_t apid, uint8_t service,
|
|||||||
size + headerSize + sizeof(PUSTmDataFieldHeader) + CRC_SIZE - 1);
|
size + headerSize + sizeof(PUSTmDataFieldHeader) + CRC_SIZE - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo: Endianness flags as optional parameter?
|
||||||
TmPacketStored::TmPacketStored(uint16_t apid, uint8_t service,
|
TmPacketStored::TmPacketStored(uint16_t apid, uint8_t service,
|
||||||
uint8_t subservice, uint8_t packetSubcounter, SerializeIF *content,
|
uint8_t subservice, uint8_t packetSubcounter, SerializeIF *content,
|
||||||
SerializeIF *header) :
|
SerializeIF *header) :
|
||||||
|
@ -114,16 +114,17 @@ public:
|
|||||||
* 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);
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@ -136,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,
|
||||||
@ -157,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,
|
||||||
@ -181,7 +188,7 @@ 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
|
||||||
* is returned and the command ID is CommandMessage::REPLY_REJECTED,
|
* is returned and the command ID is CommandMessage::REPLY_REJECTED,
|
||||||
* a failure verification message with the reason as the error parameter
|
* a failure verification message with the reason as the error parameter
|
||||||
|
Loading…
Reference in New Issue
Block a user