moved all return values to DH IF

This commit is contained in:
Robin Müller 2020-03-24 14:21:57 +01:00
parent 7e8d92f956
commit ea49d88c4b
7 changed files with 92 additions and 73 deletions

View File

@ -44,10 +44,11 @@ public:
/**
* Execute or initialize the execution of a certain function.
* Returning #EXECUTION_FINISHED or a failure code, nothing else needs to be done.
* When needing more steps, return RETURN_OK and issue steps and completion manually. One "step failed" or completion report must
* be issued!
* When needing more steps, return RETURN_OK and issue steps and completion manually.
* One "step failed" or completion report must be issued!
*/
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy, const uint8_t* data, uint32_t size) = 0;
virtual ReturnValue_t executeAction(ActionId_t actionId, MessageQueueId_t commandedBy,
const uint8_t* data, size_t size) = 0;
};

View File

@ -26,7 +26,7 @@ MessageQueueId_t DataPoolAdmin::getCommandQueue() const {
}
ReturnValue_t DataPoolAdmin::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy, const uint8_t* data, uint32_t size) {
MessageQueueId_t commandedBy, const uint8_t* data, size_t size) {
if (actionId != SET_VALIDITY) {
return INVALID_ACTION_ID;
}

View File

@ -33,8 +33,8 @@ public:
ReturnValue_t handleMemoryDump(uint32_t address, uint32_t size,
uint8_t** dataPointer, uint8_t* copyHere);
ReturnValue_t executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy, const uint8_t* data, uint32_t size);
virtual ReturnValue_t executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy, const uint8_t* data, size_t size);
//not implemented as ParameterHelper is no used
ReturnValue_t getParameter(uint8_t domainId, uint16_t parameterId,

View File

@ -811,9 +811,9 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(
iter = deviceReplyMap.find(command->first);
}
if (iter != deviceReplyMap.end()) {
DeviceReplyInfo *info = &(iter->second);
info->delayCycles = info->maxDelayCycles;
info->command = command;
DeviceReplyInfo & info = iter->second;
info.delayCycles = info.maxDelayCycles;
info.command = command;
command->second.expectedReplies = expectedReplies;
return RETURN_OK;
} else {
@ -1056,7 +1056,7 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(
if (result == RETURN_OK) {
replyReturnvalueToCommand(RETURN_OK);
} else {
replyReturnvalueToCommand(CANT_SWITCH_IOBOARD);
replyReturnvalueToCommand(CANT_SWITCH_ADDRESS);
}
}
return RETURN_OK;
@ -1138,11 +1138,15 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* data,
}
ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy, const uint8_t* data, uint32_t size) {
MessageQueueId_t commandedBy, const uint8_t* data, size_t size) {
ReturnValue_t result = acceptExternalDeviceCommands();
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if(size == 0) {
return NO_COMMAND_DATA;
}
DeviceCommandMap::iterator iter = deviceCommandMap.find(actionId);
if (iter == deviceCommandMap.end()) {
result = COMMAND_NOT_SUPPORTED;
@ -1161,7 +1165,7 @@ ReturnValue_t DeviceHandlerBase::executeAction(ActionId_t actionId,
}
void DeviceHandlerBase::buildInternalCommand(void) {
//Neither Raw nor Direct could build a command
// Neither Raw nor Direct could build a command
ReturnValue_t result = NOTHING_TO_SEND;
DeviceCommandId_t deviceCommandId = NO_COMMAND_ID;
if (mode == MODE_NORMAL) {
@ -1179,12 +1183,13 @@ void DeviceHandlerBase::buildInternalCommand(void) {
} else {
return;
}
if (result == NOTHING_TO_SEND) {
return;
}
if (result == RETURN_OK) {
DeviceCommandMap::iterator iter = deviceCommandMap.find(
deviceCommandId);
DeviceCommandMap::iterator iter =
deviceCommandMap.find(deviceCommandId);
if (iter == deviceCommandMap.end()) {
result = COMMAND_NOT_SUPPORTED;
} else if (iter->second.isExecuting) {
@ -1199,6 +1204,7 @@ void DeviceHandlerBase::buildInternalCommand(void) {
cookieInfo.state = COOKIE_WRITE_READY;
}
}
if (result != RETURN_OK) {
triggerEvent(DEVICE_BUILDING_COMMAND_FAILED, result, deviceCommandId);
}

View File

@ -197,8 +197,9 @@ protected:
*
* @param[out] id the device command id that has been built
* @return
* - @c RETURN_OK when a command is to be sent
* - not @c RETURN_OK when no command is to be sent
* - @c RETURN_OK to send command after setting #rawPacket and #rawPacketLen.
* - @c NOTHING_TO_SEND when no command is to be sent.
* - Anything else triggers an even with the returnvalue as a parameter.
*/
virtual ReturnValue_t buildNormalDeviceCommand(DeviceCommandId_t * id) = 0;
@ -216,21 +217,25 @@ protected:
* @param[out] id the device command id built
* @return
* - @c RETURN_OK when a command is to be sent
* - not @c RETURN_OK when no command is to be sent
* - @c NOTHING_TO_SEND when no command is to be sent
* - Anything else triggers an even with the returnvalue as a parameter
*/
virtual ReturnValue_t buildTransitionDeviceCommand(DeviceCommandId_t * id) = 0;
/**
* Build a device command packet from data supplied by a direct command.
* @brief Build a device command packet from data supplied by a direct command.
*
* @details
* #rawPacket and #rawPacketLen should be set by this method to the packet to be sent.
* The existence of the command in the command map and the command size check
* against 0 are done by the base class.
*
* @param deviceCommand the command to build, already checked against deviceCommandMap
* @param commandData pointer to the data from the direct command
* @param commandDataLen length of commandData
* @return
* - @c RETURN_OK when #rawPacket is valid
* - @c RETURN_FAILED when #rawPacket is invalid and no data should be sent
* - @c RETURN_OK to send command after #rawPacket and #rawPacketLen have been set.
* - Anything else triggers an event with the returnvalue as a parameter
*/
virtual ReturnValue_t buildCommandFromCommand(DeviceCommandId_t deviceCommand,
const uint8_t * commandData, size_t commandDataLen) = 0;
@ -366,14 +371,29 @@ protected:
*/
virtual void performOperationHook();
/**
* The Returnvalues id of this class, required by HasReturnvaluesIF
*/
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE;
public:
/**
* @param parentQueueId
*/
virtual void setParentQueue(MessageQueueId_t parentQueueId);
/**
* This function call handles the execution of external commands as required
* by the HasActionIF.
* @param actionId
* @param commandedBy
* @param data
* @param size
* @return
*/
ReturnValue_t executeAction(ActionId_t actionId,
MessageQueueId_t commandedBy, const uint8_t* data, uint32_t size);
MessageQueueId_t commandedBy, const uint8_t* data, size_t size);
Mode_t getTransitionSourceMode() const;
Submode_t getTransitionSourceSubMode() const;
virtual void getMode(Mode_t *mode, Submode_t *submode);
@ -392,21 +412,6 @@ public:
virtual MessageQueueId_t getCommandQueue(void) const;
protected:
/**
* The Returnvalues id of this class, required by HasReturnvaluesIF
*/
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_BASE;
static const ReturnValue_t INVALID_CHANNEL = MAKE_RETURN_CODE(4);
static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(5); //!< This is used to specify for replies from a device which are not replies to requests
static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(6); //!< Ignore parts of the received packet
static const ReturnValue_t IGNORE_FULL_PACKET = MAKE_RETURN_CODE(7); //!< Ignore full received packet
// static const ReturnValue_t ONE_SWITCH = MAKE_RETURN_CODE(8);
// static const ReturnValue_t TWO_SWITCHES = MAKE_RETURN_CODE(9);
static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(10);
static const ReturnValue_t COMMAND_MAP_ERROR = MAKE_RETURN_CODE(11);
static const ReturnValue_t NOTHING_TO_SEND = MAKE_RETURN_CODE(12);
//Mode handling error Codes
static const ReturnValue_t CHILD_TIMEOUT = MAKE_RETURN_CODE(0xE1);
static const ReturnValue_t SWITCH_FAILED = MAKE_RETURN_CODE(0xE2);

View File

@ -8,12 +8,13 @@
#include <framework/ipc/MessageQueueSenderIF.h>
/**
* Physical address type
* @brief Physical address type
*/
typedef uint32_t address_t;
/**
* 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.
*
*/
class DeviceHandlerIF {
@ -60,36 +61,48 @@ public:
static const Event MONITORING_AMBIGUOUS = MAKE_EVENT(10, SEVERITY::HIGH);
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF;
static const ReturnValue_t NO_COMMAND_DATA = MAKE_RETURN_CODE(0xA0);
static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1);
static const ReturnValue_t COMMAND_ALREADY_SENT = MAKE_RETURN_CODE(0xA2);
static const ReturnValue_t COMMAND_WAS_NOT_SENT = MAKE_RETURN_CODE(0xA3);
static const ReturnValue_t CANT_SWITCH_IOBOARD = MAKE_RETURN_CODE(0xA4);
static const ReturnValue_t WRONG_MODE_FOR_COMMAND = MAKE_RETURN_CODE(0xA5);
static const ReturnValue_t TIMEOUT = MAKE_RETURN_CODE(0xA6);
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(0xA7);
static const ReturnValue_t NO_REPLY_EXPECTED = MAKE_RETURN_CODE(0xA8); //!< Used to indicate that this is a command-only command.
static const ReturnValue_t NON_OP_TEMPERATURE = MAKE_RETURN_CODE(0xA9);
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xAA);
// Standard codes used in scan for reply
//static const ReturnValue_t TOO_SHORT = MAKE_RETURN_CODE(0xB1);
static const ReturnValue_t CHECKSUM_ERROR = MAKE_RETURN_CODE(0xB2);
static const ReturnValue_t LENGTH_MISSMATCH = MAKE_RETURN_CODE(0xB3);
static const ReturnValue_t INVALID_DATA = MAKE_RETURN_CODE(0xB4);
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0xB5);
// Standard codes used when building commands.
static const ReturnValue_t NOTHING_TO_SEND = MAKE_RETURN_CODE(0xA0); //!< Return this if no command sending in required
// Mostly used for internal handling.
static const ReturnValue_t NO_COMMAND_DATA = MAKE_RETURN_CODE(0xA2); //!< If the command size is 0. Checked in DHB
static const ReturnValue_t NO_REPLY_EXPECTED = MAKE_RETURN_CODE(0xA3); //!< Used to indicate that this is a command-only command.
static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA4); //!< Command ID not in commandMap. Checked in DHB
static const ReturnValue_t COMMAND_ALREADY_SENT = MAKE_RETURN_CODE(0xA5); //!< Command was already executed. Checked in DHB
static const ReturnValue_t COMMAND_WAS_NOT_SENT = MAKE_RETURN_CODE(0xA6);
static const ReturnValue_t CANT_SWITCH_ADDRESS = MAKE_RETURN_CODE(0xA7);
static const ReturnValue_t WRONG_MODE_FOR_COMMAND = MAKE_RETURN_CODE(0xA8);
static const ReturnValue_t TIMEOUT = MAKE_RETURN_CODE(0xA9);
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(0xAA);
static const ReturnValue_t NON_OP_TEMPERATURE = MAKE_RETURN_CODE(0xAB);
static const ReturnValue_t COMMAND_NOT_IMPLEMENTED = MAKE_RETURN_CODE(0xAC);
// Standard codes used in interpret device reply
// Standard codes used in scanForReply
static const ReturnValue_t APERIODIC_REPLY = MAKE_RETURN_CODE(0xB1); //!< This is used to specify for replies from a device which are not replies to requests
static const ReturnValue_t LENGTH_MISSMATCH = MAKE_RETURN_CODE(0xB2);
static const ReturnValue_t IGNORE_REPLY_DATA = MAKE_RETURN_CODE(0xB3); //!< Ignore parts of the received packet
static const ReturnValue_t IGNORE_FULL_PACKET = MAKE_RETURN_CODE(0xB4); //!< Ignore full received packet
static const ReturnValue_t CHECKSUM_ERROR = MAKE_RETURN_CODE(0xB5);
static const ReturnValue_t INVALID_DATA = MAKE_RETURN_CODE(0xB6);
static const ReturnValue_t PROTOCOL_ERROR = MAKE_RETURN_CODE(0xB7);
// Standard codes used in interpretDeviceReply
static const ReturnValue_t DEVICE_DID_NOT_EXECUTE = MAKE_RETURN_CODE(0xC1); //the device reported, that it did not execute the command
static const ReturnValue_t DEVICE_REPORTED_ERROR = MAKE_RETURN_CODE(0xC2);
static const ReturnValue_t UNKNOW_DEVICE_REPLY = MAKE_RETURN_CODE(0xC3); //the deviceCommandId reported by scanforReply is unknown
static const ReturnValue_t DEVICE_REPLY_INVALID = MAKE_RETURN_CODE(0xC4); //syntax etc is correct but still not ok, eg parameters where none are expected
// Standard codes used in buildCommandFromCommand
static const ReturnValue_t INVALID_COMMAND_PARAMETER = MAKE_RETURN_CODE(
0xD0);
static const ReturnValue_t INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS =
MAKE_RETURN_CODE(0xD1);
static const ReturnValue_t INVALID_COMMAND_PARAMETER = MAKE_RETURN_CODE(0xD0);
static const ReturnValue_t INVALID_NUMBER_OR_LENGTH_OF_PARAMETERS = MAKE_RETURN_CODE(0xD1);
// Standard codes used in getSwitches
static const ReturnValue_t NO_SWITCH = MAKE_RETURN_CODE(0xE1); //!< Return in getSwitches() to specify there are no switches
// static const ReturnValue_t ONE_SWITCH = MAKE_RETURN_CODE(8);
// static const ReturnValue_t TWO_SWITCHES = MAKE_RETURN_CODE(9);
// where is this used?
// static const ReturnValue_t COMMAND_MAP_ERROR = MAKE_RETURN_CODE(11);
/**
* Communication action that will be executed.
@ -97,10 +110,10 @@ public:
* This is used by the child class to tell the base class what to do.
*/
enum CommunicationAction_t: uint8_t {
SEND_WRITE,//!< RMAP send write
GET_WRITE, //!< RMAP get write
SEND_READ, //!< RMAP send read
GET_READ, //!< RMAP get read
SEND_WRITE,//!< Send write
GET_WRITE, //!< Get write
SEND_READ, //!< Send read
GET_READ, //!< Get read
NOTHING //!< Do nothing.
};

View File

@ -9,19 +9,13 @@
typedef uint16_t ReturnValue_t;
class HasReturnvaluesIF {
public:
static const ReturnValue_t RETURN_OK = 0;
static const ReturnValue_t RETURN_FAILED = 1;
static const ReturnValue_t RETURN_FAILED = 0xFFFF;
virtual ~HasReturnvaluesIF() {
}
};
#endif /* HASRETURNVALUESIF_H_ */