Merge pull request 'DHB additional step for performOperation' (#281) from KSat/fsfw:mueller/DHB-update into development
Reviewed-on: fsfw/fsfw#281
This commit is contained in:
commit
faedd40665
@ -15,6 +15,11 @@ a C file without issues
|
||||
- The same is possible for the event reporting service (PUS5)
|
||||
- PUS Health Service added, which allows to command and retrieve health via PUS packets
|
||||
|
||||
### Device Handler Base
|
||||
|
||||
- There is an additional `PERFORM_OPERATION` step for the device handler base. It is important
|
||||
that DHB users adapt their polling sequence tables to perform this step. This steps allows for aclear distinction between operation and communication steps
|
||||
|
||||
### Events
|
||||
|
||||
- makeEvent function: Now takes three input parameters instead of two and
|
||||
|
@ -1,23 +1,19 @@
|
||||
/**
|
||||
* @file AcceptsDeviceResponsesIF.h
|
||||
* @brief This file defines the AcceptsDeviceResponsesIF class.
|
||||
* @date 15.05.2013
|
||||
* @author baetz
|
||||
*/
|
||||
|
||||
#ifndef ACCEPTSDEVICERESPONSESIF_H_
|
||||
#define ACCEPTSDEVICERESPONSESIF_H_
|
||||
#ifndef FSFW_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_
|
||||
#define FSFW_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_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 {
|
||||
public:
|
||||
/**
|
||||
* Default empty virtual destructor.
|
||||
*/
|
||||
virtual ~AcceptsDeviceResponsesIF() {
|
||||
}
|
||||
virtual MessageQueueId_t getDeviceQueue() = 0;
|
||||
virtual ~AcceptsDeviceResponsesIF() {}
|
||||
virtual MessageQueueId_t getDeviceQueue() = 0;
|
||||
};
|
||||
|
||||
#endif /* ACCEPTSDEVICERESPONSESIF_H_ */
|
||||
#endif /* FSFW_DEVICEHANDLERS_ACCEPTSDEVICERESPONSESIF_H_ */
|
||||
|
@ -2,10 +2,10 @@
|
||||
|
||||
AssemblyBase::AssemblyBase(object_id_t objectId, object_id_t parentId,
|
||||
uint16_t commandQueueDepth) :
|
||||
SubsystemBase(objectId, parentId, MODE_OFF, commandQueueDepth), internalState(
|
||||
STATE_NONE), recoveryState(RECOVERY_IDLE), recoveringDevice(
|
||||
childrenMap.end()), targetMode(MODE_OFF), targetSubmode(
|
||||
SUBMODE_NONE) {
|
||||
SubsystemBase(objectId, parentId, MODE_OFF, commandQueueDepth),
|
||||
internalState(STATE_NONE), recoveryState(RECOVERY_IDLE),
|
||||
recoveringDevice(childrenMap.end()), targetMode(MODE_OFF),
|
||||
targetSubmode(SUBMODE_NONE) {
|
||||
recoveryOffTimer.setTimeout(POWER_OFF_TIME_MS);
|
||||
}
|
||||
|
||||
@ -165,9 +165,8 @@ ReturnValue_t AssemblyBase::checkChildrenState() {
|
||||
}
|
||||
|
||||
ReturnValue_t AssemblyBase::checkChildrenStateOff() {
|
||||
for (std::map<object_id_t, ChildInfo>::iterator iter = childrenMap.begin();
|
||||
iter != childrenMap.end(); iter++) {
|
||||
if (checkChildOff(iter->first) != RETURN_OK) {
|
||||
for (const auto& childIter: childrenMap) {
|
||||
if (checkChildOff(childIter.first) != RETURN_OK) {
|
||||
return NOT_ENOUGH_CHILDREN_IN_CORRECT_STATE;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,30 @@
|
||||
#ifndef ASSEMBLYBASE_H_
|
||||
#define ASSEMBLYBASE_H_
|
||||
#ifndef FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_
|
||||
#define FSFW_DEVICEHANDLERS_ASSEMBLYBASE_H_
|
||||
|
||||
#include "../container/FixedArrayList.h"
|
||||
#include "DeviceHandlerBase.h"
|
||||
#include "../container/FixedArrayList.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 {
|
||||
public:
|
||||
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 =
|
||||
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();
|
||||
|
||||
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 {
|
||||
STATE_NONE,
|
||||
STATE_OVERWRITE_HEALTH,
|
||||
@ -36,6 +87,7 @@ protected:
|
||||
RECOVERY_WAIT
|
||||
} recoveryState; //!< Indicates if one of the children requested a recovery.
|
||||
ChildrenMap::iterator recoveringDevice;
|
||||
|
||||
/**
|
||||
* the mode the current transition is trying to achieve.
|
||||
* Can be different from the modehelper.commandedMode!
|
||||
@ -61,8 +113,8 @@ protected:
|
||||
bool handleChildrenChanged();
|
||||
|
||||
/**
|
||||
* This method is called if the children changed its mode in a way that the current
|
||||
* mode can't be kept.
|
||||
* This method is called if the children changed its mode in a way that
|
||||
* the current mode can't be kept.
|
||||
* Default behavior is to go to MODE_OFF.
|
||||
* @param result The failure code which was returned by checkChildrenState.
|
||||
*/
|
||||
@ -75,9 +127,6 @@ protected:
|
||||
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
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 doStartTransition(Mode_t mode, Submode_t submode);
|
||||
@ -90,24 +139,6 @@ protected:
|
||||
|
||||
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();
|
||||
|
||||
ReturnValue_t checkChildrenState();
|
||||
@ -125,8 +156,9 @@ protected:
|
||||
* Also sets state to STATE_OVERWRITE_HEATH.
|
||||
* @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_ */
|
||||
|
@ -1,16 +1,18 @@
|
||||
#include "ChildHandlerBase.h"
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
#include "../devicehandlers/ChildHandlerBase.h"
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
|
||||
ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId,
|
||||
object_id_t deviceCommunication, CookieIF * cookie,
|
||||
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId,
|
||||
object_id_t parent, FailureIsolationBase* customFdir,
|
||||
size_t cmdQueueSize) :
|
||||
object_id_t hkDestination, uint32_t thermalStatePoolId,
|
||||
uint32_t thermalRequestPoolId,
|
||||
object_id_t parent,
|
||||
FailureIsolationBase* customFdir, size_t cmdQueueSize) :
|
||||
DeviceHandlerBase(setObjectId, deviceCommunication, cookie,
|
||||
(customFdir == nullptr? &childHandlerFdir : customFdir),
|
||||
cmdQueueSize),
|
||||
parentId(parent), childHandlerFdir(setObjectId) {
|
||||
this->setHkDestination(hkDestination);
|
||||
this->setThermalStateRequestPoolIds(thermalStatePoolId,
|
||||
thermalRequestPoolId);
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
#ifndef FSFW_DEVICES_CHILDHANDLERBASE_H_
|
||||
#define FSFW_DEVICES_CHILDHANDLERBASE_H_
|
||||
#ifndef FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
|
||||
#define FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_
|
||||
|
||||
#include "ChildHandlerFDIR.h"
|
||||
#include "DeviceHandlerBase.h"
|
||||
#include "ChildHandlerFDIR.h"
|
||||
|
||||
class ChildHandlerBase: public DeviceHandlerBase {
|
||||
public:
|
||||
ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication,
|
||||
CookieIF * cookie, uint32_t thermalStatePoolId,
|
||||
uint32_t thermalRequestPoolId,
|
||||
CookieIF * cookie, object_id_t hkDestination,
|
||||
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId,
|
||||
object_id_t parent = objects::NO_OBJECT,
|
||||
FailureIsolationBase* customFdir = nullptr,
|
||||
size_t cmdQueueSize = 20);
|
||||
|
||||
virtual ~ChildHandlerBase();
|
||||
|
||||
virtual ReturnValue_t initialize();
|
||||
@ -22,5 +23,4 @@ protected:
|
||||
|
||||
};
|
||||
|
||||
#endif /* FSFW_DEVICES_CHILDHANDLERBASE_H_ */
|
||||
|
||||
#endif /* FSFW_DEVICEHANDLER_CHILDHANDLERBASE_H_ */
|
||||
|
@ -1,6 +1,7 @@
|
||||
#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) {
|
||||
recoveryCounter.setFailureThreshold(recoveryCount);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef FRAMEWORK_DEVICEHANDLERS_CHILDHANDLERFDIR_H_
|
||||
#define FRAMEWORK_DEVICEHANDLERS_CHILDHANDLERFDIR_H_
|
||||
#ifndef FSFW_DEVICEHANDLERS_CHILDHANDLERFDIR_H_
|
||||
#define FSFW_DEVICEHANDLERS_CHILDHANDLERFDIR_H_
|
||||
|
||||
#include "DeviceHandlerFailureIsolation.h"
|
||||
|
||||
|
@ -1,11 +1,12 @@
|
||||
#ifndef COOKIE_H_
|
||||
#define COOKIE_H_
|
||||
#ifndef FSFW_DEVICEHANDLER_COOKIE_H_
|
||||
#define FSFW_DEVICEHANDLER_COOKIE_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
/**
|
||||
* @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
|
||||
@ -16,7 +17,6 @@ typedef std::uint32_t address_t;
|
||||
* calling @code{.cpp} CookieIF* childCookie = new ChildCookie(...)
|
||||
* @endcode .
|
||||
*
|
||||
* [not implemented yet]
|
||||
* This cookie is then passed to the child device handlers, which stores the
|
||||
* pointer and passes it to the communication interface functions.
|
||||
*
|
||||
@ -31,4 +31,4 @@ public:
|
||||
virtual ~CookieIF() {};
|
||||
};
|
||||
|
||||
#endif /* COOKIE_H_ */
|
||||
#endif /* FSFW_DEVICEHANDLER_COOKIE_H_ */
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef DEVICECOMMUNICATIONIF_H_
|
||||
#define DEVICECOMMUNICATIONIF_H_
|
||||
#ifndef FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_
|
||||
#define FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_
|
||||
|
||||
#include "CookieIF.h"
|
||||
#include "DeviceHandlerIF.h"
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include <cstddef>
|
||||
/**
|
||||
* @defgroup interfaces Interfaces
|
||||
* @brief Interfaces for flight software objects
|
||||
@ -19,8 +20,8 @@
|
||||
* the device handler to allow reuse of these components.
|
||||
* @details
|
||||
* Documentation: Dissertation Baetz p.138.
|
||||
* It works with the assumption that received data
|
||||
* is polled by a component. There are four generic steps of device communication:
|
||||
* It works with the assumption that received data is polled by a component.
|
||||
* There are four generic steps of device communication:
|
||||
*
|
||||
* 1. Send data to a device
|
||||
* 2. Get acknowledgement for sending
|
||||
@ -38,24 +39,20 @@ class DeviceCommunicationIF: public HasReturnvaluesIF {
|
||||
public:
|
||||
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
|
||||
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
|
||||
static const ReturnValue_t NULLPOINTER = MAKE_RETURN_CODE(0x02);
|
||||
static const ReturnValue_t INVALID_COOKIE_TYPE = MAKE_RETURN_CODE(0x03);
|
||||
static const ReturnValue_t NULLPOINTER = 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?
|
||||
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(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);
|
||||
static const ReturnValue_t TOO_MUCH_DATA = MAKE_RETURN_CODE(0x06);
|
||||
|
||||
virtual ~DeviceCommunicationIF() {}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Device specific initialization, using the cookie.
|
||||
* @details
|
||||
@ -76,13 +73,13 @@ public:
|
||||
* by implementing and calling related drivers or wrapper functions.
|
||||
* @param cookie
|
||||
* @param data
|
||||
* @param len
|
||||
* @param len If this is 0, nothing shall be sent.
|
||||
* @return
|
||||
* - @c RETURN_OK for successfull send
|
||||
* - Everything else triggers failure event with returnvalue as parameter 1
|
||||
*/
|
||||
virtual ReturnValue_t sendMessage(CookieIF *cookie, const uint8_t * sendData,
|
||||
size_t sendLen) = 0;
|
||||
virtual ReturnValue_t sendMessage(CookieIF *cookie,
|
||||
const uint8_t * sendData, size_t sendLen) = 0;
|
||||
|
||||
/**
|
||||
* Called by DHB in the GET_WRITE doGetWrite().
|
||||
@ -108,7 +105,7 @@ public:
|
||||
* returnvalue as parameter 1
|
||||
*/
|
||||
virtual ReturnValue_t requestReceiveMessage(CookieIF *cookie,
|
||||
size_t requestLen) = 0;
|
||||
size_t requestLen) = 0;
|
||||
|
||||
/**
|
||||
* Called by DHB in the GET_WRITE doGetRead().
|
||||
@ -124,8 +121,8 @@ public:
|
||||
* - Everything else triggers failure event with
|
||||
* returnvalue as parameter 1
|
||||
*/
|
||||
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||
size_t *size) = 0;
|
||||
virtual ReturnValue_t readReceivedMessage(CookieIF *cookie,
|
||||
uint8_t **buffer, size_t *size) = 0;
|
||||
};
|
||||
|
||||
#endif /* DEVICECOMMUNICATIONIF_H_ */
|
||||
#endif /* FSFW_DEVICES_DEVICECOMMUNICATIONIF_H_ */
|
||||
|
@ -72,8 +72,13 @@ DeviceHandlerBase::~DeviceHandlerBase() {
|
||||
|
||||
ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
|
||||
this->pstStep = counter;
|
||||
this->lastStep = this->pstStep;
|
||||
|
||||
if (getComAction() == SEND_WRITE) {
|
||||
if (getComAction() == CommunicationAction::NOTHING) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
if (getComAction() == CommunicationAction::PERFORM_OPERATION) {
|
||||
cookieInfo.state = COOKIE_UNUSED;
|
||||
readCommandQueue();
|
||||
doStateMachine();
|
||||
@ -83,26 +88,29 @@ ReturnValue_t DeviceHandlerBase::performOperation(uint8_t counter) {
|
||||
hkSwitcher.performOperation();
|
||||
hkManager.performHkOperation();
|
||||
performOperationHook();
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
if (mode == MODE_OFF) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
switch (getComAction()) {
|
||||
case SEND_WRITE:
|
||||
if ((cookieInfo.state == COOKIE_UNUSED)) {
|
||||
case CommunicationAction::SEND_WRITE:
|
||||
if (cookieInfo.state == COOKIE_UNUSED) {
|
||||
// if no external command was specified, build internal command.
|
||||
buildInternalCommand();
|
||||
}
|
||||
doSendWrite();
|
||||
break;
|
||||
case GET_WRITE:
|
||||
case CommunicationAction::GET_WRITE:
|
||||
doGetWrite();
|
||||
break;
|
||||
case SEND_READ:
|
||||
case CommunicationAction::SEND_READ:
|
||||
doSendRead();
|
||||
break;
|
||||
case GET_READ:
|
||||
case CommunicationAction::GET_READ:
|
||||
doGetRead();
|
||||
cookieInfo.state = COOKIE_UNUSED;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -821,24 +829,27 @@ void DeviceHandlerBase::replyRawData(const uint8_t *data, size_t len,
|
||||
}
|
||||
|
||||
//Default child implementations
|
||||
DeviceHandlerIF::CommunicationAction_t DeviceHandlerBase::getComAction() {
|
||||
DeviceHandlerIF::CommunicationAction DeviceHandlerBase::getComAction() {
|
||||
switch (pstStep) {
|
||||
case 0:
|
||||
return SEND_WRITE;
|
||||
return CommunicationAction::PERFORM_OPERATION;
|
||||
break;
|
||||
case 1:
|
||||
return GET_WRITE;
|
||||
break;
|
||||
return CommunicationAction::SEND_WRITE;
|
||||
break;
|
||||
case 2:
|
||||
return SEND_READ;
|
||||
return CommunicationAction::GET_WRITE;
|
||||
break;
|
||||
case 3:
|
||||
return GET_READ;
|
||||
return CommunicationAction::SEND_READ;
|
||||
break;
|
||||
case 4:
|
||||
return CommunicationAction::GET_READ;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return NOTHING;
|
||||
return CommunicationAction::NOTHING;
|
||||
}
|
||||
|
||||
MessageQueueId_t DeviceHandlerBase::getCommandQueue() const {
|
||||
|
@ -577,6 +577,7 @@ protected:
|
||||
|
||||
/** This is the counter value from performOperation(). */
|
||||
uint8_t pstStep = 0;
|
||||
uint8_t lastStep = 0;
|
||||
uint32_t pstIntervalMs = 0;
|
||||
|
||||
/**
|
||||
@ -841,7 +842,7 @@ protected:
|
||||
* @return The Rmap action to execute in this step
|
||||
*/
|
||||
|
||||
virtual CommunicationAction_t getComAction();
|
||||
virtual CommunicationAction getComAction();
|
||||
|
||||
/**
|
||||
* Build the device command to send for raw mode.
|
||||
|
@ -247,6 +247,14 @@ bool DeviceHandlerFailureIsolation::isFdirInActionOrAreWeFaulty(
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if (owner == nullptr) {
|
||||
// Configuration error.
|
||||
sif::error << "DeviceHandlerFailureIsolation::"
|
||||
<< "isFdirInActionOrAreWeFaulty: Owner not set!" << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (owner->getHealth() == HasHealthIF::FAULTY
|
||||
|| owner->getHealth() == HasHealthIF::PERMANENT_FAULTY) {
|
||||
//Ignore all events in case device is already faulty.
|
||||
|
@ -1,12 +1,19 @@
|
||||
#ifndef DEVICEHANDLERIF_H_
|
||||
#define DEVICEHANDLERIF_H_
|
||||
#ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_
|
||||
#define FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_
|
||||
|
||||
#include "DeviceHandlerMessage.h"
|
||||
|
||||
#include "../action/HasActionsIF.h"
|
||||
#include "DeviceHandlerMessage.h"
|
||||
#include "../events/Event.h"
|
||||
#include "../modes/HasModesIF.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.
|
||||
* @details Includes all expected return values, events and modes.
|
||||
@ -15,6 +22,7 @@
|
||||
class DeviceHandlerIF {
|
||||
public:
|
||||
|
||||
|
||||
static const uint8_t TRANSITION_MODE_CHILD_ACTION_MASK = 0x20;
|
||||
static const uint8_t TRANSITION_MODE_BASE_ACTION_MASK = 0x10;
|
||||
|
||||
@ -49,6 +57,8 @@ public:
|
||||
//! This is a transitional state which can not be commanded.
|
||||
//! 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.
|
||||
//! 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;
|
||||
//! It is possible to set the mode to _MODE_TO_ON to use the to on
|
||||
//! transition if available.
|
||||
@ -98,7 +108,7 @@ public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF;
|
||||
|
||||
// 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_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);
|
||||
@ -131,7 +141,8 @@ public:
|
||||
*
|
||||
* This is used by the child class to tell the base class what to do.
|
||||
*/
|
||||
enum CommunicationAction_t: uint8_t {
|
||||
enum CommunicationAction: uint8_t {
|
||||
PERFORM_OPERATION,
|
||||
SEND_WRITE,//!< Send write
|
||||
GET_WRITE, //!< Get write
|
||||
SEND_READ, //!< Send read
|
||||
@ -152,4 +163,4 @@ public:
|
||||
|
||||
};
|
||||
|
||||
#endif /* DEVICEHANDLERIF_H_ */
|
||||
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERIF_H_ */
|
||||
|
@ -1,10 +1,6 @@
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "DeviceHandlerMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
DeviceHandlerMessage::DeviceHandlerMessage() {
|
||||
}
|
||||
|
||||
store_address_t DeviceHandlerMessage::getStoreAddress(
|
||||
const CommandMessage* message) {
|
||||
return store_address_t(message->getParameter2());
|
||||
@ -25,14 +21,6 @@ uint8_t DeviceHandlerMessage::getWiretappingMode(
|
||||
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(
|
||||
CommandMessage* message, store_address_t rawPacketStoreId) {
|
||||
message->setCommand(CMD_RAW);
|
||||
@ -47,7 +35,7 @@ void DeviceHandlerMessage::setDeviceHandlerWiretappingMessage(
|
||||
|
||||
void DeviceHandlerMessage::setDeviceHandlerSwitchIoBoardMessage(
|
||||
CommandMessage* message, uint32_t ioBoardIdentifier) {
|
||||
message->setCommand(CMD_SWITCH_IOBOARD);
|
||||
message->setCommand(CMD_SWITCH_ADDRESS);
|
||||
message->setParameter(ioBoardIdentifier);
|
||||
}
|
||||
|
||||
@ -79,18 +67,17 @@ void DeviceHandlerMessage::setDeviceHandlerDirectCommandReply(
|
||||
void DeviceHandlerMessage::clear(CommandMessage* message) {
|
||||
switch (message->getCommand()) {
|
||||
case CMD_RAW:
|
||||
// case CMD_DIRECT:
|
||||
case REPLY_RAW_COMMAND:
|
||||
case REPLY_RAW_REPLY:
|
||||
case REPLY_DIRECT_COMMAND_DATA: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
if (ipcStore != nullptr) {
|
||||
ipcStore->deleteData(getStoreAddress(message));
|
||||
}
|
||||
}
|
||||
/* NO BREAK falls through*/
|
||||
case CMD_SWITCH_IOBOARD:
|
||||
case CMD_SWITCH_ADDRESS:
|
||||
case CMD_WIRETAPPING:
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
message->setParameter(0);
|
||||
|
@ -1,69 +1,56 @@
|
||||
#ifndef DEVICEHANDLERMESSAGE_H_
|
||||
#define DEVICEHANDLERMESSAGE_H_
|
||||
#ifndef FSFW_DEVICEHANDLERS_DEVICEHANDLERMESSAGE_H_
|
||||
#define FSFW_DEVICEHANDLERS_DEVICEHANDLERMESSAGE_H_
|
||||
|
||||
#include "../action/ActionMessage.h"
|
||||
#include "../ipc/CommandMessage.h"
|
||||
#include "../objectmanager/SystemObjectIF.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
|
||||
*
|
||||
* The values are defined in the device-specific implementations
|
||||
*/
|
||||
typedef uint32_t DeviceCommandId_t;
|
||||
|
||||
/**
|
||||
* The DeviceHandlerMessage is used to send Commands to a DeviceHandlerIF
|
||||
* @brief The DeviceHandlerMessage is used to send commands to classes
|
||||
* implementing DeviceHandlerIF
|
||||
*/
|
||||
class DeviceHandlerMessage {
|
||||
private:
|
||||
DeviceHandlerMessage();
|
||||
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
|
||||
*/
|
||||
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
|
||||
// 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
|
||||
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_WIRETAPPING = MAKE_COMMAND_ID( 4 ); //!< (De)Activates the monitoring of all raw traffic in DeviceHandlers, setParameter is 0 to deactivate, 1 to activate
|
||||
//! Sends a raw command, setParameter is a storeId containing the
|
||||
//! raw packet to send
|
||||
static const Command_t CMD_RAW = MAKE_COMMAND_ID(1);
|
||||
//! 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)
|
||||
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_WIRETAPPING = MAKE_COMMAND_ID( 3); //!< Reply to a @c CMD_WIRETAPPING, getParameter() is the current state, 1 enabled, 0 disabled
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
|
||||
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
|
||||
//! Signals that a direct command was sent
|
||||
static const Command_t REPLY_DIRECT_COMMAND_SENT = ActionMessage::STEP_SUCCESS;
|
||||
//! Contains a raw command sent to the Device
|
||||
static const Command_t REPLY_RAW_COMMAND = MAKE_COMMAND_ID(0x11);
|
||||
//! 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_RAW_REPLY = MAKE_COMMAND_ID(0x12);
|
||||
static const Command_t REPLY_DIRECT_COMMAND_DATA = ActionMessage::DATA_REPLY;
|
||||
|
||||
/**
|
||||
* Default Destructor
|
||||
*/
|
||||
virtual ~DeviceHandlerMessage() {
|
||||
}
|
||||
|
||||
static store_address_t getStoreAddress(const CommandMessage* message);
|
||||
static uint32_t getDeviceCommandId(const CommandMessage* message);
|
||||
static object_id_t getDeviceObjectId(const CommandMessage *message);
|
||||
static object_id_t getIoBoardObjectId(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,
|
||||
object_id_t deviceObjectid,
|
||||
store_address_t commandParametersStoreId);
|
||||
@ -75,11 +62,6 @@ public:
|
||||
object_id_t deviceObjectid, store_address_t rawPacketStoreId,
|
||||
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,
|
||||
uint8_t wiretappingMode);
|
||||
static void setDeviceHandlerSwitchIoBoardMessage(CommandMessage* message,
|
||||
@ -88,4 +70,4 @@ public:
|
||||
static void clear(CommandMessage* message);
|
||||
};
|
||||
|
||||
#endif /* DEVICEHANDLERMESSAGE_H_ */
|
||||
#endif /* FSFW_DEVICEHANDLERS_DEVICEHANDLERMESSAGE_H_ */
|
||||
|
@ -1,4 +1,3 @@
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
#include "DeviceTmReportingWrapper.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef DEVICETMREPORTINGWRAPPER_H_
|
||||
#define DEVICETMREPORTINGWRAPPER_H_
|
||||
#ifndef FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
|
||||
#define FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
|
||||
|
||||
#include "../action/HasActionsIF.h"
|
||||
#include "../objectmanager/SystemObjectIF.h"
|
||||
@ -24,4 +24,4 @@ private:
|
||||
SerializeIF *data;
|
||||
};
|
||||
|
||||
#endif /* DEVICETMREPORTINGWRAPPER_H_ */
|
||||
#endif /* FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_ */
|
||||
|
@ -13,10 +13,10 @@ HealthDevice::~HealthDevice() {
|
||||
}
|
||||
|
||||
ReturnValue_t HealthDevice::performOperation(uint8_t opCode) {
|
||||
CommandMessage message;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&message);
|
||||
CommandMessage command;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
healthHelper.handleHealthCommand(&message);
|
||||
healthHelper.handleHealthCommand(&command);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef HEALTHDEVICE_H_
|
||||
#define HEALTHDEVICE_H_
|
||||
#ifndef FSFW_DEVICEHANDLERS_HEALTHDEVICE_H_
|
||||
#define FSFW_DEVICEHANDLERS_HEALTHDEVICE_H_
|
||||
|
||||
#include "../health/HasHealthIF.h"
|
||||
#include "../health/HealthHelper.h"
|
||||
@ -37,4 +37,4 @@ public:
|
||||
HealthHelper healthHelper;
|
||||
};
|
||||
|
||||
#endif /* HEALTHDEVICE_H_ */
|
||||
#endif /* FSFW_DEVICEHANDLERS_HEALTHDEVICE_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user