form improvements DHB

This commit is contained in:
Robin Müller 2020-10-12 18:18:41 +02:00
parent 335e146735
commit 140aa3ab42
19 changed files with 403 additions and 303 deletions

View File

@ -1,23 +1,19 @@
/** #ifndef FSFW_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_
* @file AcceptsDeviceResponsesIF.h #define FSFW_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_
* @brief This file defines the AcceptsDeviceResponsesIF class.
* @date 15.05.2013
* @author baetz
*/
#ifndef ACCEPTSDEVICERESPONSESIF_H_
#define ACCEPTSDEVICERESPONSESIF_H_
#include "../ipc/MessageQueueSenderIF.h" #include "../ipc/MessageQueueSenderIF.h"
/**
* This interface is used by the device handler to send a device response
* to the queue ID, which is returned in the implemented abstract method.
*/
class AcceptsDeviceResponsesIF { class AcceptsDeviceResponsesIF {
public: public:
/** /**
* Default empty virtual destructor. * Default empty virtual destructor.
*/ */
virtual ~AcceptsDeviceResponsesIF() { virtual ~AcceptsDeviceResponsesIF() {}
} virtual MessageQueueId_t getDeviceQueue() = 0;
virtual MessageQueueId_t getDeviceQueue() = 0;
}; };
#endif /* ACCEPTSDEVICERESPONSESIF_H_ */ #endif /* FSFW_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_ */

View File

@ -2,10 +2,10 @@
AssemblyBase::AssemblyBase(object_id_t objectId, object_id_t parentId, AssemblyBase::AssemblyBase(object_id_t objectId, object_id_t parentId,
uint16_t commandQueueDepth) : uint16_t commandQueueDepth) :
SubsystemBase(objectId, parentId, MODE_OFF, commandQueueDepth), internalState( SubsystemBase(objectId, parentId, MODE_OFF, commandQueueDepth),
STATE_NONE), recoveryState(RECOVERY_IDLE), recoveringDevice( internalState(STATE_NONE), recoveryState(RECOVERY_IDLE),
childrenMap.end()), targetMode(MODE_OFF), targetSubmode( recoveringDevice(childrenMap.end()), targetMode(MODE_OFF),
SUBMODE_NONE) { targetSubmode(SUBMODE_NONE) {
recoveryOffTimer.setTimeout(POWER_OFF_TIME_MS); recoveryOffTimer.setTimeout(POWER_OFF_TIME_MS);
} }
@ -165,9 +165,8 @@ ReturnValue_t AssemblyBase::checkChildrenState() {
} }
ReturnValue_t AssemblyBase::checkChildrenStateOff() { ReturnValue_t AssemblyBase::checkChildrenStateOff() {
for (std::map<object_id_t, ChildInfo>::iterator iter = childrenMap.begin(); for (const auto& childIter: childrenMap) {
iter != childrenMap.end(); iter++) { if (checkChildOff(childIter.first) != RETURN_OK) {
if (checkChildOff(iter->first) != RETURN_OK) {
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE; return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
} }
} }

View File

@ -1,10 +1,30 @@
#ifndef ASSEMBLYBASE_H_ #ifndef FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_
#define ASSEMBLYBASE_H_ #define FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_
#include "../container/FixedArrayList.h"
#include "DeviceHandlerBase.h" #include "DeviceHandlerBase.h"
#include "../container/FixedArrayList.h"
#include "../subsystem/SubsystemBase.h" #include "../subsystem/SubsystemBase.h"
/**
* @brief Base class to implement reconfiguration and failure handling for
* redundant devices by monitoring their modes health states.
* @details
* Documentation: Dissertation Baetz p.156, 157.
*
* This class reduces the complexity of controller components which would
* otherwise be needed for the handling of redundant devices.
*
* The template class monitors mode and health state of its children
* and checks availability of devices on every detected change.
* AssemblyBase does not implement any redundancy logic by itself, but provides
* adaptation points for implementations to do so. Since most monitoring
* activities rely on mode and health state only and are therefore
* generic, it is sufficient for subclasses to provide:
*
* 1. check logic when active-> checkChildrenStateOn
* 2. transition logic to change the mode -> commandChildren
*
*/
class AssemblyBase: public SubsystemBase { class AssemblyBase: public SubsystemBase {
public: public:
static const uint8_t INTERFACE_ID = CLASS_ID::ASSEMBLY_BASE; static const uint8_t INTERFACE_ID = CLASS_ID::ASSEMBLY_BASE;
@ -16,10 +36,41 @@ public:
static const ReturnValue_t NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE = static const ReturnValue_t NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE =
MAKE_RETURN_CODE(0xa1); MAKE_RETURN_CODE(0xa1);
AssemblyBase(object_id_t objectId, object_id_t parentId, uint16_t commandQueueDepth = 8); AssemblyBase(object_id_t objectId, object_id_t parentId,
uint16_t commandQueueDepth = 8);
virtual ~AssemblyBase(); virtual ~AssemblyBase();
protected: protected:
// SHOULDDO: Change that OVERWRITE_HEALTH may be returned
// (or return internalState directly?)
/**
* Command children to reach [mode,submode] combination
* Can be done by setting #commandsOutstanding correctly,
* or using executeTable()
* @param mode
* @param submode
* @return
* - @c RETURN_OK if ok
* - @c NEED_SECOND_STEP if children need to be commanded again
*/
virtual ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) = 0;
/**
* Check whether desired assembly mode was achieved by checking the modes
* or/and health states of child device handlers.
* The assembly template class will also call this function if a health
* or mode change of a child device handler was detected.
* @param wantedMode
* @param wantedSubmode
* @return
*/
virtual ReturnValue_t checkChildrenStateOn(Mode_t wantedMode,
Submode_t wantedSubmode) = 0;
virtual ReturnValue_t isModeCombinationValid(Mode_t mode,
Submode_t submode) = 0;
enum InternalState { enum InternalState {
STATE_NONE, STATE_NONE,
STATE_OVERWRITE_HEALTH, STATE_OVERWRITE_HEALTH,
@ -36,6 +87,7 @@ protected:
RECOVERY_WAIT RECOVERY_WAIT
} recoveryState; //!< Indicates if one of the children requested a recovery. } recoveryState; //!< Indicates if one of the children requested a recovery.
ChildrenMap::iterator recoveringDevice; ChildrenMap::iterator recoveringDevice;
/** /**
* the mode the current transition is trying to achieve. * the mode the current transition is trying to achieve.
* Can be different from the modehelper.commandedMode! * Can be different from the modehelper.commandedMode!
@ -61,8 +113,8 @@ protected:
bool handleChildrenChanged(); bool handleChildrenChanged();
/** /**
* This method is called if the children changed its mode in a way that the current * This method is called if the children changed its mode in a way that
* mode can't be kept. * the current mode can't be kept.
* Default behavior is to go to MODE_OFF. * Default behavior is to go to MODE_OFF.
* @param result The failure code which was returned by checkChildrenState. * @param result The failure code which was returned by checkChildrenState.
*/ */
@ -75,9 +127,6 @@ protected:
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode); uint32_t *msToReachTheMode);
virtual ReturnValue_t isModeCombinationValid(Mode_t mode,
Submode_t submode) = 0;
virtual void startTransition(Mode_t mode, Submode_t submode); virtual void startTransition(Mode_t mode, Submode_t submode);
virtual void doStartTransition(Mode_t mode, Submode_t submode); virtual void doStartTransition(Mode_t mode, Submode_t submode);
@ -90,24 +139,6 @@ protected:
void sendHealthCommand(MessageQueueId_t sendTo, HealthState health); void sendHealthCommand(MessageQueueId_t sendTo, HealthState health);
//SHOULDDO: Change that OVERWRITE_HEALTH may be returned (or return internalState directly?)
/**
* command children to reach mode,submode
*
* set #commandsOutstanding correctly, or use executeTable()
*
* @param mode
* @param submode
* @return
* - @c RETURN_OK if ok
* - @c NEED_SECOND_STEP if children need to be commanded again
*/
virtual ReturnValue_t commandChildren(Mode_t mode, Submode_t submode) = 0;
//SHOULDDO: Remove wantedMode, wantedSubmode, as targetMode/submode is available?
virtual ReturnValue_t checkChildrenStateOn(Mode_t wantedMode,
Submode_t wantedSubmode) = 0;
virtual ReturnValue_t checkChildrenStateOff(); virtual ReturnValue_t checkChildrenStateOff();
ReturnValue_t checkChildrenState(); ReturnValue_t checkChildrenState();
@ -125,8 +156,9 @@ protected:
* Also sets state to STATE_OVERWRITE_HEATH. * Also sets state to STATE_OVERWRITE_HEATH.
* @param objectId Must be a registered child. * @param objectId Must be a registered child.
*/ */
void overwriteDeviceHealth(object_id_t objectId, HasHealthIF::HealthState oldHealth); void overwriteDeviceHealth(object_id_t objectId,
HasHealthIF::HealthState oldHealth);
}; };
#endif /* ASSEMBLYBASE_H_ */ #endif /* FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_ */

View File

@ -1,16 +1,18 @@
#include "ChildHandlerBase.h"
#include "../subsystem/SubsystemBase.h" #include "../subsystem/SubsystemBase.h"
#include "../devicehandlers/ChildHandlerBase.h"
#include "../subsystem/SubsystemBase.h" #include "../subsystem/SubsystemBase.h"
ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId, ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId,
object_id_t deviceCommunication, CookieIF * cookie, object_id_t deviceCommunication, CookieIF * cookie,
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, object_id_t hkDestination, uint32_t thermalStatePoolId,
object_id_t parent, FailureIsolationBase* customFdir, uint32_t thermalRequestPoolId,
size_t cmdQueueSize) : object_id_t parent,
FailureIsolationBase* customFdir, size_t cmdQueueSize) :
DeviceHandlerBase(setObjectId, deviceCommunication, cookie, DeviceHandlerBase(setObjectId, deviceCommunication, cookie,
(customFdir == nullptr? &childHandlerFdir : customFdir), (customFdir == nullptr? &childHandlerFdir : customFdir),
cmdQueueSize), cmdQueueSize),
parentId(parent), childHandlerFdir(setObjectId) { parentId(parent), childHandlerFdir(setObjectId) {
this->setHkDestination(hkDestination);
this->setThermalStateRequestPoolIds(thermalStatePoolId, this->setThermalStateRequestPoolIds(thermalStatePoolId,
thermalRequestPoolId); thermalRequestPoolId);

View File

@ -1,17 +1,18 @@
#ifndef FSFW_DEVICES_CHILDHANDLERBASE_H_ #ifndef FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
#define FSFW_DEVICES_CHILDHANDLERBASE_H_ #define FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
#include "ChildHandlerFDIR.h"
#include "DeviceHandlerBase.h" #include "DeviceHandlerBase.h"
#include "ChildHandlerFDIR.h"
class ChildHandlerBase: public DeviceHandlerBase { class ChildHandlerBase: public DeviceHandlerBase {
public: public:
ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication, ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication,
CookieIF * cookie, uint32_t thermalStatePoolId, CookieIF * cookie, object_id_t hkDestination,
uint32_t thermalRequestPoolId, uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId,
object_id_t parent = objects::NO_OBJECT, object_id_t parent = objects::NO_OBJECT,
FailureIsolationBase* customFdir = nullptr, FailureIsolationBase* customFdir = nullptr,
size_t cmdQueueSize = 20); size_t cmdQueueSize = 20);
virtual ~ChildHandlerBase(); virtual ~ChildHandlerBase();
virtual ReturnValue_t initialize(); virtual ReturnValue_t initialize();
@ -22,5 +23,4 @@ protected:
}; };
#endif /* FSFW_DEVICES_CHILDHANDLERBASE_H_ */ #endif /* FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_ */

View File

@ -1,6 +1,7 @@
#include "ChildHandlerFDIR.h" #include "ChildHandlerFDIR.h"
ChildHandlerFDIR::ChildHandlerFDIR(object_id_t owner, object_id_t faultTreeParent, uint32_t recoveryCount) : ChildHandlerFDIR::ChildHandlerFDIR(object_id_t owner,
object_id_t faultTreeParent, uint32_t recoveryCount) :
DeviceHandlerFailureIsolation(owner, faultTreeParent) { DeviceHandlerFailureIsolation(owner, faultTreeParent) {
recoveryCounter.setFailureThreshold(recoveryCount); recoveryCounter.setFailureThreshold(recoveryCount);
} }

View File

@ -1,5 +1,5 @@
#ifndef FRAMEWORK_DEVICEHANDLERS_CHILDHANDLERFDIR_H_ #ifndef FSFW_DEVICEHANDLERS_CHILDHANDLERFDIR_H_
#define FRAMEWORK_DEVICEHANDLERS_CHILDHANDLERFDIR_H_ #define FSFW_DEVICEHANDLERS_CHILDHANDLERFDIR_H_
#include "DeviceHandlerFailureIsolation.h" #include "DeviceHandlerFailureIsolation.h"

View File

@ -1,11 +1,12 @@
#ifndef COOKIE_H_ #ifndef FSFW_DEVICEHANDLER_COOKIE_H_
#define COOKIE_H_ #define FSFW_DEVICEHANDLER_COOKIE_H_
#include <cstdint> #include <cstdint>
/** /**
* @brief Physical address type * @brief Physical address type
*/ */
typedef std::uint32_t address_t; using address_t = uint32_t;
/** /**
* @brief This datatype is used to identify different connection over a * @brief This datatype is used to identify different connection over a
@ -16,7 +17,6 @@ typedef std::uint32_t address_t;
* calling @code{.cpp} CookieIF* childCookie = new ChildCookie(...) * calling @code{.cpp} CookieIF* childCookie = new ChildCookie(...)
* @endcode . * @endcode .
* *
* [not implemented yet]
* This cookie is then passed to the child device handlers, which stores the * This cookie is then passed to the child device handlers, which stores the
* pointer and passes it to the communication interface functions. * pointer and passes it to the communication interface functions.
* *
@ -31,4 +31,4 @@ public:
virtual ~CookieIF() {}; virtual ~CookieIF() {};
}; };
#endif /* COOKIE_H_ */ #endif /* FSFW_DEVICEHANDLER_COOKIE_H_ */

View File

@ -1,9 +1,10 @@
#ifndef DEVICECOMMUNICATIONIF_H_ #ifndef FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_
#define DEVICECOMMUNICATIONIF_H_ #define FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_
#include "CookieIF.h" #include "CookieIF.h"
#include "DeviceHandlerIF.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include <cstddef>
/** /**
* @defgroup interfaces Interfaces * @defgroup interfaces Interfaces
* @brief Interfaces for flight software objects * @brief Interfaces for flight software objects
@ -19,8 +20,8 @@
* the device handler to allow reuse of these components. * the device handler to allow reuse of these components.
* @details * @details
* Documentation: Dissertation Baetz p.138. * Documentation: Dissertation Baetz p.138.
* It works with the assumption that received data * It works with the assumption that received data is polled by a component.
* is polled by a component. There are four generic steps of device communication: * There are four generic steps of device communication:
* *
* 1. Send data to a device * 1. Send data to a device
* 2. Get acknowledgement for sending * 2. Get acknowledgement for sending
@ -38,24 +39,20 @@ class DeviceCommunicationIF: public HasReturnvaluesIF {
public: public:
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_COMMUNICATION_IF; static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_COMMUNICATION_IF;
//! Standard Error Codes //! This is returned in readReceivedMessage() if no reply was reived.
static const ReturnValue_t NO_REPLY_RECEIVED = MAKE_RETURN_CODE(0x01);
//! General protocol error. Define more concrete errors in child handler //! General protocol error. Define more concrete errors in child handler
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x01); static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0x02);
//! If cookie is a null pointer //! If cookie is a null pointer
static const ReturnValue_t NULLPOINTER = MAKE_RETURN_CODE(0x02); static const ReturnValue_t NULLPOINTER = MAKE_RETURN_CODE(0x03);
static const ReturnValue_t INVALID_COOKIE_TYPE = MAKE_RETURN_CODE(0x03); static const ReturnValue_t INVALID_COOKIE_TYPE = MAKE_RETURN_CODE(0x04);
// is this needed if there is no open/close call? // is this needed if there is no open/close call?
static const ReturnValue_t NOT_ACTIVE = MAKE_RETURN_CODE(0x05); static const ReturnValue_t NOT_ACTIVE = MAKE_RETURN_CODE(0x05);
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0x06); static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x06);
static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x07);
static const ReturnValue_t CANT_CHANGE_REPLY_LEN = MAKE_RETURN_CODE(0x08);
//! Can be used in readReceivedMessage() if no reply was received.
static const ReturnValue_t NO_REPLY_RECEIVED = MAKE_RETURN_CODE(0xA1);
virtual ~DeviceCommunicationIF() {} virtual ~DeviceCommunicationIF() {}
/** /**
* @brief Device specific initialization, using the cookie. * @brief Device specific initialization, using the cookie.
* @details * @details
@ -76,13 +73,13 @@ public:
* by implementing and calling related drivers or wrapper functions. * by implementing and calling related drivers or wrapper functions.
* @param cookie * @param cookie
* @param data * @param data
* @param len * @param len If this is 0, nothing shall be sent.
* @return * @return
* - @c RETURN_OK for successfull send * - @c RETURN_OK for successfull send
* - Everything else triggers failure event with returnvalue as parameter 1 * - Everything else triggers failure event with returnvalue as parameter 1
*/ */
virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData, virtual ReturnValue_t sendMessage(CookieIF *cookie,
size_t sendLen) = 0; const uint8_t * sendData, size_t sendLen) = 0;
/** /**
* Called by DHB in the GET_WRITE doGetWrite(). * Called by DHB in the GET_WRITE doGetWrite().
@ -124,8 +121,8 @@ public:
* - Everything else triggers failure event with * - Everything else triggers failure event with
* returnvalue as parameter 1 * returnvalue as parameter 1
*/ */
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, virtual ReturnValue_t readReceivedMessage(CookieIF *cookie,
size_t *size) = 0; uint8_t **buffer, size_t *size) = 0;
}; };
#endif /* DEVICECOMMUNICATIONIF_H_ */ #endif /* FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_ */

View File

@ -2,15 +2,17 @@
#include "AcceptsDeviceResponsesIF.h" #include "AcceptsDeviceResponsesIF.h"
#include "DeviceTmReportingWrapper.h" #include "DeviceTmReportingWrapper.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../datapoolglob/GlobalDataSet.h"
#include "../datapoolglob/GlobalPoolVariable.h"
#include "../objectmanager/ObjectManager.h" #include "../objectmanager/ObjectManager.h"
#include "../storagemanager/StorageManagerIF.h" #include "../storagemanager/StorageManagerIF.h"
#include "../thermal/ThermalComponentIF.h" #include "../thermal/ThermalComponentIF.h"
#include "../datapool/DataSet.h"
#include "../datapool/PoolVariable.h"
#include "../globalfunctions/CRC.h" #include "../globalfunctions/CRC.h"
#include "../subsystem/SubsystemBase.h" #include "../housekeeping/HousekeepingMessage.h"
#include "../ipc/MessageQueueMessage.h"
#include "../ipc/QueueFactory.h" #include "../ipc/QueueFactory.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../subsystem/SubsystemBase.h"
#include <iomanip> #include <iomanip>
@ -25,10 +27,11 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId,
wiretappingMode(OFF), storedRawData(StorageManagerIF::INVALID_ADDRESS), wiretappingMode(OFF), storedRawData(StorageManagerIF::INVALID_ADDRESS),
deviceCommunicationId(deviceCommunication), comCookie(comCookie), deviceCommunicationId(deviceCommunication), comCookie(comCookie),
healthHelper(this,setObjectId), modeHelper(this), parameterHelper(this), healthHelper(this,setObjectId), modeHelper(this), parameterHelper(this),
actionHelper(this, nullptr), childTransitionFailure(RETURN_OK), actionHelper(this, nullptr), hkManager(this, nullptr),
fdirInstance(fdirInstance), hkSwitcher(this), childTransitionFailure(RETURN_OK), fdirInstance(fdirInstance),
defaultFDIRUsed(fdirInstance == nullptr), switchOffWasReported(false), hkSwitcher(this), defaultFDIRUsed(fdirInstance == nullptr),
childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN), switchOffWasReported(false), childTransitionDelay(5000),
transitionSourceMode(_MODE_POWER_DOWN),
transitionSourceSubMode(SUBMODE_NONE) { transitionSourceSubMode(SUBMODE_NONE) {
commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize, commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize,
MessageQueueMessage::MAX_MESSAGE_SIZE); MessageQueueMessage::MAX_MESSAGE_SIZE);
@ -48,6 +51,10 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId,
} }
} }
void DeviceHandlerBase::setHkDestination(object_id_t hkDestination) {
this->hkDestination = hkDestination;
}
void DeviceHandlerBase::setThermalStateRequestPoolIds( void DeviceHandlerBase::setThermalStateRequestPoolIds(
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId) { uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId) {
this->deviceThermalRequestPoolId = thermalStatePoolId; this->deviceThermalRequestPoolId = thermalStatePoolId;
@ -74,6 +81,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
decrementDeviceReplyMap(); decrementDeviceReplyMap();
fdirInstance->checkForFailures(); fdirInstance->checkForFailures();
hkSwitcher.performOperation(); hkSwitcher.performOperation();
hkManager.performHkOperation();
performOperationHook(); performOperationHook();
} }
if (mode == MODE_OFF) { if (mode == MODE_OFF) {
@ -120,6 +128,8 @@ ReturnValue_t DeviceHandlerBase::initialize() {
result = communicationInterface->initializeInterface(comCookie); result = communicationInterface->initializeInterface(comCookie);
if (result != RETURN_OK) { if (result != RETURN_OK) {
sif::error << "DeviceHandlerBase::initialize: Initializing "
"communication interface failed!" << std::endl;
return result; return result;
} }
@ -183,11 +193,16 @@ ReturnValue_t DeviceHandlerBase::initialize() {
return result; return result;
} }
result = hkManager.initialize(commandQueue);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
fillCommandAndReplyMap(); fillCommandAndReplyMap();
//Set temperature target state to NON_OP. //Set temperature target state to NON_OP.
DataSet mySet; GlobDataSet mySet;
db_int8_t thermalRequest(deviceThermalRequestPoolId, &mySet, gp_uint8_t thermalRequest(deviceThermalRequestPoolId, &mySet,
PoolVariableIF::VAR_WRITE); PoolVariableIF::VAR_WRITE);
mySet.read(); mySet.read();
thermalRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL; thermalRequest = ThermalComponentIF::STATE_REQUEST_NON_OPERATIONAL;
@ -245,10 +260,10 @@ void DeviceHandlerBase::readCommandQueue() {
return; return;
} }
// result = hkManager.handleHousekeepingMessage(&command); result = hkManager.handleHousekeepingMessage(&command);
// if (result == RETURN_OK) { if (result == RETURN_OK) {
// return; return;
// } }
result = handleDeviceHandlerMessage(&command); result = handleDeviceHandlerMessage(&command);
if (result == RETURN_OK) { if (result == RETURN_OK) {
@ -376,24 +391,28 @@ ReturnValue_t DeviceHandlerBase::isModeCombinationValid(Mode_t mode,
ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap( ReturnValue_t DeviceHandlerBase::insertInCommandAndReplyMap(
DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles, DeviceCommandId_t deviceCommand, uint16_t maxDelayCycles,
size_t replyLen, bool periodic, bool hasDifferentReplyId, LocalPoolDataSetBase* replyDataSet, size_t replyLen, bool periodic,
DeviceCommandId_t replyId) { bool hasDifferentReplyId, DeviceCommandId_t replyId) {
//No need to check, as we may try to insert multiple times. //No need to check, as we may try to insert multiple times.
insertInCommandMap(deviceCommand); insertInCommandMap(deviceCommand);
if (hasDifferentReplyId) { if (hasDifferentReplyId) {
return insertInReplyMap(replyId, maxDelayCycles, replyLen, periodic); return insertInReplyMap(replyId, maxDelayCycles,
replyDataSet, replyLen, periodic);
} else { } else {
return insertInReplyMap(deviceCommand, maxDelayCycles, replyLen, periodic); return insertInReplyMap(deviceCommand, maxDelayCycles,
replyDataSet, replyLen, periodic);
} }
} }
ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId, ReturnValue_t DeviceHandlerBase::insertInReplyMap(DeviceCommandId_t replyId,
uint16_t maxDelayCycles, size_t replyLen, bool periodic) { uint16_t maxDelayCycles, LocalPoolDataSetBase* dataSet,
size_t replyLen, bool periodic) {
DeviceReplyInfo info; DeviceReplyInfo info;
info.maxDelayCycles = maxDelayCycles; info.maxDelayCycles = maxDelayCycles;
info.periodic = periodic; info.periodic = periodic;
info.delayCycles = 0; info.delayCycles = 0;
info.replyLen = replyLen; info.replyLen = replyLen;
info.dataSet = dataSet;
info.command = deviceCommandMap.end(); info.command = deviceCommandMap.end();
auto resultPair = deviceReplyMap.emplace(replyId, info); auto resultPair = deviceReplyMap.emplace(replyId, info);
if (resultPair.second) { if (resultPair.second) {
@ -419,13 +438,12 @@ ReturnValue_t DeviceHandlerBase::insertInCommandMap(
ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceReply, ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceReply,
uint16_t delayCycles, uint16_t maxDelayCycles, bool periodic) { uint16_t delayCycles, uint16_t maxDelayCycles, bool periodic) {
std::map<DeviceCommandId_t, DeviceReplyInfo>::iterator iter = auto replyIter = deviceReplyMap.find(deviceReply);
deviceReplyMap.find(deviceReply); if (replyIter == deviceReplyMap.end()) {
if (iter == deviceReplyMap.end()) {
triggerEvent(INVALID_DEVICE_COMMAND, deviceReply); triggerEvent(INVALID_DEVICE_COMMAND, deviceReply);
return RETURN_FAILED; return RETURN_FAILED;
} else { } else {
DeviceReplyInfo *info = &(iter->second); DeviceReplyInfo *info = &(replyIter->second);
if (maxDelayCycles != 0) { if (maxDelayCycles != 0) {
info->maxDelayCycles = maxDelayCycles; info->maxDelayCycles = maxDelayCycles;
} }
@ -435,6 +453,17 @@ ReturnValue_t DeviceHandlerBase::updateReplyMapEntry(DeviceCommandId_t deviceRep
} }
} }
ReturnValue_t DeviceHandlerBase::setReplyDataset(DeviceCommandId_t replyId,
LocalPoolDataSetBase *dataSet) {
auto replyIter = deviceReplyMap.find(replyId);
if(replyIter == deviceReplyMap.end()) {
return HasReturnvaluesIF::RETURN_FAILED;
}
replyIter->second.dataSet = dataSet;
return HasReturnvaluesIF::RETURN_OK;
}
void DeviceHandlerBase::callChildStatemachine() { void DeviceHandlerBase::callChildStatemachine() {
if (mode == _MODE_START_UP) { if (mode == _MODE_START_UP) {
doStartUp(); doStartUp();
@ -469,8 +498,8 @@ void DeviceHandlerBase::setMode(Mode_t newMode, uint8_t newSubmode) {
Clock::getUptime(&timeoutStart); Clock::getUptime(&timeoutStart);
if (mode == MODE_OFF) { if (mode == MODE_OFF) {
DataSet mySet; GlobDataSet mySet;
db_int8_t thermalRequest(deviceThermalRequestPoolId, &mySet, gp_uint8_t thermalRequest(deviceThermalRequestPoolId, &mySet,
PoolVariableIF::VAR_READ_WRITE); PoolVariableIF::VAR_READ_WRITE);
mySet.read(); mySet.read();
if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) {
@ -649,7 +678,7 @@ void DeviceHandlerBase::doGetRead() {
void DeviceHandlerBase::parseReply(const uint8_t* receivedData, void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
size_t receivedDataLen) { size_t receivedDataLen) {
ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED; ReturnValue_t result = HasReturnvaluesIF::RETURN_FAILED;
DeviceCommandId_t foundId = 0xFFFFFFFF; DeviceCommandId_t foundId = 0xffffffff;
size_t foundLen = 0; size_t foundLen = 0;
// The loop may not execute more often than the number of received bytes // The loop may not execute more often than the number of received bytes
// (worst case). This approach avoids infinite loops due to buggy // (worst case). This approach avoids infinite loops due to buggy
@ -661,6 +690,10 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
switch (result) { switch (result) {
case RETURN_OK: case RETURN_OK:
handleReply(receivedData, foundId, foundLen); handleReply(receivedData, foundId, foundLen);
if(foundLen == 0) {
sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!"
" Packet parsing will be stuck." << std::endl;
}
break; break;
case APERIODIC_REPLY: { case APERIODIC_REPLY: {
result = interpretDeviceReply(foundId, receivedData); result = interpretDeviceReply(foundId, receivedData);
@ -669,10 +702,14 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result, triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result,
foundId); foundId);
} }
if(foundLen == 0) {
sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!"
" Packet parsing will be stuck." << std::endl;
} }
break; break;
}
case IGNORE_REPLY_DATA: case IGNORE_REPLY_DATA:
break; continue;
case IGNORE_FULL_PACKET: case IGNORE_FULL_PACKET:
return; return;
default: default:
@ -704,16 +741,19 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData,
DeviceReplyInfo *info = &(iter->second); DeviceReplyInfo *info = &(iter->second);
if (info->delayCycles != 0) { if (info->delayCycles != 0) {
result = interpretDeviceReply(foundId, receivedData);
if (info->periodic != false) { if(result == IGNORE_REPLY_DATA) {
return;
}
if (info->periodic) {
info->delayCycles = info->maxDelayCycles; info->delayCycles = info->maxDelayCycles;
} }
else { else {
info->delayCycles = 0; info->delayCycles = 0;
} }
result = interpretDeviceReply(foundId, receivedData);
if (result != RETURN_OK) { if (result != RETURN_OK) {
// Report failed interpretation to FDIR. // Report failed interpretation to FDIR.
replyRawReplyIfnotWiretapped(receivedData, foundLen); replyRawReplyIfnotWiretapped(receivedData, foundLen);
@ -926,10 +966,10 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode,
if ((commandedMode == MODE_ON) && (mode == MODE_OFF) if ((commandedMode == MODE_ON) && (mode == MODE_OFF)
&& (deviceThermalStatePoolId != PoolVariableIF::NO_PARAMETER)) { && (deviceThermalStatePoolId != PoolVariableIF::NO_PARAMETER)) {
DataSet mySet; GlobDataSet mySet;
db_int8_t thermalState(deviceThermalStatePoolId, &mySet, gp_uint8_t thermalState(deviceThermalStatePoolId, &mySet,
PoolVariableIF::VAR_READ); PoolVariableIF::VAR_READ);
db_int8_t thermalRequest(deviceThermalRequestPoolId, &mySet, gp_uint8_t thermalRequest(deviceThermalRequestPoolId, &mySet,
PoolVariableIF::VAR_READ); PoolVariableIF::VAR_READ);
mySet.read(); mySet.read();
if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) {
@ -956,8 +996,8 @@ void DeviceHandlerBase::startTransition(Mode_t commandedMode,
childTransitionDelay = getTransitionDelayMs(_MODE_START_UP, childTransitionDelay = getTransitionDelayMs(_MODE_START_UP,
MODE_ON); MODE_ON);
triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode); triggerEvent(CHANGING_MODE, commandedMode, commandedSubmode);
DataSet mySet; GlobDataSet mySet;
db_int8_t thermalRequest(deviceThermalRequestPoolId, gp_int8_t thermalRequest(deviceThermalRequestPoolId,
&mySet, PoolVariableIF::VAR_READ_WRITE); &mySet, PoolVariableIF::VAR_READ_WRITE);
mySet.read(); mySet.read();
if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) { if (thermalRequest != ThermalComponentIF::STATE_REQUEST_IGNORE) {
@ -1089,19 +1129,6 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(
} }
replyReturnvalueToCommand(RETURN_OK); replyReturnvalueToCommand(RETURN_OK);
return RETURN_OK; return RETURN_OK;
// case DeviceHandlerMessage::CMD_SWITCH_IOBOARD:
// if (mode != MODE_OFF) {
// replyReturnvalueToCommand(WRONG_MODE_FOR_COMMAND);
// } else {
// result = switchCookieChannel(
// DeviceHandlerMessage::getIoBoardObjectId(message));
// if (result == RETURN_OK) {
// replyReturnvalueToCommand(RETURN_OK);
// } else {
// replyReturnvalueToCommand(CANT_SWITCH_IO_ADDRESS);
// }
// }
// return RETURN_OK;
case DeviceHandlerMessage::CMD_RAW: case DeviceHandlerMessage::CMD_RAW:
if ((mode != MODE_RAW)) { if ((mode != MODE_RAW)) {
DeviceHandlerMessage::clear(message); DeviceHandlerMessage::clear(message);
@ -1185,7 +1212,7 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data,
} }
//Try to cast to GlobDataSet and commit data. //Try to cast to GlobDataSet and commit data.
if (!neverInDataPool) { if (!neverInDataPool) {
DataSet* dataSet = dynamic_cast<DataSet*>(data); GlobDataSet* dataSet = dynamic_cast<GlobDataSet*>(data);
if (dataSet != NULL) { if (dataSet != NULL) {
dataSet->commit(PoolVariableIF::VALID); dataSet->commit(PoolVariableIF::VALID);
} }
@ -1248,10 +1275,14 @@ void DeviceHandlerBase::buildInternalCommand(void) {
if (iter == deviceCommandMap.end()) { if (iter == deviceCommandMap.end()) {
result = COMMAND_NOT_SUPPORTED; result = COMMAND_NOT_SUPPORTED;
} else if (iter->second.isExecuting) { } else if (iter->second.isExecuting) {
//so we can track misconfigurations
sif::debug << std::hex << getObjectId() sif::debug << std::hex << getObjectId()
<< ": DHB::buildInternalCommand: Command " << ": DHB::buildInternalCommand: Command "
<< deviceCommandId << " isExecuting" << std::endl; //so we can track misconfigurations << deviceCommandId << " isExecuting" << std::dec
return; //this is an internal command, no need to report a failure here, missed reply will track if a reply is too late, otherwise, it's ok << std::endl;
// this is an internal command, no need to report a failure here,
// missed reply will track if a reply is too late, otherwise, it's ok
return;
} else { } else {
iter->second.sendReplyTo = NO_COMMANDER; iter->second.sendReplyTo = NO_COMMANDER;
iter->second.isExecuting = true; iter->second.isExecuting = true;
@ -1340,12 +1371,50 @@ void DeviceHandlerBase::debugInterface(uint8_t positionTracker,
void DeviceHandlerBase::performOperationHook() { void DeviceHandlerBase::performOperationHook() {
} }
ReturnValue_t DeviceHandlerBase::initializeLocalDataPool(
LocalDataPool &localDataPoolMap,
LocalDataPoolManager& poolManager) {
return RETURN_OK;
}
LocalDataPoolManager* DeviceHandlerBase::getHkManagerHandle() {
return &hkManager;
}
ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() { ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() {
// In this function, the task handle should be valid if the task // In this function, the task handle should be valid if the task
// was implemented correctly. We still check to be 1000 % sure :-) // was implemented correctly. We still check to be 1000 % sure :-)
if(executingTask != nullptr) { if(executingTask != nullptr) {
pstIntervalMs = executingTask->getPeriodMs(); pstIntervalMs = executingTask->getPeriodMs();
} }
this->hkManager.initializeAfterTaskCreation();
if(setStartupImmediately) {
startTransition(MODE_ON, SUBMODE_NONE);
}
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
LocalPoolDataSetBase* DeviceHandlerBase::getDataSetHandle(sid_t sid) {
auto iter = deviceReplyMap.find(sid.ownerSetId);
if(iter != deviceReplyMap.end()) {
return iter->second.dataSet;
}
else {
return nullptr;
}
}
object_id_t DeviceHandlerBase::getObjectId() const {
return SystemObject::getObjectId();
}
void DeviceHandlerBase::setStartUpImmediately() {
this->setStartupImmediately = true;
}
dur_millis_t DeviceHandlerBase::getPeriodicOperationFrequency() const {
return pstIntervalMs;
}

View File

@ -1,12 +1,11 @@
#ifndef FRAMEWORK_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ #ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_
#define FRAMEWORK_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ #define FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_
#include "DeviceHandlerIF.h" #include "DeviceHandlerIF.h"
#include "DeviceCommunicationIF.h" #include "DeviceCommunicationIF.h"
#include "DeviceHandlerFailureIsolation.h" #include "DeviceHandlerFailureIsolation.h"
#include "../objectmanager/SystemObject.h" #include "../objectmanager/SystemObject.h"
#include "../tasks/PeriodicTaskIF.h"
#include "../tasks/ExecutableObjectIF.h" #include "../tasks/ExecutableObjectIF.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#include "../action/HasActionsIF.h" #include "../action/HasActionsIF.h"
@ -14,10 +13,13 @@
#include "../modes/HasModesIF.h" #include "../modes/HasModesIF.h"
#include "../power/PowerSwitchIF.h" #include "../power/PowerSwitchIF.h"
#include "../ipc/MessageQueueIF.h" #include "../ipc/MessageQueueIF.h"
#include "../tasks/PeriodicTaskIF.h"
#include "../action/ActionHelper.h" #include "../action/ActionHelper.h"
#include "../health/HealthHelper.h" #include "../health/HealthHelper.h"
#include "../parameters/ParameterHelper.h" #include "../parameters/ParameterHelper.h"
#include "../datapool/HkSwitchHelper.h" #include "../datapool/HkSwitchHelper.h"
#include "../datapoollocal/HasLocalDataPoolIF.h"
#include "../datapoollocal/LocalDataPoolManager.h"
#include <map> #include <map>
@ -38,17 +40,16 @@ class StorageManagerIF;
* Documentation: Dissertation Baetz p.138,139, p.141-149 * Documentation: Dissertation Baetz p.138,139, p.141-149
* *
* It features handling of @link DeviceHandlerIF::Mode_t Modes @endlink, * It features handling of @link DeviceHandlerIF::Mode_t Modes @endlink,
* communication with physical devices, using the @link DeviceCommunicationIF @endlink, * communication with physical devices, using the
* and communication with commanding objects. * @link DeviceCommunicationIF @endlink, and communication with commanding
* It inherits SystemObject and thus can be created by the ObjectManagerIF. * objects. It inherits SystemObject and thus can be created by the
* ObjectManagerIF.
* *
* This class uses the opcode of ExecutableObjectIF to perform a step-wise execution. * This class uses the opcode of ExecutableObjectIF to perform a
* For each step an RMAP action is selected and executed. * step-wise execution. For each step a different action is selected and
* If data has been received (GET_READ), the data will be interpreted. * executed. Currently, the device handler base performs a 4-step
* The action for each step can be defined by the child class but as most * execution related to 4 communication steps (based on RMAP).
* device handlers share a 4-call (sendRead-getRead-sendWrite-getWrite) structure, * NOTE: RMAP is a standard which is used for Flying Laptop.
* a default implementation is provided.
* NOTE: RMAP is a standard which is used for FLP.
* RMAP communication is not mandatory for projects implementing the FSFW. * RMAP communication is not mandatory for projects implementing the FSFW.
* However, the communication principles are similar to RMAP as there are * However, the communication principles are similar to RMAP as there are
* two write and two send calls involved. * two write and two send calls involved.
@ -69,9 +70,6 @@ class StorageManagerIF;
* *
* Other important virtual methods with a default implementation * Other important virtual methods with a default implementation
* are the getTransitionDelayMs() function and the getSwitches() function. * are the getTransitionDelayMs() function and the getSwitches() function.
* Please ensure that getSwitches() returns DeviceHandlerIF::NO_SWITCHES if
* power switches are not implemented yet. Otherwise, the device handler will
* not transition to MODE_ON, even if setMode(MODE_ON) is called.
* If a transition to MODE_ON is desired without commanding, override the * If a transition to MODE_ON is desired without commanding, override the
* intialize() function and call setMode(_MODE_START_UP) before calling * intialize() function and call setMode(_MODE_START_UP) before calling
* DeviceHandlerBase::initialize(). * DeviceHandlerBase::initialize().
@ -85,20 +83,18 @@ class DeviceHandlerBase: public DeviceHandlerIF,
public HasModesIF, public HasModesIF,
public HasHealthIF, public HasHealthIF,
public HasActionsIF, public HasActionsIF,
public ReceivesParameterMessagesIF { public ReceivesParameterMessagesIF,
public HasLocalDataPoolIF {
friend void (Factory::setStaticFrameworkObjectIds)(); friend void (Factory::setStaticFrameworkObjectIds)();
public: public:
/** /**
* The constructor passes the objectId to the SystemObject(). * The constructor passes the objectId to the SystemObject().
* *
* @param setObjectId the ObjectId to pass to the SystemObject() Constructor * @param setObjectId the ObjectId to pass to the SystemObject() Constructor
* @param maxDeviceReplyLen the length the RMAP getRead call will be sent with
* @param setDeviceSwitch the switch the device is connected to,
* for devices using two switches, overwrite getSwitches()
* @param deviceCommuncation Communcation Interface object which is used * @param deviceCommuncation Communcation Interface object which is used
* to implement communication functions * to implement communication functions
* @param thermalStatePoolId * @param comCookie This object will be passed to the communication inter-
* @param thermalRequestPoolId * face and can contain user-defined information about the communication.
* @param fdirInstance * @param fdirInstance
* @param cmdQueueSize * @param cmdQueueSize
*/ */
@ -106,8 +102,21 @@ public:
CookieIF * comCookie, FailureIsolationBase* fdirInstance = nullptr, CookieIF * comCookie, FailureIsolationBase* fdirInstance = nullptr,
size_t cmdQueueSize = 20); size_t cmdQueueSize = 20);
void setHkDestination(object_id_t hkDestination);
void setThermalStateRequestPoolIds(uint32_t thermalStatePoolId, void setThermalStateRequestPoolIds(uint32_t thermalStatePoolId,
uint32_t thermalRequestPoolId); uint32_t thermalRequestPoolId);
/**
* @brief Helper function to ease device handler development.
* This will instruct the transition to MODE_ON immediately
* (leading to doStartUp() being called for the transition to the ON mode),
* so external mode commanding is not necessary anymore.
*
* This has to be called before the task is started!
* (e.g. in the task factory). This is only a helper function for
* development. Regular mode commanding should be performed by commanding
* the AssemblyBase or Subsystem objects resposible for the device handler.
*/
void setStartUpImmediately();
/** /**
* @brief This function is the device handler base core component and is * @brief This function is the device handler base core component and is
@ -153,6 +162,14 @@ public:
* @return * @return
*/ */
virtual ReturnValue_t initialize(); virtual ReturnValue_t initialize();
/**
* @brief Intialization steps performed after all tasks have been created.
* This function will be called by the executing task.
* @return
*/
virtual ReturnValue_t initializeAfterTaskCreation() override;
/** Destructor. */ /** Destructor. */
virtual ~DeviceHandlerBase(); virtual ~DeviceHandlerBase();
@ -320,6 +337,8 @@ protected:
* @param packet * @param packet
* @return * @return
* - @c RETURN_OK when the reply was interpreted. * - @c RETURN_OK when the reply was interpreted.
* - @c IGNORE_REPLY_DATA Ignore the reply and don't reset reply cycle
* counter.
* - @c RETURN_FAILED when the reply could not be interpreted, * - @c RETURN_FAILED when the reply could not be interpreted,
* e.g. logical errors or range violations occurred * e.g. logical errors or range violations occurred
*/ */
@ -347,22 +366,10 @@ protected:
* set to the maximum expected number of PST cycles between two replies * set to the maximum expected number of PST cycles between two replies
* (also a tolerance should be added, as an FDIR message will be * (also a tolerance should be added, as an FDIR message will be
* generated if it is missed). * generated if it is missed).
*
* (Robin) This part confuses me. "must do as soon as" implies that
* the developer must do something somewhere else in the code. Is
* that really the case? If I understood correctly, DHB performs
* almost everything (e.g. in erirm function) as long as the commands
* are inserted correctly.
*
* As soon as the replies are enabled, DeviceCommandInfo.periodic must
* be set to true, DeviceCommandInfo.delayCycles to
* DeviceCommandInfo.maxDelayCycles.
* From then on, the base class handles the reception. * From then on, the base class handles the reception.
* Then, scanForReply returns the id of the reply or the placeholder id * Then, scanForReply returns the id of the reply or the placeholder id
* and the base class will take care of checking that all replies are * and the base class will take care of checking that all replies are
* received and the interval is correct. * received and the interval is correct.
* When the replies are disabled, DeviceCommandInfo.periodic must be set
* to 0, DeviceCommandInfo.delayCycles to 0;
* *
* - Aperiodic, unrequested replies. These are replies that are sent * - Aperiodic, unrequested replies. These are replies that are sent
* by the device without any preceding command and not in a defined * by the device without any preceding command and not in a defined
@ -376,13 +383,17 @@ protected:
* @param deviceCommand Identifier of the command to add. * @param deviceCommand Identifier of the command to add.
* @param maxDelayCycles The maximum number of delay cycles the command * @param maxDelayCycles The maximum number of delay cycles the command
* waits until it times out. * waits until it times out.
* @param replyLen Will be supplied to the requestReceiveMessage call of
* the communication interface.
* @param periodic Indicates if the command is periodic (i.e. it is sent * @param periodic Indicates if the command is periodic (i.e. it is sent
* by the device repeatedly without request) or not. Default is aperiodic (0) * by the device repeatedly without request) or not. Default is aperiodic (0)
* @return - @c RETURN_OK when the command was successfully inserted, * @return - @c RETURN_OK when the command was successfully inserted,
* - @c RETURN_FAILED else. * - @c RETURN_FAILED else.
*/ */
ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand,
uint16_t maxDelayCycles, size_t replyLen = 0, bool periodic = false, uint16_t maxDelayCycles,
LocalPoolDataSetBase* replyDataSet = nullptr,
size_t replyLen = 0, bool periodic = false,
bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0); bool hasDifferentReplyId = false, DeviceCommandId_t replyId = 0);
/** /**
@ -396,7 +407,8 @@ protected:
* - @c RETURN_FAILED else. * - @c RETURN_FAILED else.
*/ */
ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand, ReturnValue_t insertInReplyMap(DeviceCommandId_t deviceCommand,
uint16_t maxDelayCycles, size_t replyLen = 0, bool periodic = false); uint16_t maxDelayCycles, LocalPoolDataSetBase* dataSet = nullptr,
size_t replyLen = 0, bool periodic = false);
/** /**
* @brief A simple command to add a command to the commandList. * @brief A simple command to add a command to the commandList.
@ -424,6 +436,9 @@ protected:
uint16_t delayCycles, uint16_t maxDelayCycles, uint16_t delayCycles, uint16_t maxDelayCycles,
bool periodic = false); bool periodic = false);
ReturnValue_t setReplyDataset(DeviceCommandId_t replyId,
LocalPoolDataSetBase* dataset);
/** /**
* @brief Can be implemented by child handler to * @brief Can be implemented by child handler to
* perform debugging * perform debugging
@ -477,18 +492,22 @@ protected:
* @param localDataPoolMap * @param localDataPoolMap
* @return * @return
*/ */
//virtual ReturnValue_t initializePoolEntries( virtual ReturnValue_t initializeLocalDataPool(LocalDataPool& localDataPoolMap,
// LocalDataPool& localDataPoolMap) override; LocalDataPoolManager& poolManager) override;
/** Get the HK manager object handle */ /** Get the HK manager object handle */
//virtual LocalDataPoolManager* getHkManagerHandle() override; virtual LocalDataPoolManager* getHkManagerHandle() override;
/** /**
* @brief Hook function for child handlers which is called once per * @brief Hook function for child handlers which is called once per
* performOperation(). Default implementation is empty. * performOperation(). Default implementation is empty.
*/ */
virtual void performOperationHook(); virtual void performOperationHook();
public: public:
/** Explicit interface implementation of getObjectId */
virtual object_id_t getObjectId() const override;
/** /**
* @param parentQueueId * @param parentQueueId
*/ */
@ -608,7 +627,7 @@ protected:
/** Action helper for HasActionsIF */ /** Action helper for HasActionsIF */
ActionHelper actionHelper; ActionHelper actionHelper;
/** Housekeeping Manager */ /** Housekeeping Manager */
//LocalDataPoolManager hkManager; LocalDataPoolManager hkManager;
/** /**
* @brief Information about commands * @brief Information about commands
@ -647,7 +666,7 @@ protected:
//! The dataset used to access housekeeping data related to the //! The dataset used to access housekeeping data related to the
//! respective device reply. Will point to a dataset held by //! respective device reply. Will point to a dataset held by
//! the child handler (if one is specified) //! the child handler (if one is specified)
// DataSetIF* dataSet = nullptr; LocalPoolDataSetBase* dataSet;
//! The command that expects this reply. //! The command that expects this reply.
DeviceCommandMap::iterator command; DeviceCommandMap::iterator command;
}; };
@ -689,14 +708,18 @@ protected:
uint32_t deviceThermalRequestPoolId = PoolVariableIF::NO_PARAMETER; uint32_t deviceThermalRequestPoolId = PoolVariableIF::NO_PARAMETER;
/** /**
* Optional Error code * Optional Error code. Can be set in doStartUp(), doShutDown() and
* Can be set in doStartUp(), doShutDown() and doTransition() to signal cause for Transition failure. * doTransition() to signal cause for Transition failure.
*/ */
ReturnValue_t childTransitionFailure; ReturnValue_t childTransitionFailure;
uint32_t ignoreMissedRepliesCount = 0; //!< Counts if communication channel lost a reply, so some missed replys can be ignored. /** Counts if communication channel lost a reply, so some missed
* replys can be ignored. */
uint32_t ignoreMissedRepliesCount = 0;
FailureIsolationBase* fdirInstance; //!< Pointer to the used FDIR instance. If not provided by child, default class is instantiated. /** Pointer to the used FDIR instance. If not provided by child,
* default class is instantiated. */
FailureIsolationBase* fdirInstance;
HkSwitchHelper hkSwitcher; HkSwitchHelper hkSwitcher;
@ -944,14 +967,17 @@ protected:
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode); uint32_t *msToReachTheMode);
virtual void startTransition(Mode_t mode, Submode_t submode);
virtual void setToExternalControl(); /* HasModesIF overrides */
virtual void announceMode(bool recursive); virtual void startTransition(Mode_t mode, Submode_t submode) override;
virtual void setToExternalControl() override;
virtual void announceMode(bool recursive) override;
virtual ReturnValue_t letChildHandleMessage(CommandMessage *message); virtual ReturnValue_t letChildHandleMessage(CommandMessage *message);
/** /**
* Overwrites SystemObject::triggerEvent in order to inform FDIR"Helper" faster about executed events. * Overwrites SystemObject::triggerEvent in order to inform FDIR"Helper"
* faster about executed events.
* This is a bit sneaky, but improves responsiveness of the device FDIR. * This is a bit sneaky, but improves responsiveness of the device FDIR.
* @param event The event to be thrown * @param event The event to be thrown
* @param parameter1 Optional parameter 1 * @param parameter1 Optional parameter 1
@ -1034,12 +1060,17 @@ private:
/** the object used to set power switches */ /** the object used to set power switches */
PowerSwitchIF *powerSwitcher = nullptr; PowerSwitchIF *powerSwitcher = nullptr;
/** HK destination can also be set individually */
object_id_t hkDestination = objects::NO_OBJECT;
/** /**
* @brief Used for timing out mode transitions. * @brief Used for timing out mode transitions.
* Set when setMode() is called. * Set when setMode() is called.
*/ */
uint32_t timeoutStart = 0; uint32_t timeoutStart = 0;
bool setStartupImmediately = false;
/** /**
* Delay for the current mode transition, used for time out * Delay for the current mode transition, used for time out
*/ */
@ -1080,11 +1111,6 @@ private:
void buildRawDeviceCommand(CommandMessage* message); void buildRawDeviceCommand(CommandMessage* message);
void buildInternalCommand(void); void buildInternalCommand(void);
// /**
// * Send a reply with the current mode and submode.
// */
// void announceMode(void);
/** /**
* Decrement the counter for the timout of replies. * Decrement the counter for the timout of replies.
* *
@ -1111,10 +1137,14 @@ private:
/** /**
* Build and send a command to the device. * Build and send a command to the device.
* *
* This routine checks whether a raw or direct command has been received, checks the content of the received command and * This routine checks whether a raw or direct command has been received,
* calls buildCommandFromCommand() for direct commands or sets #rawpacket to the received raw packet. * checks the content of the received command and calls
* If no external command is received or the received command is invalid and the current mode is @c MODE_NORMAL or a transitional mode, * buildCommandFromCommand() for direct commands or sets #rawpacket
* it asks the child class to build a command (via getNormalDeviceCommand() or getTransitionalDeviceCommand() and buildCommand()) and * to the received raw packet.
* If no external command is received or the received command is invalid and
* the current mode is @c MODE_NORMAL or a transitional mode, it asks the
* child class to build a command (via getNormalDeviceCommand() or
* getTransitionalDeviceCommand() and buildCommand()) and
* sends the command via RMAP. * sends the command via RMAP.
*/ */
void doSendWrite(void); void doSendWrite(void);
@ -1159,7 +1189,6 @@ private:
ReturnValue_t getStorageData(store_address_t storageAddress, uint8_t **data, ReturnValue_t getStorageData(store_address_t storageAddress, uint8_t **data,
uint32_t *len); uint32_t *len);
/** /**
* @param modeTo either @c MODE_ON, MODE_NORMAL or MODE_RAW NOTHING ELSE!!! * @param modeTo either @c MODE_ON, MODE_NORMAL or MODE_RAW NOTHING ELSE!!!
*/ */
@ -1170,25 +1199,14 @@ private:
*/ */
void callChildStatemachine(); void callChildStatemachine();
/**
* Switches the channel of the cookie used for the communication
*
*
* @param newChannel the object Id of the channel to switch to
* @return
* - @c RETURN_OK when cookie was changed
* - @c RETURN_FAILED when cookies could not be changed, eg because the newChannel is not enabled
* - @c returnvalues of RMAPChannelIF::isActive()
*/
ReturnValue_t switchCookieChannel(object_id_t newChannelId);
ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message); ReturnValue_t handleDeviceHandlerMessage(CommandMessage *message);
virtual ReturnValue_t initializeAfterTaskCreation() override; virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
virtual dur_millis_t getPeriodicOperationFrequency() const override;
void parseReply(const uint8_t* receivedData, void parseReply(const uint8_t* receivedData,
size_t receivedDataLen); size_t receivedDataLen);
}; };
#endif /* FRAMEWORK_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */ #endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERBASE_H_ */

View File

@ -247,6 +247,14 @@ bool DeviceHandlerFailureIsolation::isFdirInActionOrAreWeFaulty(
} }
return true; return true;
} }
if (owner == nullptr) {
// Configuration error.
sif::error << "DeviceHandlerFailureIsolation::"
<< "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl;
return false;
}
if (owner->getHealth() == HasHealthIF::FAULTY if (owner->getHealth() == HasHealthIF::FAULTY
|| owner->getHealth() == HasHealthIF::PERMANENT_FAULTY) { || owner->getHealth() == HasHealthIF::PERMANENT_FAULTY) {
//Ignore all events in case device is already faulty. //Ignore all events in case device is already faulty.

View File

@ -1,12 +1,19 @@
#ifndef DEVICEHANDLERIF_H_ #ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_
#define DEVICEHANDLERIF_H_ #define FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_
#include "DeviceHandlerMessage.h"
#include "../action/HasActionsIF.h" #include "../action/HasActionsIF.h"
#include "DeviceHandlerMessage.h"
#include "../events/Event.h" #include "../events/Event.h"
#include "../modes/HasModesIF.h" #include "../modes/HasModesIF.h"
#include "../ipc/MessageQueueSenderIF.h" #include "../ipc/MessageQueueSenderIF.h"
/**
* This is used to uniquely identify commands that are sent to a device
* The values are defined in the device-specific implementations
*/
using DeviceCommandId_t = uint32_t;
/** /**
* @brief This is the Interface used to communicate with a device handler. * @brief This is the Interface used to communicate with a device handler.
* @details Includes all expected return values, events and modes. * @details Includes all expected return values, events and modes.
@ -15,6 +22,7 @@
class DeviceHandlerIF { class DeviceHandlerIF {
public: public:
static const uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20; static const uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20;
static const uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10; static const uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10;
@ -47,6 +55,8 @@ public:
//! This is a transitional state which can not be commanded. //! This is a transitional state which can not be commanded.
//! The device handler performs all actions and commands to get the device //! The device handler performs all actions and commands to get the device
//! shut down. When the device is off, the mode changes to @c MODE_OFF. //! shut down. When the device is off, the mode changes to @c MODE_OFF.
//! It is possible to set the mode to _MODE_SHUT_DOWN to use the to off
//! transition if available.
static const Mode_t _MODE_SHUT_DOWN = TRANSITION_MODE_CHILD_ACTION_MASK | 6; static const Mode_t _MODE_SHUT_DOWN = TRANSITION_MODE_CHILD_ACTION_MASK | 6;
//! It is possible to set the mode to _MODE_TO_ON to use the to on //! It is possible to set the mode to _MODE_TO_ON to use the to on
//! transition if available. //! transition if available.
@ -96,7 +106,7 @@ public:
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF; static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF;
// Standard codes used when building commands. // Standard codes used when building commands.
static const ReturnValue_t NO_COMMAND_DATA = MAKE_RETURN_CODE(0xA0); //!< If the command size is 0. Checked in DHB static const ReturnValue_t NO_COMMAND_DATA = MAKE_RETURN_CODE(0xA0); //!< If no command data was given when expected.
static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); //!< Command ID not in commandMap. Checked in DHB static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); //!< Command ID not in commandMap. Checked in DHB
static const ReturnValue_t COMMAND_ALREADY_SENT = MAKE_RETURN_CODE(0xA2); //!< Command was already executed. Checked in DHB static const ReturnValue_t COMMAND_ALREADY_SENT = MAKE_RETURN_CODE(0xA2); //!< Command was already executed. Checked in DHB
static const ReturnValue_t COMMAND_WAS_NOT_SENT = MAKE_RETURN_CODE(0xA3); static const ReturnValue_t COMMAND_WAS_NOT_SENT = MAKE_RETURN_CODE(0xA3);
@ -150,4 +160,4 @@ public:
}; };
#endif /* DEVICEHANDLERIF_H_ */ #endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_ */

View File

@ -1,10 +1,6 @@
#include "../objectmanager/ObjectManagerIF.h"
#include "DeviceHandlerMessage.h" #include "DeviceHandlerMessage.h"
#include "../objectmanager/ObjectManagerIF.h" #include "../objectmanager/ObjectManagerIF.h"
DeviceHandlerMessage::DeviceHandlerMessage() {
}
store_address_t DeviceHandlerMessage::getStoreAddress( store_address_t DeviceHandlerMessage::getStoreAddress(
const CommandMessage* message) { const CommandMessage* message) {
return store_address_t(message->getParameter2()); return store_address_t(message->getParameter2());
@ -25,14 +21,6 @@ uint8_t DeviceHandlerMessage::getWiretappingMode(
return message->getParameter(); return message->getParameter();
} }
//void DeviceHandlerMessage::setDeviceHandlerDirectCommandMessage(
// CommandMessage* message, DeviceCommandId_t deviceCommand,
// store_address_t commandParametersStoreId) {
// message->setCommand(CMD_DIRECT);
// message->setParameter(deviceCommand);
// message->setParameter2(commandParametersStoreId.raw);
//}
void DeviceHandlerMessage::setDeviceHandlerRawCommandMessage( void DeviceHandlerMessage::setDeviceHandlerRawCommandMessage(
CommandMessage* message, store_address_t rawPacketStoreId) { CommandMessage* message, store_address_t rawPacketStoreId) {
message->setCommand(CMD_RAW); message->setCommand(CMD_RAW);
@ -47,7 +35,7 @@ void DeviceHandlerMessage::setDeviceHandlerWiretappingMessage(
void DeviceHandlerMessage::setDeviceHandlerSwitchIoBoardMessage( void DeviceHandlerMessage::setDeviceHandlerSwitchIoBoardMessage(
CommandMessage* message, uint32_t ioBoardIdentifier) { CommandMessage* message, uint32_t ioBoardIdentifier) {
message->setCommand(CMD_SWITCH_IOBOARD); message->setCommand(CMD_SWITCH_ADDRESS);
message->setParameter(ioBoardIdentifier); message->setParameter(ioBoardIdentifier);
} }
@ -79,18 +67,17 @@ void DeviceHandlerMessage::setDeviceHandlerDirectCommandReply(
void DeviceHandlerMessage::clear(CommandMessage* message) { void DeviceHandlerMessage::clear(CommandMessage* message) {
switch (message->getCommand()) { switch (message->getCommand()) {
case CMD_RAW: case CMD_RAW:
// case CMD_DIRECT:
case REPLY_RAW_COMMAND: case REPLY_RAW_COMMAND:
case REPLY_RAW_REPLY: case REPLY_RAW_REPLY:
case REPLY_DIRECT_COMMAND_DATA: { case REPLY_DIRECT_COMMAND_DATA: {
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>( StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
objects::IPC_STORE); objects::IPC_STORE);
if (ipcStore != NULL) { if (ipcStore != nullptr) {
ipcStore->deleteData(getStoreAddress(message)); ipcStore->deleteData(getStoreAddress(message));
} }
} }
/* NO BREAK falls through*/ /* NO BREAK falls through*/
case CMD_SWITCH_IOBOARD: case CMD_SWITCH_ADDRESS:
case CMD_WIRETAPPING: case CMD_WIRETAPPING:
message->setCommand(CommandMessage::CMD_NONE); message->setCommand(CommandMessage::CMD_NONE);
message->setParameter(0); message->setParameter(0);

View File

@ -1,69 +1,56 @@
#ifndef DEVICEHANDLERMESSAGE_H_ #ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERMESSAGE_H_
#define DEVICEHANDLERMESSAGE_H_ #define FSFW_DEVICEHANDLERS_DEVICEHANDLERMESSAGE_H_
#include "../action/ActionMessage.h" #include "../action/ActionMessage.h"
#include "../ipc/CommandMessage.h" #include "../ipc/CommandMessage.h"
#include "../objectmanager/SystemObjectIF.h" #include "../objectmanager/SystemObjectIF.h"
#include "../storagemanager/StorageManagerIF.h" #include "../storagemanager/StorageManagerIF.h"
//SHOULDDO: rework the static constructors to name the type of command they are building, maybe even hide setting the commandID. // SHOULDDO: rework the static constructors to name the type of command
// they are building, maybe even hide setting the commandID.
/** /**
* This is used to uniquely identify commands that are sent to a device * @brief The DeviceHandlerMessage is used to send commands to classes
* * implementing DeviceHandlerIF
* The values are defined in the device-specific implementations
*/
typedef uint32_t DeviceCommandId_t;
/**
* The DeviceHandlerMessage is used to send Commands to a DeviceHandlerIF
*/ */
class DeviceHandlerMessage { class DeviceHandlerMessage {
private:
DeviceHandlerMessage();
public: public:
/**
* Instantiation forbidden. Instead, use static functions to operate
* on messages.
*/
DeviceHandlerMessage() = delete;
virtual ~DeviceHandlerMessage() {}
/** /**
* These are the commands that can be sent to a DeviceHandlerBase * These are the commands that can be sent to a DeviceHandlerBase
*/ */
static const uint8_t MESSAGE_ID = messagetypes::DEVICE_HANDLER_COMMAND; static const uint8_t MESSAGE_ID = messagetypes::DEVICE_HANDLER_COMMAND;
static const Command_t CMD_RAW = MAKE_COMMAND_ID( 1 ); //!< Sends a raw command, setParameter is a ::store_id_t containing the raw packet to send //! Sends a raw command, setParameter is a storeId containing the
// static const Command_t CMD_DIRECT = MAKE_COMMAND_ID( 2 ); //!< Sends a direct command, setParameter is a ::DeviceCommandId_t, setParameter2 is a ::store_id_t containing the data needed for the command //! raw packet to send
static const Command_t CMD_SWITCH_IOBOARD = MAKE_COMMAND_ID( 3 ); //!< Requests a IO-Board switch, setParameter() is the IO-Board identifier static const Command_t CMD_RAW = MAKE_COMMAND_ID(1);
static const Command_t CMD_WIRETAPPING = MAKE_COMMAND_ID( 4 ); //!< (De)Activates the monitoring of all raw traffic in DeviceHandlers, setParameter is 0 to deactivate, 1 to activate //! Requests a IO-Board switch, setParameter() is the IO-Board identifier
static const Command_t CMD_SWITCH_ADDRESS = MAKE_COMMAND_ID(3);
//! (De)Activates the monitoring of all raw traffic in DeviceHandlers,
//! setParameter is 0 to deactivate, 1 to activate
static const Command_t CMD_WIRETAPPING = MAKE_COMMAND_ID(4);
/*static const Command_t REPLY_SWITCHED_IOBOARD = MAKE_COMMAND_ID(1 );//!< Reply to a @c CMD_SWITCH_IOBOARD, indicates switch was successful, getParameter() contains the board switched to (0: nominal, 1: redundant) //! Signals that a direct command was sent
static const Command_t REPLY_CANT_SWITCH_IOBOARD = MAKE_COMMAND_ID( 2); //!< Reply to a @c CMD_SWITCH_IOBOARD, indicating the switch could not be performed, getParameter() contains the error message static const Command_t REPLY_DIRECT_COMMAND_SENT = ActionMessage::STEP_SUCCESS;
static const Command_t REPLY_WIRETAPPING = MAKE_COMMAND_ID( 3); //!< Reply to a @c CMD_WIRETAPPING, getParameter() is the current state, 1 enabled, 0 disabled //! Contains a raw command sent to the Device
static const Command_t REPLY_RAW_COMMAND = MAKE_COMMAND_ID(0x11);
static const Command_t REPLY_COMMAND_WAS_SENT = MAKE_COMMAND_ID(4 );//!< Reply to a @c CMD_RAW or @c CMD_DIRECT, indicates the command was successfully sent to the device, getParameter() contains the ::DeviceCommandId_t //! Contains a raw reply from the Device, getParameter() is the ObjcetId
static const Command_t REPLY_COMMAND_NOT_SUPPORTED = MAKE_COMMAND_ID(5 );//!< Reply to a @c CMD_DIRECT, the requested ::DeviceCommand_t is not supported, getParameter() contains the requested ::DeviceCommand_t, getParameter2() contains the ::DeviceCommandId_t //! of the sender, getParameter2() is a ::store_id_t containing the
static const Command_t REPLY_COMMAND_WAS_NOT_SENT = MAKE_COMMAND_ID(6 );//!< Reply to a @c CMD_RAW or @c CMD_DIRECT, indicates the command was not sent, getParameter contains the RMAP Return code (@see rmap.h), getParameter2() contains the ::DeviceCommandId_t //! raw packet received
static const Command_t REPLY_RAW_REPLY = MAKE_COMMAND_ID(0x12);
static const Command_t REPLY_COMMAND_ALREADY_SENT = MAKE_COMMAND_ID(7 );//!< Reply to a @c CMD_DIRECT, the requested ::DeviceCommand_t has already been sent to the device and not ye been answered
static const Command_t REPLY_WRONG_MODE_FOR_CMD = MAKE_COMMAND_ID(8 );//!< Reply to a @c CMD_RAW or @c CMD_DIRECT, indicates that the requested command can not be sent in the curent mode, getParameter() contains the DeviceHandlerCommand_t
static const Command_t REPLY_NO_DATA = MAKE_COMMAND_ID(9 ); //!< Reply to a CMD_RAW or @c CMD_DIRECT, indicates that the ::store_id_t was invalid, getParameter() contains the ::DeviceCommandId_t, getPrameter2() contains the error code
*/
static const Command_t REPLY_DIRECT_COMMAND_SENT = ActionMessage::STEP_SUCCESS; //!< Signals that a direct command was sent
static const Command_t REPLY_RAW_COMMAND = MAKE_COMMAND_ID(0x11 ); //!< Contains a raw command sent to the Device
static const Command_t REPLY_RAW_REPLY = MAKE_COMMAND_ID( 0x12); //!< Contains a raw reply from the Device, getParameter() is the ObjcetId of the sender, getParameter2() is a ::store_id_t containing the raw packet received
static const Command_t REPLY_DIRECT_COMMAND_DATA = ActionMessage::DATA_REPLY; static const Command_t REPLY_DIRECT_COMMAND_DATA = ActionMessage::DATA_REPLY;
/**
* Default Destructor
*/
virtual ~DeviceHandlerMessage() {
}
static store_address_t getStoreAddress(const CommandMessage* message); static store_address_t getStoreAddress(const CommandMessage* message);
static uint32_t getDeviceCommandId(const CommandMessage* message); static uint32_t getDeviceCommandId(const CommandMessage* message);
static object_id_t getDeviceObjectId(const CommandMessage *message); static object_id_t getDeviceObjectId(const CommandMessage *message);
static object_id_t getIoBoardObjectId(const CommandMessage* message); static object_id_t getIoBoardObjectId(const CommandMessage* message);
static uint8_t getWiretappingMode(const CommandMessage* message); static uint8_t getWiretappingMode(const CommandMessage* message);
// static void setDeviceHandlerDirectCommandMessage(CommandMessage* message,
// DeviceCommandId_t deviceCommand,
// store_address_t commandParametersStoreId);
static void setDeviceHandlerDirectCommandReply(CommandMessage* message, static void setDeviceHandlerDirectCommandReply(CommandMessage* message,
object_id_t deviceObjectid, object_id_t deviceObjectid,
store_address_t commandParametersStoreId); store_address_t commandParametersStoreId);
@ -75,11 +62,6 @@ public:
object_id_t deviceObjectid, store_address_t rawPacketStoreId, object_id_t deviceObjectid, store_address_t rawPacketStoreId,
bool isCommand); bool isCommand);
// static void setDeviceHandlerMessage(CommandMessage* message,
// Command_t command, DeviceCommandId_t deviceCommand,
// store_address_t commandParametersStoreId);
// static void setDeviceHandlerMessage(CommandMessage* message,
// Command_t command, store_address_t rawPacketStoreId);
static void setDeviceHandlerWiretappingMessage(CommandMessage* message, static void setDeviceHandlerWiretappingMessage(CommandMessage* message,
uint8_t wiretappingMode); uint8_t wiretappingMode);
static void setDeviceHandlerSwitchIoBoardMessage(CommandMessage* message, static void setDeviceHandlerSwitchIoBoardMessage(CommandMessage* message,
@ -88,4 +70,4 @@ public:
static void clear(CommandMessage* message); static void clear(CommandMessage* message);
}; };
#endif /* DEVICEHANDLERMESSAGE_H_ */ #endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERMESSAGE_H_ */

View File

@ -1,4 +1,3 @@
#include "../serialize/SerializeAdapter.h"
#include "DeviceTmReportingWrapper.h" #include "DeviceTmReportingWrapper.h"
#include "../serialize/SerializeAdapter.h" #include "../serialize/SerializeAdapter.h"

View File

@ -1,5 +1,5 @@
#ifndef DEVICETMREPORTINGWRAPPER_H_ #ifndef FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
#define DEVICETMREPORTINGWRAPPER_H_ #define FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
#include "../action/HasActionsIF.h" #include "../action/HasActionsIF.h"
#include "../objectmanager/SystemObjectIF.h" #include "../objectmanager/SystemObjectIF.h"
@ -24,4 +24,4 @@ private:
SerializeIF *data; SerializeIF *data;
}; };
#endif /* DEVICETMREPORTINGWRAPPER_H_ */ #endif /* FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_ */

View File

@ -13,10 +13,10 @@ HealthDevice::~HealthDevice() {
} }
ReturnValue_t HealthDevice::performOperation(uint8_t opCode) { ReturnValue_t HealthDevice::performOperation(uint8_t opCode) {
CommandMessage message; CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&message); ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result == HasReturnvaluesIF::RETURN_OK) { if (result == HasReturnvaluesIF::RETURN_OK) {
healthHelper.handleHealthCommand(&message); healthHelper.handleHealthCommand(&command);
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -1,5 +1,5 @@
#ifndef HEALTHDEVICE_H_ #ifndef FSFW_DEVICEHANDLERS_HEALTHDEVICE_H_
#define HEALTHDEVICE_H_ #define FSFW_DEVICEHANDLERS_HEALTHDEVICE_H_
#include "../health/HasHealthIF.h" #include "../health/HasHealthIF.h"
#include "../health/HealthHelper.h" #include "../health/HealthHelper.h"
@ -37,4 +37,4 @@ public:
HealthHelper healthHelper; HealthHelper healthHelper;
}; };
#endif /* HEALTHDEVICE_H_ */ #endif /* FSFW_DEVICEHANDLERS_HEALTHDEVICE_H_ */