new adaptions for cookie + comIF changes

hook for performOp() added
This commit is contained in:
Robin Müller 2020-03-23 18:03:00 +01:00
parent e03aff3731
commit 029b2133e6
2 changed files with 151 additions and 114 deletions

View File

@ -16,37 +16,34 @@ object_id_t DeviceHandlerBase::powerSwitcherId = 0;
object_id_t DeviceHandlerBase::rawDataReceiverId = 0; object_id_t DeviceHandlerBase::rawDataReceiverId = 0;
object_id_t DeviceHandlerBase::defaultFDIRParentId = 0; object_id_t DeviceHandlerBase::defaultFDIRParentId = 0;
DeviceHandlerBase::DeviceHandlerBase(uint32_t logicalAddress_, DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId, address_t logicalAddress_,
object_id_t setObjectId, uint32_t maxDeviceReplyLen, object_id_t deviceCommunication, Cookie * cookie_, size_t maxReplyLen,
uint8_t setDeviceSwitch, object_id_t deviceCommunication, uint8_t setDeviceSwitch, uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId,
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId, FailureIsolationBase* fdirInstance, size_t cmdQueueSize) :
FailureIsolationBase* fdirInstance, uint32_t cmdQueueSize) : SystemObject(setObjectId), mode(MODE_OFF), submode(SUBMODE_NONE),
SystemObject(setObjectId), rawPacket(0), rawPacketLen(0), mode(MODE_OFF), wiretappingMode(OFF), storedRawData(StorageManagerIF::INVALID_ADDRESS),
submode(SUBMODE_NONE), pstStep(0), maxDeviceReplyLen(maxDeviceReplyLen), deviceCommunicationId(deviceCommunication), cookie(cookie_),
wiretappingMode(OFF), defaultRawReceiver(0), storedRawData(StorageManagerIF::INVALID_ADDRESS), deviceThermalStatePoolId(thermalStatePoolId), deviceThermalRequestPoolId(thermalRequestPoolId),
requestedRawTraffic(0), powerSwitcher(NULL), IPCStore(NULL), healthHelper(this, setObjectId), modeHelper(this), parameterHelper(this),
deviceCommunicationId(deviceCommunication), communicationInterface(NULL), fdirInstance(fdirInstance), hkSwitcher(this),
cookie(NULL), commandQueue(NULL), deviceThermalStatePoolId(thermalStatePoolId), defaultFDIRUsed(fdirInstance == nullptr), switchOffWasReported(false),
deviceThermalRequestPoolId(thermalRequestPoolId), healthHelper(this, setObjectId), executingTask(nullptr), actionHelper(this, nullptr), cookieInfo(),
modeHelper(this), parameterHelper(this), childTransitionFailure(RETURN_OK), logicalAddress(logicalAddress_), childTransitionDelay(5000),
ignoreMissedRepliesCount(0), fdirInstance(fdirInstance), hkSwitcher(this), transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(SUBMODE_NONE),
defaultFDIRUsed(fdirInstance == NULL), switchOffWasReported(false), deviceSwitch(setDeviceSwitch)
executingTask(NULL), actionHelper(this, NULL), cookieInfo(), logicalAddress(logicalAddress_),
timeoutStart(0), childTransitionDelay(5000), transitionSourceMode(_MODE_POWER_DOWN),
transitionSourceSubMode(SUBMODE_NONE), deviceSwitch(setDeviceSwitch)
{ {
this->cookie->setMaxReplyLen(maxReplyLen);
commandQueue = QueueFactory::instance()-> commandQueue = QueueFactory::instance()->
createMessageQueue(cmdQueueSize, CommandMessage::MAX_MESSAGE_SIZE); createMessageQueue(cmdQueueSize, CommandMessage::MAX_MESSAGE_SIZE);
cookieInfo.state = COOKIE_UNUSED; cookieInfo.state = COOKIE_UNUSED;
insertInCommandMap(RAW_COMMAND_ID); insertInCommandMap(RAW_COMMAND_ID);
if (this->fdirInstance == NULL) { if (this->fdirInstance == nullptr) {
this->fdirInstance = this->fdirInstance =
new DeviceHandlerFailureIsolation(setObjectId, defaultFDIRParentId); new DeviceHandlerFailureIsolation(setObjectId, defaultFDIRParentId);
} }
} }
DeviceHandlerBase::~DeviceHandlerBase() { DeviceHandlerBase::~DeviceHandlerBase() {
communicationInterface->close(cookie);
if (defaultFDIRUsed) { if (defaultFDIRUsed) {
delete fdirInstance; delete fdirInstance;
} }
@ -63,10 +60,12 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
decrementDeviceReplyMap(); decrementDeviceReplyMap();
fdirInstance->checkForFailures(); fdirInstance->checkForFailures();
hkSwitcher.performOperation(); hkSwitcher.performOperation();
performOperationHook();
} }
if (mode == MODE_OFF) { if (mode == MODE_OFF) {
return RETURN_OK; return RETURN_OK;
} }
switch (getRmapAction()) { switch (getRmapAction()) {
case SEND_WRITE: case SEND_WRITE:
if ((cookieInfo.state == COOKIE_UNUSED)) { if ((cookieInfo.state == COOKIE_UNUSED)) {
@ -87,6 +86,7 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
default: default:
break; break;
} }
return RETURN_OK; return RETURN_OK;
} }
@ -102,11 +102,11 @@ ReturnValue_t DeviceHandlerBase::initialize() {
return RETURN_FAILED; return RETURN_FAILED;
} }
result = communicationInterface->open(&cookie, logicalAddress, // result = communicationInterface->open(&cookie, logicalAddress,
maxDeviceReplyLen); // maxDeviceReplyLen, comParameter1, comParameter2);
if (result != RETURN_OK) { // if (result != RETURN_OK) {
return result; // return result;
} // }
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE); IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
if (IPCStore == NULL) { if (IPCStore == NULL) {
@ -166,7 +166,6 @@ ReturnValue_t DeviceHandlerBase::initialize() {
mySet.commit(PoolVariableIF::VALID); mySet.commit(PoolVariableIF::VALID);
return RETURN_OK; return RETURN_OK;
} }
void DeviceHandlerBase::decrementDeviceReplyMap() { void DeviceHandlerBase::decrementDeviceReplyMap() {
@ -549,7 +548,7 @@ void DeviceHandlerBase::doGetWrite() {
void DeviceHandlerBase::doSendRead() { void DeviceHandlerBase::doSendRead() {
ReturnValue_t result; ReturnValue_t result;
result = communicationInterface->requestReceiveMessage(cookie); result = communicationInterface->requestReceiveMessage(cookie, requestLen);
if (result == RETURN_OK) { if (result == RETURN_OK) {
cookieInfo.state = COOKIE_READ_SENT; cookieInfo.state = COOKIE_READ_SENT;
} else { } else {
@ -563,10 +562,10 @@ void DeviceHandlerBase::doSendRead() {
} }
void DeviceHandlerBase::doGetRead() { void DeviceHandlerBase::doGetRead() {
uint32_t receivedDataLen; size_t receivedDataLen;
uint8_t *receivedData; uint8_t *receivedData;
DeviceCommandId_t foundId = 0xFFFFFFFF; DeviceCommandId_t foundId = 0xFFFFFFFF;
uint32_t foundLen = 0; size_t foundLen = 0;
ReturnValue_t result; ReturnValue_t result;
if (cookieInfo.state != COOKIE_READ_SENT) { if (cookieInfo.state != COOKIE_READ_SENT) {
@ -637,8 +636,8 @@ void DeviceHandlerBase::doGetRead() {
} }
ReturnValue_t DeviceHandlerBase::getStorageData(store_address_t storageAddress, ReturnValue_t DeviceHandlerBase::getStorageData(store_address_t storageAddress,
uint8_t * *data, uint32_t * len) { uint8_t ** data, size_t * len) {
uint32_t lenTmp; size_t lenTmp;
if (IPCStore == NULL) { if (IPCStore == NULL) {
*data = NULL; *data = NULL;
@ -689,7 +688,7 @@ void DeviceHandlerBase::replyRawData(const uint8_t *data, size_t len,
//Default child implementations //Default child implementations
DeviceHandlerBase::RmapAction_t DeviceHandlerBase::getRmapAction() { DeviceHandlerBase::CommunicationAction_t DeviceHandlerBase::getRmapAction() {
switch (pstStep) { switch (pstStep) {
case 0: case 0:
return SEND_WRITE; return SEND_WRITE;
@ -749,20 +748,20 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData,
} }
} }
ReturnValue_t DeviceHandlerBase::switchCookieChannel(object_id_t newChannelId) { //ReturnValue_t DeviceHandlerBase::switchCookieChannel(object_id_t newChannelId) {
DeviceCommunicationIF *newCommunication = objectManager->get< // DeviceCommunicationIF *newCommunication = objectManager->get<
DeviceCommunicationIF>(newChannelId); // DeviceCommunicationIF>(newChannelId);
//
if (newCommunication != NULL) { // if (newCommunication != NULL) {
ReturnValue_t result = newCommunication->reOpen(cookie, logicalAddress, // ReturnValue_t result = newCommunication->reOpen(cookie, logicalAddress,
maxDeviceReplyLen); // maxDeviceReplyLen, comParameter1, comParameter2);
if (result != RETURN_OK) { // if (result != RETURN_OK) {
return result; // return result;
} // }
return RETURN_OK; // return RETURN_OK;
} // }
return RETURN_FAILED; // return RETURN_FAILED;
} //}
void DeviceHandlerBase::buildRawDeviceCommand(CommandMessage* commandMessage) { void DeviceHandlerBase::buildRawDeviceCommand(CommandMessage* commandMessage) {
storedRawData = DeviceHandlerMessage::getStoreAddress(commandMessage); storedRawData = DeviceHandlerMessage::getStoreAddress(commandMessage);
@ -1046,12 +1045,13 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(
} }
replyReturnvalueToCommand(RETURN_OK); replyReturnvalueToCommand(RETURN_OK);
return RETURN_OK; return RETURN_OK;
case DeviceHandlerMessage::CMD_SWITCH_IOBOARD: case DeviceHandlerMessage::CMD_SWITCH_ADDRESS:
if (mode != MODE_OFF) { if (mode != MODE_OFF) {
replyReturnvalueToCommand(WRONG_MODE_FOR_COMMAND); replyReturnvalueToCommand(WRONG_MODE_FOR_COMMAND);
} else { } else {
result = switchCookieChannel( // rework in progress
DeviceHandlerMessage::getIoBoardObjectId(message)); //result = switchCookieChannel(
// DeviceHandlerMessage::getIoBoardObjectId(message));
if (result == RETURN_OK) { if (result == RETURN_OK) {
replyReturnvalueToCommand(RETURN_OK); replyReturnvalueToCommand(RETURN_OK);
} else { } else {
@ -1278,3 +1278,6 @@ void DeviceHandlerBase::debugInterface(uint8_t positionTracker, object_id_t obje
uint32_t DeviceHandlerBase::getLogicalAddress() { uint32_t DeviceHandlerBase::getLogicalAddress() {
return logicalAddress; return logicalAddress;
} }
void DeviceHandlerBase::performOperationHook() {
}

View File

@ -18,9 +18,9 @@
#include <framework/devicehandlers/DeviceHandlerFailureIsolation.h> #include <framework/devicehandlers/DeviceHandlerFailureIsolation.h>
#include <framework/datapool/HkSwitchHelper.h> #include <framework/datapool/HkSwitchHelper.h>
#include <framework/serialize/SerialFixedArrayListAdapter.h> #include <framework/serialize/SerialFixedArrayListAdapter.h>
#include <map>
#include <framework/ipc/MessageQueueIF.h> #include <framework/ipc/MessageQueueIF.h>
#include <framework/tasks/PeriodicTaskIF.h> #include <framework/tasks/PeriodicTaskIF.h>
#include <map>
namespace Factory{ namespace Factory{
void setStaticFrameworkObjectIds(); void setStaticFrameworkObjectIds();
@ -29,7 +29,7 @@ void setStaticFrameworkObjectIds();
class StorageManagerIF; class StorageManagerIF;
/** /**
* \defgroup devices Devices * @defgroup devices Devices
* Contains all devices and the DeviceHandlerBase class. * Contains all devices and the DeviceHandlerBase class.
*/ */
@ -38,18 +38,20 @@ class StorageManagerIF;
* @details * @details
* 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, communication with * It features handling of @link DeviceHandlerIF::Mode_t Modes @endlink,
* physical devices, using the @link DeviceCommunicationIF @endlink, and communication with commanding objects. * communication with physical devices, using the @link DeviceCommunicationIF @endlink,
* and communication with commanding objects.
* It inherits SystemObject and thus can be created by the ObjectManagerIF. * 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 step-wise execution.
* For each step an RMAP action is selected and executed. * For each step an RMAP action is selected and executed.
* If data has been received (GET_READ), the data will be interpreted. * If data has been received (GET_READ), the data will be interpreted.
* The action for each step can be defined by the child class but as most device handlers share a 4-call * The action for each step can be defined by the child class but as most
* (sendRead-getRead-sendWrite-getWrite) structure, a default implementation is provided. * device handlers share a 4-call (sendRead-getRead-sendWrite-getWrite) structure,
* NOTE: RMAP is a standard which is used for FLP. * 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 two write and two send calls involved. * However, the communication principles are similar to RMAP as there are
* two write and two send calls involved.
* *
* Device handler instances should extend this class and implement the abstract functions. * Device handler instances should extend this class and implement the abstract functions.
* Components and drivers can send so called cookies which are used for communication * Components and drivers can send so called cookies which are used for communication
@ -83,7 +85,7 @@ 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 maxDeviceReplyLen the largest allowed reply size
* @param setDeviceSwitch the switch the device is connected to, for devices using two switches, overwrite getSwitches() * @param setDeviceSwitch the switch the device is connected to, for devices using two switches, overwrite getSwitches()
* @param deviceCommuncation Communcation Interface object which is used to implement communication functions * @param deviceCommuncation Communcation Interface object which is used to implement communication functions
* @param thermalStatePoolId * @param thermalStatePoolId
@ -91,12 +93,11 @@ public:
* @param fdirInstance * @param fdirInstance
* @param cmdQueueSize * @param cmdQueueSize
*/ */
DeviceHandlerBase(uint32_t logicalAddress, object_id_t setObjectId, DeviceHandlerBase(object_id_t setObjectId, address_t logicalAddress_,
uint32_t maxDeviceReplyLen, uint8_t setDeviceSwitch, object_id_t deviceCommunication, Cookie* cookie_, size_t maxReplyLen,
object_id_t deviceCommunication, uint8_t setDeviceSwitch, uint32_t thermalStatePoolId = PoolVariableIF::NO_PARAMETER,
uint32_t thermalStatePoolId = PoolVariableIF::NO_PARAMETER,
uint32_t thermalRequestPoolId = PoolVariableIF::NO_PARAMETER, uint32_t thermalRequestPoolId = PoolVariableIF::NO_PARAMETER,
FailureIsolationBase* fdirInstance = NULL, uint32_t cmdQueueSize = 20); FailureIsolationBase* fdirInstance = nullptr, size_t cmdQueueSize = 20);
/** /**
* @brief This function is the device handler base core component and is called periodically. * @brief This function is the device handler base core component and is called periodically.
@ -281,8 +282,8 @@ protected:
* - @c DeviceHandlerIF::IGNORE_FULL_PACKET Ignore the packet * - @c DeviceHandlerIF::IGNORE_FULL_PACKET Ignore the packet
* - @c APERIODIC_REPLY if a valid reply is received that has not been requested by a command, but should be handled anyway (@see also fillCommandAndCookieMap() ) * - @c APERIODIC_REPLY if a valid reply is received that has not been requested by a command, but should be handled anyway (@see also fillCommandAndCookieMap() )
*/ */
virtual ReturnValue_t scanForReply(const uint8_t *start, uint32_t len, virtual ReturnValue_t scanForReply(const uint8_t *start, size_t len,
DeviceCommandId_t *foundId, uint32_t *foundLen) = 0; DeviceCommandId_t *foundId, size_t *foundLen) = 0;
/** /**
* @brief Interpret a reply from the device. * @brief Interpret a reply from the device.
@ -301,6 +302,14 @@ protected:
virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, virtual ReturnValue_t interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) = 0; const uint8_t *packet) = 0;
/**
* set all datapool variables that are update periodically in normal mode invalid
*
* Child classes should provide an implementation which sets all those variables invalid
* which are set periodically during any normal mode.
*/
virtual void setNormalDatapoolEntriesInvalid() = 0;
/** /**
* @brief Can be implemented by child handler to * @brief Can be implemented by child handler to
* perform debugging * perform debugging
@ -344,6 +353,12 @@ protected:
virtual ReturnValue_t getSwitches(const uint8_t **switches, virtual ReturnValue_t getSwitches(const uint8_t **switches,
uint8_t *numberOfSwitches); uint8_t *numberOfSwitches);
/**
* Can be used to perform device specific periodic operations.
* This is called on the SEND_READ step of the performOperation() call
*/
virtual void performOperationHook();
public: public:
/** /**
* @param parentQueueId * @param parentQueueId
@ -396,11 +411,32 @@ protected:
/** /**
* Pointer to the raw packet that will be sent. * Pointer to the raw packet that will be sent.
*/ */
uint8_t *rawPacket; uint8_t *rawPacket = nullptr;
/** /**
* Size of the #rawPacket. * Size of the #rawPacket.
*/ */
uint32_t rawPacketLen; size_t rawPacketLen = 0;
/**
* Size of data to request.
*/
size_t requestLen = 0;
// /**
// * This union (or std::variant) type can be used to set comParameters which
// * are passed in the open() and reOpen() calls to the communication
// * interface
// * TODO: I don't know if we should use C++17 features but if we do we propably
// * should also write a function to get either a storeId handle
// * or an array handle so these values can be set conveniently.
// * The good think is that if there are many parameters, they can
// * be stored in the IPC pool. But maybe two uint32_t parameters are enough.
// * Simple = Good. It is downwards compatible and one can still store
// * 4 bytes of parameters AND a store ID.
// */
// comParameters_t comParameters;
// uint32_t comParameter1 = 0;
// uint32_t comParameter2 = 0;
/** /**
* The mode the device handler is currently in. * The mode the device handler is currently in.
@ -419,12 +455,12 @@ protected:
/** /**
* This is the counter value from performOperation(). * This is the counter value from performOperation().
*/ */
uint8_t pstStep; uint8_t pstStep = 0;
/** /**
* This will be used in the RMAP getRead command as expected length, is set by the constructor, can be modiefied at will. * This will be used in the RMAP getRead command as expected length, is set by the constructor, can be modiefied at will.
*/ */
const uint32_t maxDeviceReplyLen; const uint32_t maxDeviceReplyLen = 0;
/** /**
* wiretapping flag: * wiretapping flag:
@ -442,7 +478,7 @@ protected:
* Statically initialized in initialize() to a configurable object. Used when there is no method * Statically initialized in initialize() to a configurable object. Used when there is no method
* of finding a recipient, ie raw mode and reporting erreonous replies * of finding a recipient, ie raw mode and reporting erreonous replies
*/ */
MessageQueueId_t defaultRawReceiver; MessageQueueId_t defaultRawReceiver = 0;
store_address_t storedRawData; store_address_t storedRawData;
@ -451,19 +487,19 @@ protected:
* *
* if #isWiretappingActive all raw communication from and to the device will be sent to this queue * if #isWiretappingActive all raw communication from and to the device will be sent to this queue
*/ */
MessageQueueId_t requestedRawTraffic; MessageQueueId_t requestedRawTraffic = 0;
/** /**
* the object used to set power switches * the object used to set power switches
*/ */
PowerSwitchIF *powerSwitcher; PowerSwitchIF *powerSwitcher = nullptr;
/** /**
* Pointer to the IPCStore. * Pointer to the IPCStore.
* *
* This caches the pointer received from the objectManager in the constructor. * This caches the pointer received from the objectManager in the constructor.
*/ */
StorageManagerIF *IPCStore; StorageManagerIF *IPCStore = nullptr;
/** /**
* cached for init * cached for init
@ -473,17 +509,18 @@ protected:
/** /**
* Communication object used for device communication * Communication object used for device communication
*/ */
DeviceCommunicationIF *communicationInterface; DeviceCommunicationIF *communicationInterface = nullptr;
/** /**
* Cookie used for communication * Cookie used for communication. This is passed to the communication
* interface.
*/ */
Cookie *cookie; Cookie *cookie;
/** /**
* The MessageQueue used to receive device handler commands and to send replies. * The MessageQueue used to receive device handler commands and to send replies.
*/ */
MessageQueueIF* commandQueue; MessageQueueIF* commandQueue = nullptr;
/** /**
* this is the datapool variable with the thermal state of the device * this is the datapool variable with the thermal state of the device
@ -512,9 +549,9 @@ protected:
* Optional Error code * Optional Error code
* Can be set in doStartUp(), doShutDown() and doTransition() to signal cause for Transition failure. * Can be set in doStartUp(), doShutDown() and doTransition() to signal cause for Transition failure.
*/ */
ReturnValue_t childTransitionFailure; ReturnValue_t childTransitionFailure = RETURN_OK;
uint32_t ignoreMissedRepliesCount; //!< Counts if communication channel lost a reply, so some missed replys can be ignored. uint32_t ignoreMissedRepliesCount = 0; //!< Counts if communication channel lost a reply, so some missed replys can be ignored.
FailureIsolationBase* fdirInstance; //!< Pointer to the used FDIR instance. If not provided by child, default class is instantiated. FailureIsolationBase* fdirInstance; //!< Pointer to the used FDIR instance. If not provided by child, default class is instantiated.
@ -531,6 +568,28 @@ protected:
static object_id_t rawDataReceiverId; //!< Object which receives RAW data by default. static object_id_t rawDataReceiverId; //!< Object which receives RAW data by default.
static object_id_t defaultFDIRParentId; //!< Object which may be the root cause of an identified fault. static object_id_t defaultFDIRParentId; //!< Object which may be the root cause of an identified fault.
/**
* Set the device handler mode
*
* Sets #timeoutStart with every call.
*
* Sets #transitionTargetMode if necessary so transitional states can be entered from everywhere without breaking the state machine
* (which relies on a correct #transitionTargetMode).
*
* The submode is left unchanged.
*
*
* @param newMode
*/
void setMode(Mode_t newMode);
/**
* @overload
* @param submode
*/
void setMode(Mode_t newMode, Submode_t submode);
/** /**
* Helper function to report a missed reply * Helper function to report a missed reply
* *
@ -559,27 +618,6 @@ protected:
*/ */
void replyToCommand(ReturnValue_t status, uint32_t parameter = 0); void replyToCommand(ReturnValue_t status, uint32_t parameter = 0);
/**
* Set the device handler mode
*
* Sets #timeoutStart with every call.
*
* Sets #transitionTargetMode if necessary so transitional states can be entered from everywhere without breaking the state machine
* (which relies on a correct #transitionTargetMode).
*
* The submode is left unchanged.
*
*
* @param newMode
*/
void setMode(Mode_t newMode);
/**
* @overload
* @param submode
*/
void setMode(Mode_t newMode, Submode_t submode);
/** /**
* Do the transition to the main modes (MODE_ON, MODE_NORMAL and MODE_RAW). * Do the transition to the main modes (MODE_ON, MODE_NORMAL and MODE_RAW).
* *
@ -628,7 +666,7 @@ protected:
* *
* @return The Rmap action to execute in this step * @return The Rmap action to execute in this step
*/ */
virtual RmapAction_t getRmapAction(); virtual CommunicationAction_t getRmapAction();
/** /**
* Build the device command to send for raw mode. * Build the device command to send for raw mode.
@ -655,8 +693,10 @@ protected:
* This is a helper method to facilitate inserting entries in the command map. * This is a helper method to facilitate inserting entries in the command map.
* @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 waits until it times out. * @param maxDelayCycles The maximum number of delay cycles the command waits until it times out.
* @param periodic Indicates if the command is periodic (i.e. it is sent by the device repeatedly without request) or not. * @param periodic Indicates if the reply is periodic (i.e. it is sent by the device repeatedly without request) or not.
* Default is aperiodic (0) * Default is aperiodic (0)
* @param hasDifferentReplyId
* @param replyId
* @return RETURN_OK when the command was successfully inserted, COMMAND_MAP_ERROR else. * @return RETURN_OK when the command was successfully inserted, COMMAND_MAP_ERROR else.
*/ */
ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand, ReturnValue_t insertInCommandAndReplyMap(DeviceCommandId_t deviceCommand,
@ -769,14 +809,6 @@ protected:
*/ */
ReturnValue_t getStateOfSwitches(void); ReturnValue_t getStateOfSwitches(void);
/**
* set all datapool variables that are update periodically in normal mode invalid
*
* Child classes should provide an implementation which sets all those variables invalid
* which are set periodically during any normal mode.
*/
virtual void setNormalDatapoolEntriesInvalid() = 0;
/** /**
* build a list of sids and pass it to the #hkSwitcher * build a list of sids and pass it to the #hkSwitcher
*/ */
@ -897,7 +929,7 @@ private:
/** /**
* State a cookie is in. * State a cookie is in.
* *
* Used to keep track of the state of the RMAP communication. * Used to keep track of the state of the communication.
*/ */
enum CookieState_t { enum CookieState_t {
COOKIE_UNUSED, //!< The Cookie is unused COOKIE_UNUSED, //!< The Cookie is unused
@ -934,7 +966,7 @@ private:
* *
* Set when setMode() is called. * Set when setMode() is called.
*/ */
uint32_t timeoutStart; uint32_t timeoutStart = 0;
/** /**
* Delay for the current mode transition, used for time out * Delay for the current mode transition, used for time out
@ -976,6 +1008,8 @@ private:
* - checks whether commanded mode transitions are required and calls handleCommandedModeTransition() * - checks whether commanded mode transitions are required and calls handleCommandedModeTransition()
* - does the necessary action for the current mode or calls doChildStateMachine in modes @c MODE_TO_ON and @c MODE_TO_OFF * - does the necessary action for the current mode or calls doChildStateMachine in modes @c MODE_TO_ON and @c MODE_TO_OFF
* - actions that happen in transitions (eg setting a timeout) are handled in setMode() * - actions that happen in transitions (eg setting a timeout) are handled in setMode()
* - Maybe export this into own class to increase modularity of software
* and reduce the massive class size ?
*/ */
void doStateMachine(void); void doStateMachine(void);
@ -1054,8 +1088,8 @@ private:
* - @c RETURN_FAILED IPCStore is NULL * - @c RETURN_FAILED IPCStore is NULL
* - the return value from the IPCStore if it was not @c RETURN_OK * - the return value from the IPCStore if it was not @c RETURN_OK
*/ */
ReturnValue_t getStorageData(store_address_t storageAddress, uint8_t **data, ReturnValue_t getStorageData(store_address_t storageAddress,
uint32_t *len); uint8_t ** data, size_t * len);
/** /**
* set all switches returned by getSwitches() * set all switches returned by getSwitches()
@ -1084,7 +1118,7 @@ private:
* - @c RETURN_FAILED when cookies could not be changed, eg because the newChannel is not enabled * - @c RETURN_FAILED when cookies could not be changed, eg because the newChannel is not enabled
* - @c returnvalues of RMAPChannelIF::isActive() * - @c returnvalues of RMAPChannelIF::isActive()
*/ */
ReturnValue_t switchCookieChannel(object_id_t newChannelId); //ReturnValue_t switchCookieChannel(object_id_t newChannelId);
/** /**
* Handle device handler messages (e.g. commands sent by PUS Service 2) * Handle device handler messages (e.g. commands sent by PUS Service 2)