MessageQueue refactoring complete
This commit is contained in:
parent
b1f91439c6
commit
8ff6506ad9
@ -16,7 +16,7 @@ ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) {
|
||||
ActionMessage::getStoreId(command));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
} else {
|
||||
return CommandMessage::UNKNOW_COMMAND;
|
||||
return CommandMessage::UNKNOWN_COMMAND;
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,13 +33,15 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
|
||||
}
|
||||
|
||||
void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) {
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
ActionMessage::setStepReply(&reply, commandId, step + STEP_OFFSET, result);
|
||||
queueToUse->sendMessage(reportTo, &reply);
|
||||
}
|
||||
|
||||
void ActionHelper::finish(MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) {
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
ActionMessage::setCompletionReply(&reply, commandId, result);
|
||||
queueToUse->sendMessage(reportTo, &reply);
|
||||
}
|
||||
@ -54,7 +56,8 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
ActionMessage::setStepReply(&reply, actionId, 0, result);
|
||||
queueToUse->sendMessage(commandedBy, &reply);
|
||||
return;
|
||||
@ -62,7 +65,8 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
|
||||
result = owner->executeAction(actionId, commandedBy, dataPtr, size);
|
||||
ipcStore->deleteData(dataAddress);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
ActionMessage::setStepReply(&reply, actionId, 0, result);
|
||||
queueToUse->sendMessage(commandedBy, &reply);
|
||||
return;
|
||||
@ -71,7 +75,8 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
|
||||
|
||||
ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
|
||||
ActionId_t replyId, SerializeIF* data, bool hideSender) {
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
store_address_t storeAddress;
|
||||
uint8_t *dataPtr;
|
||||
size_t maxSize = data->getSerializedSize();
|
||||
|
@ -53,7 +53,8 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo,
|
||||
|
||||
ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId,
|
||||
ActionId_t actionId, store_address_t storeId) {
|
||||
CommandMessage command;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
ActionMessage::setCommand(&command, actionId, storeId);
|
||||
ReturnValue_t result = queueToUse->sendMessage(queueId, &command);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
|
@ -36,7 +36,8 @@ void SimpleActionHelper::resetHelper() {
|
||||
|
||||
void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy,
|
||||
ActionId_t actionId, store_address_t dataAddress) {
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
if (isExecuting) {
|
||||
ipcStore->deleteData(dataAddress);
|
||||
ActionMessage::setStepReply(&reply, actionId, 0,
|
||||
|
@ -56,26 +56,27 @@ MessageQueueId_t ControllerBase::getCommandQueue() const {
|
||||
}
|
||||
|
||||
void ControllerBase::handleQueue() {
|
||||
CommandMessage message;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
ReturnValue_t result;
|
||||
for (result = commandQueue->receiveMessage(&message); result == RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&message)) {
|
||||
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&command)) {
|
||||
|
||||
result = modeHelper.handleModeCommand(&message);
|
||||
result = modeHelper.handleModeCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = healthHelper.handleHealthCommand(&message);
|
||||
result = healthHelper.handleHealthCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
result = handleCommandMessage(&message);
|
||||
result = handleCommandMessage(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
message.setToUnknownCommand();
|
||||
commandQueue->reply(&message);
|
||||
command.setToUnknownCommand();
|
||||
commandQueue->reply(&command);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
MapPacketExtraction::MapPacketExtraction(uint8_t setMapId,
|
||||
object_id_t setPacketDestination) :
|
||||
lastSegmentationFlag(NO_SEGMENTATION), mapId(setMapId), packetLength(0), bufferPosition(
|
||||
packetBuffer), packetDestination(setPacketDestination), packetStore(
|
||||
NULL), tcQueueId(MessageQueueSenderIF::NO_QUEUE) {
|
||||
lastSegmentationFlag(NO_SEGMENTATION), mapId(setMapId), packetLength(0),
|
||||
bufferPosition(packetBuffer), packetDestination(setPacketDestination),
|
||||
packetStore(nullptr), tcQueueId(MessageQueueMessageIF::NO_QUEUE) {
|
||||
memset(packetBuffer, 0, sizeof(packetBuffer));
|
||||
}
|
||||
|
||||
|
@ -21,14 +21,15 @@ ReturnValue_t HkSwitchHelper::initialize() {
|
||||
}
|
||||
|
||||
ReturnValue_t HkSwitchHelper::performOperation(uint8_t operationCode) {
|
||||
CommandMessage message;
|
||||
while (actionQueue->receiveMessage(&message) == HasReturnvaluesIF::RETURN_OK) {
|
||||
ReturnValue_t result = commandActionHelper.handleReply(&message);
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
while (actionQueue->receiveMessage(&command) == HasReturnvaluesIF::RETURN_OK) {
|
||||
ReturnValue_t result = commandActionHelper.handleReply(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
message.setToUnknownCommand();
|
||||
actionQueue->reply(&message);
|
||||
command.setToUnknownCommand();
|
||||
actionQueue->reply(&command);
|
||||
}
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
@ -66,7 +66,8 @@ ReturnValue_t DataPoolAdmin::getParameter(uint8_t domainId,
|
||||
}
|
||||
|
||||
void DataPoolAdmin::handleCommand() {
|
||||
CommandMessage command;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||
if (result != RETURN_OK) {
|
||||
return;
|
||||
@ -282,7 +283,8 @@ ReturnValue_t DataPoolAdmin::sendParameter(MessageQueueId_t to, uint32_t id,
|
||||
return result;
|
||||
}
|
||||
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
|
||||
ParameterMessage::setParameterDumpReply(&reply, id, address);
|
||||
|
||||
@ -294,7 +296,8 @@ ReturnValue_t DataPoolAdmin::sendParameter(MessageQueueId_t to, uint32_t id,
|
||||
//identical to ParameterHelper::rejectCommand()
|
||||
void DataPoolAdmin::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
|
||||
Command_t initialCommand) {
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
reply.setReplyRejected(reason, initialCommand);
|
||||
commandQueue->sendMessage(to, &reply);
|
||||
}
|
||||
|
@ -148,7 +148,8 @@ void AssemblyBase::handleModeTransitionFailed(ReturnValue_t result) {
|
||||
|
||||
void AssemblyBase::sendHealthCommand(MessageQueueId_t sendTo,
|
||||
HealthState health) {
|
||||
CommandMessage command;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
HealthMessage::setHealthMessage(&command, HealthMessage::HEALTH_SET,
|
||||
health);
|
||||
if (commandQueue->sendMessage(sendTo, &command) == RETURN_OK) {
|
||||
|
@ -218,8 +218,9 @@ void DeviceHandlerBase::readCommandQueue() {
|
||||
// message with 3 parameters). The full buffer is filled anyway
|
||||
// and I could just copy the content into the other message but
|
||||
// all I need are few additional functions the other message type offers.
|
||||
CommandMessage cmdMessage;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&cmdMessage);
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||
if (result != RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
@ -234,23 +235,23 @@ void DeviceHandlerBase::readCommandQueue() {
|
||||
// }
|
||||
|
||||
if(healthHelperActive) {
|
||||
result = healthHelper.handleHealthCommand(&cmdMessage);
|
||||
result = healthHelper.handleHealthCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
result = modeHelper.handleModeCommand(&cmdMessage);
|
||||
result = modeHelper.handleModeCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
result = actionHelper.handleActionMessage(&cmdMessage);
|
||||
result = actionHelper.handleActionMessage(&command);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
result = parameterHelper.handleParameterMessage(&cmdMessage);
|
||||
result = parameterHelper.handleParameterMessage(&command);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
@ -261,17 +262,17 @@ void DeviceHandlerBase::readCommandQueue() {
|
||||
// return;
|
||||
// }
|
||||
|
||||
result = handleDeviceHandlerMessage(&cmdMessage);
|
||||
result = handleDeviceHandlerMessage(&command);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
result = letChildHandleMessage(&cmdMessage);
|
||||
result = letChildHandleMessage(&command);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
replyReturnvalueToCommand(CommandMessage::UNKNOW_COMMAND);
|
||||
replyReturnvalueToCommand(CommandMessage::UNKNOWN_COMMAND);
|
||||
|
||||
}
|
||||
|
||||
@ -492,12 +493,13 @@ void DeviceHandlerBase::setMode(Mode_t newMode) {
|
||||
|
||||
void DeviceHandlerBase::replyReturnvalueToCommand(ReturnValue_t status,
|
||||
uint32_t parameter) {
|
||||
MessageQueueMessage message;
|
||||
//This is actually the reply protocol for raw and misc DH commands.
|
||||
if (status == RETURN_OK) {
|
||||
CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, parameter);
|
||||
CommandMessage reply(&message, CommandMessage::REPLY_COMMAND_OK, 0, parameter);
|
||||
commandQueue->reply(&reply);
|
||||
} else {
|
||||
CommandMessage reply(CommandMessage::REPLY_REJECTED, status, parameter);
|
||||
CommandMessage reply(&message, CommandMessage::REPLY_REJECTED, status, parameter);
|
||||
commandQueue->reply(&reply);
|
||||
}
|
||||
}
|
||||
@ -767,9 +769,10 @@ void DeviceHandlerBase::replyRawData(const uint8_t *data, size_t len,
|
||||
return;
|
||||
}
|
||||
|
||||
CommandMessage message;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
|
||||
DeviceHandlerMessage::setDeviceHandlerRawReplyMessage(&message,
|
||||
DeviceHandlerMessage::setDeviceHandlerRawReplyMessage(&command,
|
||||
getObjectId(), address, isCommand);
|
||||
|
||||
// this->DeviceHandlerCommand = CommandMessage::CMD_NONE;
|
||||
|
@ -13,10 +13,11 @@ HealthDevice::~HealthDevice() {
|
||||
}
|
||||
|
||||
ReturnValue_t HealthDevice::performOperation(uint8_t opCode) {
|
||||
CommandMessage message;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&message);
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
healthHelper.handleHealthCommand(&message);
|
||||
healthHelper.handleHealthCommand(&command);
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -65,29 +65,31 @@ void HealthHelper::informParent(HasHealthIF::HealthState health,
|
||||
if (parentQueue == 0) {
|
||||
return;
|
||||
}
|
||||
CommandMessage message;
|
||||
HealthMessage::setHealthMessage(&message, HealthMessage::HEALTH_INFO,
|
||||
MessageQueueMessage message;
|
||||
CommandMessage information(&message);
|
||||
HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO,
|
||||
health, oldHealth);
|
||||
if (MessageQueueSenderIF::sendMessage(parentQueue, &message,
|
||||
if (MessageQueueSenderIF::sendMessage(parentQueue, &information,
|
||||
owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::debug << "HealthHelper::informParent: sending health reply failed."
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void HealthHelper::handleSetHealthCommand(CommandMessage* message) {
|
||||
ReturnValue_t result = owner->setHealth(HealthMessage::getHealth(message));
|
||||
if (message->getSender() == 0) {
|
||||
void HealthHelper::handleSetHealthCommand(CommandMessage* command) {
|
||||
ReturnValue_t result = owner->setHealth(HealthMessage::getHealth(command));
|
||||
if (command->getSender() == MessageQueueMessageIF::NO_QUEUE) {
|
||||
return;
|
||||
}
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
HealthMessage::setHealthMessage(&reply,
|
||||
HealthMessage::REPLY_HEALTH_SET);
|
||||
} else {
|
||||
reply.setReplyRejected(result, message->getCommand());
|
||||
reply.setReplyRejected(result, command->getCommand());
|
||||
}
|
||||
if (MessageQueueSenderIF::sendMessage(message->getSender(), &reply,
|
||||
if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply,
|
||||
owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::debug << "HealthHelper::handleHealthCommand: sending health "
|
||||
"reply failed." << std::endl;
|
||||
|
@ -14,14 +14,26 @@ void clearMissionMessage(CommandMessage* message);
|
||||
}
|
||||
|
||||
|
||||
CommandMessage::CommandMessage() {
|
||||
this->messageSize = COMMAND_MESSAGE_SIZE;
|
||||
CommandMessage::CommandMessage(MessageQueueMessage* receiverMessage):
|
||||
internalMessage(receiverMessage) {
|
||||
if(receiverMessage == nullptr) {
|
||||
sif::error << "CommandMessage::CommandMessage: Don't pass a nullptr"
|
||||
" as the message queue message, pass the address of an actual"
|
||||
" message!" << std::endl;
|
||||
}
|
||||
internalMessage->messageSize = COMMAND_MESSAGE_SIZE;
|
||||
setCommand(CMD_NONE);
|
||||
}
|
||||
|
||||
CommandMessage::CommandMessage(Command_t command, uint32_t parameter1,
|
||||
uint32_t parameter2) {
|
||||
this->messageSize = COMMAND_MESSAGE_SIZE;
|
||||
CommandMessage::CommandMessage(MessageQueueMessage* messageToSet,
|
||||
Command_t command, uint32_t parameter1, uint32_t parameter2):
|
||||
internalMessage(messageToSet) {
|
||||
if(messageToSet == nullptr) {
|
||||
sif::error << "CommandMessage::CommandMessage: Don't pass a nullptr"
|
||||
" as the message queue message, pass the address of an actual"
|
||||
" message!" << std::endl;
|
||||
}
|
||||
internalMessage->messageSize = COMMAND_MESSAGE_SIZE;
|
||||
setCommand(command);
|
||||
setParameter(parameter1);
|
||||
setParameter2(parameter2);
|
||||
@ -29,7 +41,7 @@ CommandMessage::CommandMessage(Command_t command, uint32_t parameter1,
|
||||
|
||||
Command_t CommandMessage::getCommand() const {
|
||||
Command_t command;
|
||||
memcpy(&command, getData(), sizeof(Command_t));
|
||||
memcpy(&command, internalMessage->getData(), sizeof(Command_t));
|
||||
return command;
|
||||
}
|
||||
|
||||
@ -38,29 +50,35 @@ uint8_t CommandMessage::getMessageType() const {
|
||||
}
|
||||
|
||||
void CommandMessage::setCommand(Command_t command) {
|
||||
memcpy(getData(), &command, sizeof(command));
|
||||
memcpy(internalMessage->getData(), &command, sizeof(command));
|
||||
}
|
||||
|
||||
uint32_t CommandMessage::getParameter() const {
|
||||
uint32_t parameter1;
|
||||
memcpy(¶meter1, getData() + sizeof(Command_t), sizeof(parameter1));
|
||||
memcpy(¶meter1, internalMessage->getData() + sizeof(Command_t),
|
||||
sizeof(parameter1));
|
||||
return parameter1;
|
||||
}
|
||||
|
||||
void CommandMessage::setParameter(uint32_t parameter1) {
|
||||
memcpy(getData() + sizeof(Command_t), ¶meter1, sizeof(parameter1));
|
||||
memcpy(internalMessage->getData() + sizeof(Command_t),
|
||||
¶meter1, sizeof(parameter1));
|
||||
}
|
||||
|
||||
uint32_t CommandMessage::getParameter2() const {
|
||||
uint32_t parameter2;
|
||||
memcpy(¶meter2, getData() + sizeof(Command_t) + sizeof(uint32_t),
|
||||
sizeof(parameter2));
|
||||
memcpy(¶meter2, internalMessage->getData() + sizeof(Command_t)
|
||||
+ sizeof(uint32_t), sizeof(parameter2));
|
||||
return parameter2;
|
||||
}
|
||||
|
||||
void CommandMessage::setParameter2(uint32_t parameter2) {
|
||||
memcpy(getData() + sizeof(Command_t) + sizeof(uint32_t), ¶meter2,
|
||||
sizeof(parameter2));
|
||||
memcpy(internalMessage-> getData() + sizeof(Command_t) + sizeof(uint32_t),
|
||||
¶meter2, sizeof(parameter2));
|
||||
}
|
||||
|
||||
void CommandMessage::clear() {
|
||||
clearCommandMessage();
|
||||
}
|
||||
|
||||
void CommandMessage::clearCommandMessage() {
|
||||
@ -109,7 +127,7 @@ size_t CommandMessage::getMinimumMessageSize() const {
|
||||
void CommandMessage::setToUnknownCommand() {
|
||||
Command_t initialCommand = getCommand();
|
||||
clearCommandMessage();
|
||||
setReplyRejected(UNKNOW_COMMAND, initialCommand);
|
||||
setReplyRejected(UNKNOWN_COMMAND, initialCommand);
|
||||
}
|
||||
|
||||
void CommandMessage::setReplyRejected(ReturnValue_t reason,
|
||||
@ -118,3 +136,19 @@ void CommandMessage::setReplyRejected(ReturnValue_t reason,
|
||||
setParameter(reason);
|
||||
setParameter2(initialCommand);
|
||||
}
|
||||
|
||||
MessageQueueId_t CommandMessage::getSender() const {
|
||||
return internalMessage->getSender();
|
||||
}
|
||||
|
||||
uint8_t* CommandMessage::getBuffer() {
|
||||
return internalMessage->getBuffer();
|
||||
}
|
||||
|
||||
void CommandMessage::setSender(MessageQueueId_t setId) {
|
||||
internalMessage->setSender(setId);
|
||||
}
|
||||
|
||||
const uint8_t* CommandMessage::getBuffer() const {
|
||||
return internalMessage->getBuffer();
|
||||
}
|
||||
|
@ -13,10 +13,10 @@ typedef uint16_t Command_t;
|
||||
* @brief Used to pass command messages between tasks
|
||||
* @author Bastian Baetz
|
||||
*/
|
||||
class CommandMessage : public MessageQueueMessage {
|
||||
class CommandMessage: public MessageQueueMessageIF {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_MESSAGE;
|
||||
static const ReturnValue_t UNKNOW_COMMAND = MAKE_RETURN_CODE(0x01);
|
||||
static const ReturnValue_t UNKNOWN_COMMAND = MAKE_RETURN_CODE(0x01);
|
||||
|
||||
|
||||
static const uint8_t MESSAGE_ID = messagetypes::COMMAND;
|
||||
@ -31,7 +31,7 @@ public:
|
||||
* This is the size of a message as it is seen by the MessageQueue.
|
||||
* 14 of the 24 available MessageQueueMessage bytes are used.
|
||||
*/
|
||||
static const size_t COMMAND_MESSAGE_SIZE = HEADER_SIZE
|
||||
static const size_t COMMAND_MESSAGE_SIZE = MessageQueueMessage::HEADER_SIZE
|
||||
+ sizeof(Command_t) + 2 * sizeof(uint32_t);
|
||||
|
||||
/**
|
||||
@ -40,7 +40,7 @@ public:
|
||||
* This constructor should be used when receiving a Message, as the
|
||||
* content is filled by the MessageQueue.
|
||||
*/
|
||||
CommandMessage();
|
||||
CommandMessage(MessageQueueMessage* receiverMessage);
|
||||
/**
|
||||
* This constructor creates a new message with all message content
|
||||
* initialized
|
||||
@ -49,7 +49,7 @@ public:
|
||||
* @param parameter1 The first parameter
|
||||
* @param parameter2 The second parameter
|
||||
*/
|
||||
CommandMessage(Command_t command,
|
||||
CommandMessage(MessageQueueMessage* messageToSet, Command_t command,
|
||||
uint32_t parameter1, uint32_t parameter2);
|
||||
|
||||
/**
|
||||
@ -58,6 +58,8 @@ public:
|
||||
virtual ~CommandMessage() {
|
||||
}
|
||||
|
||||
uint8_t * getBuffer() override;
|
||||
const uint8_t * getBuffer() const override;
|
||||
/**
|
||||
* Read the DeviceHandlerCommand_t that is stored in the message,
|
||||
* usually used after receiving.
|
||||
@ -66,6 +68,16 @@ public:
|
||||
*/
|
||||
Command_t getCommand() const;
|
||||
|
||||
/**
|
||||
* @brief This method is used to set the sender's message queue id
|
||||
* information prior to sending the message.
|
||||
* @param setId
|
||||
* The message queue id that identifies the sending message queue.
|
||||
*/
|
||||
void setSender(MessageQueueId_t setId) override;
|
||||
|
||||
MessageQueueId_t getSender() const override;
|
||||
|
||||
uint8_t getMessageType() const;
|
||||
/**
|
||||
* Set the DeviceHandlerCOmmand_t of the message
|
||||
@ -102,6 +114,7 @@ public:
|
||||
*/
|
||||
void setParameter2(uint32_t parameter2);
|
||||
|
||||
void clear() override;
|
||||
/**
|
||||
* Set the command to CMD_NONE and try to find
|
||||
* the correct class to handle a more detailed
|
||||
@ -129,7 +142,10 @@ public:
|
||||
void setToUnknownCommand();
|
||||
void setReplyRejected(ReturnValue_t reason,
|
||||
Command_t initialCommand = CMD_NONE);
|
||||
size_t getMinimumMessageSize() const;
|
||||
size_t getMinimumMessageSize() const override;
|
||||
|
||||
private:
|
||||
MessageQueueMessage* internalMessage;
|
||||
};
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
class MessageQueueIF {
|
||||
public:
|
||||
static const MessageQueueId_t NO_QUEUE = MessageQueueSenderIF::NO_QUEUE; //!< Ugly hack.
|
||||
static const MessageQueueId_t NO_QUEUE = MessageQueueMessageIF::NO_QUEUE; //!< Ugly hack.
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF;
|
||||
/**
|
||||
@ -41,7 +41,7 @@ public:
|
||||
* @return RETURN_OK if ok
|
||||
* @return NO_REPLY_PARTNER Should return NO_REPLY_PARTNER if partner was found
|
||||
*/
|
||||
virtual ReturnValue_t reply( MessageQueueMessage* message ) = 0;
|
||||
virtual ReturnValue_t reply( MessageQueueMessageIF* message ) = 0;
|
||||
|
||||
/**
|
||||
* @brief This function reads available messages from the message queue and returns the sender.
|
||||
@ -50,7 +50,7 @@ public:
|
||||
* @param message A pointer to a message in which the received data is stored.
|
||||
* @param receivedFrom A pointer to a queue id in which the sender's id is stored.
|
||||
*/
|
||||
virtual ReturnValue_t receiveMessage(MessageQueueMessage* message,
|
||||
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message,
|
||||
MessageQueueId_t *receivedFrom) = 0;
|
||||
|
||||
/**
|
||||
@ -65,7 +65,7 @@ public:
|
||||
* @return -@c RETURN_OK on success
|
||||
* -@c MessageQueueIF::EMPTY if queue is empty
|
||||
*/
|
||||
virtual ReturnValue_t receiveMessage(MessageQueueMessage* message) = 0;
|
||||
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message) = 0;
|
||||
/**
|
||||
* Deletes all pending messages in the queue.
|
||||
* @param count The number of flushed messages.
|
||||
@ -95,7 +95,7 @@ public:
|
||||
* -@c MessageQueueIF::FULL if queue is full
|
||||
*/
|
||||
virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo,
|
||||
MessageQueueMessage* message, MessageQueueId_t sentFrom,
|
||||
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
||||
bool ignoreFault = false ) = 0;
|
||||
|
||||
/**
|
||||
@ -107,7 +107,7 @@ public:
|
||||
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full.
|
||||
*/
|
||||
virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo,
|
||||
MessageQueueMessage* message, bool ignoreFault = false ) = 0;
|
||||
MessageQueueMessageIF* message, bool ignoreFault = false ) = 0;
|
||||
|
||||
/**
|
||||
* @brief The sendToDefaultFrom method sends a queue message to the default destination.
|
||||
@ -118,7 +118,7 @@ public:
|
||||
* @return -@c RETURN_OK on success
|
||||
* -@c MessageQueueIF::FULL if queue is full
|
||||
*/
|
||||
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessage* message,
|
||||
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessageIF* message,
|
||||
MessageQueueId_t sentFrom, bool ignoreFault = false ) = 0;
|
||||
/**
|
||||
* @brief This operation sends a message to the default destination.
|
||||
@ -128,7 +128,7 @@ public:
|
||||
* @return -@c RETURN_OK on success
|
||||
* -@c MessageQueueIF::FULL if queue is full
|
||||
*/
|
||||
virtual ReturnValue_t sendToDefault( MessageQueueMessage* message ) = 0;
|
||||
virtual ReturnValue_t sendToDefault( MessageQueueMessageIF* message ) = 0;
|
||||
/**
|
||||
* \brief This method is a simple setter for the default destination.
|
||||
*/
|
||||
|
@ -51,7 +51,7 @@ void MessageQueueMessage::setSender(MessageQueueId_t setId) {
|
||||
memcpy(this->internalBuffer, &setId, sizeof(MessageQueueId_t));
|
||||
}
|
||||
|
||||
size_t MessageQueueMessage::getMinimumMessageSize() {
|
||||
size_t MessageQueueMessage::getMinimumMessageSize() const {
|
||||
return this->HEADER_SIZE;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ public:
|
||||
* @details The method must be overwritten by child classes if size checks shall be more strict.
|
||||
* @return The default implementation returns HEADER_SIZE.
|
||||
*/
|
||||
virtual size_t getMinimumMessageSize();
|
||||
virtual size_t getMinimumMessageSize() const;
|
||||
};
|
||||
|
||||
#endif /* MESSAGEQUEUEMESSAGE_H_ */
|
||||
|
@ -1,10 +1,23 @@
|
||||
#ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
|
||||
#define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
/*
|
||||
* TODO: Actually, the definition of this ID to be a uint32_t is not ideal and
|
||||
* breaks layering. However, it is difficult to keep layering, as the ID is
|
||||
* stored in many places and sent around in MessageQueueMessage.
|
||||
* Ideally, one would use the (current) object_id_t only, however, doing a
|
||||
* lookup of queueIDs for every call does not sound ideal.
|
||||
* In a first step, I'll circumvent the issue by not touching it,
|
||||
* maybe in a second step. This also influences Interface design
|
||||
* (getCommandQueue) and some other issues.. */
|
||||
typedef uint32_t MessageQueueId_t;
|
||||
|
||||
class MessageQueueMessageIF {
|
||||
public:
|
||||
static const MessageQueueId_t NO_QUEUE = 0xffffffff;
|
||||
|
||||
virtual ~MessageQueueMessageIF() {};
|
||||
|
||||
/**
|
||||
@ -12,11 +25,11 @@ public:
|
||||
* size is set to zero.
|
||||
*/
|
||||
virtual void clear() = 0;
|
||||
/**
|
||||
* @brief This is a debug method that prints the content
|
||||
* (till messageSize) to the debug output.
|
||||
*/
|
||||
virtual void print() = 0;
|
||||
// /**
|
||||
// * @brief This is a debug method that prints the content
|
||||
// * (till messageSize) to the debug output.
|
||||
// */
|
||||
// virtual void print() = 0;
|
||||
|
||||
/**
|
||||
* @brief Get read-only pointer to the raw buffer.
|
||||
@ -37,11 +50,13 @@ public:
|
||||
*/
|
||||
virtual void setSender(MessageQueueId_t setId) = 0;
|
||||
|
||||
virtual MessageQueueId_t getSender() const = 0;
|
||||
|
||||
/**
|
||||
* @brief This helper function is used by the MessageQueue class to
|
||||
* check the size of an incoming message.
|
||||
*/
|
||||
virtual size_t getMinimumMessageSize() = 0;
|
||||
virtual size_t getMinimumMessageSize() const = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,22 +1,11 @@
|
||||
#ifndef FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_
|
||||
#define FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_
|
||||
|
||||
#include <framework/ipc/MessageQueueMessageIF.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
class MessageQueueMessage;
|
||||
|
||||
|
||||
//TODO: Actually, the definition of this ID to be a uint32_t is not ideal and breaks layering.
|
||||
//However, it is difficult to keep layering, as the ID is stored in many places and sent around in
|
||||
//MessageQueueMessage.
|
||||
//Ideally, one would use the (current) object_id_t only, however, doing a lookup of queueIDs for every
|
||||
//call does not sound ideal.
|
||||
//In a first step, I'll circumvent the issue by not touching it, maybe in a second step.
|
||||
//This also influences Interface design (getCommandQueue) and some other issues..
|
||||
typedef uint32_t MessageQueueId_t;
|
||||
|
||||
class MessageQueueSenderIF {
|
||||
public:
|
||||
static const MessageQueueId_t NO_QUEUE = 0xffffffff;
|
||||
|
||||
virtual ~MessageQueueSenderIF() {}
|
||||
|
||||
@ -26,7 +15,8 @@ public:
|
||||
* Must be implemented by a subclass.
|
||||
*/
|
||||
static ReturnValue_t sendMessage(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage* message, MessageQueueId_t sentFrom = MessageQueueSenderIF::NO_QUEUE,
|
||||
MessageQueueMessageIF* message,
|
||||
MessageQueueId_t sentFrom = MessageQueueMessageIF::NO_QUEUE,
|
||||
bool ignoreFault=false);
|
||||
private:
|
||||
MessageQueueSenderIF() {}
|
||||
|
@ -51,14 +51,16 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode,
|
||||
break;
|
||||
default:
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, errorCode,
|
||||
MemoryMessage::CMD_MEMORY_LOAD);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
return;
|
||||
}
|
||||
//Only reached on success
|
||||
CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message, CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
}
|
||||
@ -66,7 +68,8 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode,
|
||||
void MemoryHelper::completeDump(ReturnValue_t errorCode,
|
||||
const uint8_t* dataToCopy, const uint32_t size) {
|
||||
busy = false;
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, errorCode, lastCommand);
|
||||
switch (errorCode) {
|
||||
case HasMemoryIF::DO_IT_MYSELF:
|
||||
@ -151,7 +154,8 @@ void MemoryHelper::handleMemoryLoad(CommandMessage* message) {
|
||||
completeLoad(returnCode, p_data, size, dataPointer);
|
||||
} else {
|
||||
//At least inform sender.
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, returnCode,
|
||||
MemoryMessage::CMD_MEMORY_LOAD);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
@ -169,7 +173,8 @@ void MemoryHelper::handleMemoryCheckOrDump(CommandMessage* message) {
|
||||
reservedSpaceInIPC);
|
||||
completeDump(returnCode, dataPointer, size);
|
||||
} else {
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
MemoryMessage::setMemoryReplyFailed(&reply, returnCode, lastCommand);
|
||||
queueToUse->sendMessage(lastSender, &reply);
|
||||
}
|
||||
|
@ -11,31 +11,32 @@ ModeHelper::~ModeHelper() {
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* message) {
|
||||
CommandMessage reply;
|
||||
ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) {
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
Mode_t mode;
|
||||
Submode_t submode;
|
||||
switch (message->getCommand()) {
|
||||
switch (command->getCommand()) {
|
||||
case ModeMessage::CMD_MODE_COMMAND_FORCED:
|
||||
forced = true;
|
||||
/* NO BREAK falls through*/
|
||||
case ModeMessage::CMD_MODE_COMMAND: {
|
||||
mode = ModeMessage::getMode(message);
|
||||
submode = ModeMessage::getSubmode(message);
|
||||
mode = ModeMessage::getMode(command);
|
||||
submode = ModeMessage::getSubmode(command);
|
||||
uint32_t timeout;
|
||||
ReturnValue_t result = owner->checkModeCommand(mode, submode, &timeout);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
ModeMessage::cantReachMode(&reply, result);
|
||||
MessageQueueSenderIF::sendMessage(message->getSender(), &reply,
|
||||
MessageQueueSenderIF::sendMessage(command->getSender(), &reply,
|
||||
owner->getCommandQueue());
|
||||
break;
|
||||
}
|
||||
//Free to start transition
|
||||
theOneWhoCommandedAMode = message->getSender();
|
||||
theOneWhoCommandedAMode = command->getSender();
|
||||
commandedMode = mode;
|
||||
commandedSubmode = submode;
|
||||
|
||||
if ((parentQueueId != MessageQueueSenderIF::NO_QUEUE)
|
||||
if ((parentQueueId != MessageQueueMessageIF::NO_QUEUE)
|
||||
&& (theOneWhoCommandedAMode != parentQueueId)) {
|
||||
owner->setToExternalControl();
|
||||
}
|
||||
@ -48,7 +49,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* message) {
|
||||
owner->getMode(&mode, &submode);
|
||||
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_REPLY, mode,
|
||||
submode);
|
||||
MessageQueueSenderIF::sendMessage(message->getSender(), &reply,
|
||||
MessageQueueSenderIF::sendMessage(command->getSender(), &reply,
|
||||
owner->getCommandQueue());
|
||||
}
|
||||
break;
|
||||
@ -73,13 +74,14 @@ void ModeHelper::modeChanged(Mode_t ownerMode, Submode_t ownerSubmode) {
|
||||
forced = false;
|
||||
sendModeReplyMessage(ownerMode, ownerSubmode);
|
||||
sendModeInfoMessage(ownerMode, ownerSubmode);
|
||||
theOneWhoCommandedAMode = MessageQueueSenderIF::NO_QUEUE;
|
||||
theOneWhoCommandedAMode = MessageQueueMessageIF::NO_QUEUE;
|
||||
}
|
||||
|
||||
void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
|
||||
Submode_t ownerSubmode) {
|
||||
CommandMessage reply;
|
||||
if (theOneWhoCommandedAMode != MessageQueueSenderIF::NO_QUEUE)
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
if (theOneWhoCommandedAMode != MessageQueueMessageIF::NO_QUEUE)
|
||||
{
|
||||
if (ownerMode != commandedMode or ownerSubmode != commandedSubmode)
|
||||
{
|
||||
@ -99,9 +101,10 @@ void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
|
||||
|
||||
void ModeHelper::sendModeInfoMessage(Mode_t ownerMode,
|
||||
Submode_t ownerSubmode) {
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
if (theOneWhoCommandedAMode != parentQueueId
|
||||
and parentQueueId != MessageQueueSenderIF::NO_QUEUE)
|
||||
and parentQueueId != MessageQueueMessageIF::NO_QUEUE)
|
||||
{
|
||||
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_INFO,
|
||||
ownerMode, ownerSubmode);
|
||||
|
@ -31,7 +31,8 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
CommandMessage report;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage report(&message);
|
||||
MonitoringMessage::setLimitViolationReport(&report, storeId);
|
||||
return MessageQueueSenderIF::sendMessage(reportQueue, &report);
|
||||
}
|
||||
|
@ -25,21 +25,21 @@ void MessageQueue::switchSystemContext(CallContext callContext) {
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::sendMessage(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage* message, bool ignoreFault) {
|
||||
MessageQueueMessageIF* message, bool ignoreFault) {
|
||||
return sendMessageFrom(sendTo, message, this->getId(), ignoreFault);
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::sendToDefault(MessageQueueMessage* message) {
|
||||
ReturnValue_t MessageQueue::sendToDefault(MessageQueueMessageIF* message) {
|
||||
return sendToDefaultFrom(message, this->getId());
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::sendToDefaultFrom(MessageQueueMessage* message,
|
||||
ReturnValue_t MessageQueue::sendToDefaultFrom(MessageQueueMessageIF* message,
|
||||
MessageQueueId_t sentFrom, bool ignoreFault) {
|
||||
return sendMessageFrom(defaultDestination,message,sentFrom,ignoreFault);
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::reply(MessageQueueMessage* message) {
|
||||
if (this->lastPartner != 0) {
|
||||
ReturnValue_t MessageQueue::reply(MessageQueueMessageIF* message) {
|
||||
if (this->lastPartner != MessageQueueMessageIF::NO_QUEUE) {
|
||||
return sendMessageFrom(this->lastPartner, message, this->getId());
|
||||
} else {
|
||||
return NO_REPLY_PARTNER;
|
||||
@ -47,7 +47,7 @@ ReturnValue_t MessageQueue::reply(MessageQueueMessage* message) {
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage* message, MessageQueueId_t sentFrom,
|
||||
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
||||
bool ignoreFault) {
|
||||
return sendMessageFromMessageQueue(sendTo, message, sentFrom,
|
||||
ignoreFault, callContext);
|
||||
@ -69,7 +69,7 @@ ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessage* message,
|
||||
ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message,
|
||||
MessageQueueId_t* receivedFrom) {
|
||||
ReturnValue_t status = this->receiveMessage(message);
|
||||
if(status == HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -78,7 +78,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessage* message,
|
||||
return status;
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessage* message) {
|
||||
ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
||||
BaseType_t result = xQueueReceive(handle,reinterpret_cast<void*>(
|
||||
message->getBuffer()), 0);
|
||||
if (result == pdPASS){
|
||||
@ -120,7 +120,7 @@ bool MessageQueue::isDefaultDestinationSet() const {
|
||||
|
||||
// static core function to send messages.
|
||||
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage *message, MessageQueueId_t sentFrom,
|
||||
MessageQueueMessageIF *message, MessageQueueId_t sentFrom,
|
||||
bool ignoreFault, CallContext callContext) {
|
||||
message->setSender(sentFrom);
|
||||
BaseType_t result;
|
||||
|
@ -85,14 +85,14 @@ public:
|
||||
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full.
|
||||
*/
|
||||
ReturnValue_t sendMessage(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage* message, bool ignoreFault = false );
|
||||
MessageQueueMessageIF* message, bool ignoreFault = false );
|
||||
/**
|
||||
* @brief This operation sends a message to the default destination.
|
||||
* @details As in the sendMessage method, this function uses the sendToDefault call of the
|
||||
* MessageQueueSender parent class and adds its queue id as "sentFrom" information.
|
||||
* @param message A pointer to a previously created message, which is sent.
|
||||
*/
|
||||
ReturnValue_t sendToDefault( MessageQueueMessage* message );
|
||||
ReturnValue_t sendToDefault( MessageQueueMessageIF* message );
|
||||
/**
|
||||
* @brief This operation sends a message to the last communication partner.
|
||||
* @details This operation simplifies answering an incoming message by using the stored
|
||||
@ -100,7 +100,7 @@ public:
|
||||
* (i.e. lastPartner is zero), an error code is returned.
|
||||
* @param message A pointer to a previously created message, which is sent.
|
||||
*/
|
||||
ReturnValue_t reply( MessageQueueMessage* message );
|
||||
ReturnValue_t reply( MessageQueueMessageIF* message );
|
||||
|
||||
/**
|
||||
* @brief With the sendMessage call, a queue message is sent to a receiving queue.
|
||||
@ -113,8 +113,9 @@ public:
|
||||
* This variable is set to zero by default.
|
||||
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full.
|
||||
*/
|
||||
virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo, MessageQueueMessage* message,
|
||||
MessageQueueId_t sentFrom = NO_QUEUE, bool ignoreFault = false );
|
||||
virtual ReturnValue_t sendMessageFrom( MessageQueueId_t sendTo,
|
||||
MessageQueueMessageIF* message, MessageQueueId_t sentFrom = NO_QUEUE,
|
||||
bool ignoreFault = false );
|
||||
|
||||
/**
|
||||
* @brief The sendToDefault method sends a queue message to the default destination.
|
||||
@ -123,7 +124,7 @@ public:
|
||||
* @param sentFrom The sentFrom information can be set to inject the sender's queue id into the message.
|
||||
* This variable is set to zero by default.
|
||||
*/
|
||||
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessage* message,
|
||||
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessageIF* message,
|
||||
MessageQueueId_t sentFrom = NO_QUEUE, bool ignoreFault = false );
|
||||
|
||||
/**
|
||||
@ -133,7 +134,7 @@ public:
|
||||
* @param message A pointer to a message in which the received data is stored.
|
||||
* @param receivedFrom A pointer to a queue id in which the sender's id is stored.
|
||||
*/
|
||||
ReturnValue_t receiveMessage(MessageQueueMessage* message,
|
||||
ReturnValue_t receiveMessage(MessageQueueMessageIF* message,
|
||||
MessageQueueId_t *receivedFrom);
|
||||
|
||||
/**
|
||||
@ -144,7 +145,7 @@ public:
|
||||
* message's content is cleared and the function returns immediately.
|
||||
* @param message A pointer to a message in which the received data is stored.
|
||||
*/
|
||||
ReturnValue_t receiveMessage(MessageQueueMessage* message);
|
||||
ReturnValue_t receiveMessage(MessageQueueMessageIF* message);
|
||||
/**
|
||||
* Deletes all pending messages in the queue.
|
||||
* @param count The number of flushed messages.
|
||||
@ -191,7 +192,7 @@ protected:
|
||||
* @param context Specify whether call is made from task or from an ISR.
|
||||
*/
|
||||
static ReturnValue_t sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage* message, MessageQueueId_t sentFrom = NO_QUEUE,
|
||||
MessageQueueMessageIF* message, MessageQueueId_t sentFrom = NO_QUEUE,
|
||||
bool ignoreFault=false, CallContext callContext = CallContext::TASK);
|
||||
|
||||
static ReturnValue_t handleSendResult(BaseType_t result, bool ignoreFault);
|
||||
|
@ -7,7 +7,7 @@ QueueFactory* QueueFactory::factoryInstance = nullptr;
|
||||
|
||||
|
||||
ReturnValue_t MessageQueueSenderIF::sendMessage(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage* message, MessageQueueId_t sentFrom,
|
||||
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
||||
bool ignoreFault) {
|
||||
return MessageQueue::sendMessageFromMessageQueue(sendTo,message,
|
||||
sentFrom,ignoreFault);
|
||||
|
@ -102,7 +102,8 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id,
|
||||
return result;
|
||||
}
|
||||
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
|
||||
ParameterMessage::setParameterDumpReply(&reply, id, address);
|
||||
|
||||
@ -123,8 +124,10 @@ ReturnValue_t ParameterHelper::initialize() {
|
||||
}
|
||||
}
|
||||
|
||||
void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason, Command_t initialCommand) {
|
||||
CommandMessage reply;
|
||||
void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
|
||||
Command_t initialCommand) {
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
reply.setReplyRejected(reason, initialCommand);
|
||||
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
|
||||
}
|
||||
|
@ -163,7 +163,8 @@ void Fuse::setAllMonitorsToUnchecked() {
|
||||
}
|
||||
|
||||
void Fuse::checkCommandQueue() {
|
||||
CommandMessage command;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
|
@ -74,7 +74,8 @@ void PowerSensor::setAllMonitorsToUnchecked() {
|
||||
}
|
||||
|
||||
void PowerSensor::checkCommandQueue() {
|
||||
CommandMessage command;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
|
@ -309,7 +309,8 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
|
||||
break;
|
||||
case ModeSequenceMessage::READ_FREE_SEQUENCE_SLOTS: {
|
||||
uint32_t freeSlots = modeSequences.maxSize() - modeSequences.size();
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
ModeSequenceMessage::setModeSequenceMessage(&reply,
|
||||
ModeSequenceMessage::FREE_SEQUENCE_SLOTS, freeSlots);
|
||||
commandQueue->reply(&reply);
|
||||
@ -317,7 +318,8 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
|
||||
break;
|
||||
case ModeSequenceMessage::READ_FREE_TABLE_SLOTS: {
|
||||
uint32_t free = modeTables.maxSize() - modeTables.size();
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
ModeSequenceMessage::setModeSequenceMessage(&reply,
|
||||
ModeSequenceMessage::FREE_TABLE_SLOTS, free);
|
||||
commandQueue->reply(&reply);
|
||||
@ -330,11 +332,12 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
|
||||
}
|
||||
|
||||
void Subsystem::replyToCommand(ReturnValue_t status, uint32_t parameter) {
|
||||
MessageQueueMessage message;
|
||||
if (status == RETURN_OK) {
|
||||
CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
||||
CommandMessage reply(&message, CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
||||
commandQueue->reply(&reply);
|
||||
} else {
|
||||
CommandMessage reply(CommandMessage::REPLY_REJECTED, status, 0);
|
||||
CommandMessage reply(&message, CommandMessage::REPLY_REJECTED, status, 0);
|
||||
commandQueue->reply(&reply);
|
||||
}
|
||||
}
|
||||
@ -617,7 +620,8 @@ void Subsystem::sendSerializablesAsCommandMessage(Command_t command,
|
||||
for (uint8_t i = 0; i < count; i++) {
|
||||
elements[i]->serialize(&storeBuffer, &size, maxSize, true);
|
||||
}
|
||||
CommandMessage reply;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
ModeSequenceMessage::setModeSequenceMessage(&reply, command, address);
|
||||
if (commandQueue->reply(&reply) != RETURN_OK) {
|
||||
IPCStore->deleteData(address);
|
||||
|
@ -9,7 +9,7 @@ SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent,
|
||||
false), commandsOutstanding(0), commandQueue(NULL), healthHelper(this,
|
||||
setObjectId), modeHelper(this), parentId(parent) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(commandQueueDepth,
|
||||
CommandMessage::MAX_MESSAGE_SIZE);
|
||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
}
|
||||
|
||||
SubsystemBase::~SubsystemBase() {
|
||||
@ -77,8 +77,8 @@ ReturnValue_t SubsystemBase::checkStateAgainstTable(
|
||||
}
|
||||
|
||||
void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submode_t targetSubmode) {
|
||||
|
||||
CommandMessage message;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
|
||||
std::map<object_id_t, ChildInfo>::iterator iter;
|
||||
|
||||
@ -100,17 +100,17 @@ void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submod
|
||||
|
||||
if (healthHelper.healthTable->hasHealth(object)) {
|
||||
if (healthHelper.healthTable->isFaulty(object)) {
|
||||
ModeMessage::setModeMessage(&message,
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND, HasModesIF::MODE_OFF,
|
||||
SUBMODE_NONE);
|
||||
} else {
|
||||
if (modeHelper.isForced()) {
|
||||
ModeMessage::setModeMessage(&message,
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND_FORCED,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
} else {
|
||||
if (healthHelper.healthTable->isCommandable(object)) {
|
||||
ModeMessage::setModeMessage(&message,
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_COMMAND,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
} else {
|
||||
@ -119,12 +119,12 @@ void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submod
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ModeMessage::setModeMessage(&message, ModeMessage::CMD_MODE_COMMAND,
|
||||
ModeMessage::setModeMessage(&command, ModeMessage::CMD_MODE_COMMAND,
|
||||
tableIter.value->getMode(), submodeToCommand);
|
||||
}
|
||||
|
||||
if ((iter->second.mode == ModeMessage::getMode(&message))
|
||||
&& (iter->second.submode == ModeMessage::getSubmode(&message))
|
||||
if ((iter->second.mode == ModeMessage::getMode(&command))
|
||||
&& (iter->second.submode == ModeMessage::getSubmode(&command))
|
||||
&& !modeHelper.isForced()) {
|
||||
continue; //don't send redundant mode commands (produces event spam), but still command if mode is forced to reach lower levels
|
||||
}
|
||||
@ -297,7 +297,8 @@ void SubsystemBase::setToExternalControl() {
|
||||
void SubsystemBase::announceMode(bool recursive) {
|
||||
triggerEvent(MODE_INFO, mode, submode);
|
||||
if (recursive) {
|
||||
CommandMessage command;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
ModeMessage::setModeMessage(&command,
|
||||
ModeMessage::CMD_MODE_ANNOUNCE_RECURSIVELY, 0, 0);
|
||||
commandAllChildren(&command);
|
||||
@ -306,31 +307,33 @@ void SubsystemBase::announceMode(bool recursive) {
|
||||
|
||||
void SubsystemBase::checkCommandQueue() {
|
||||
ReturnValue_t result;
|
||||
CommandMessage message;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
|
||||
for (result = commandQueue->receiveMessage(&message); result == RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&message)) {
|
||||
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
|
||||
result = commandQueue->receiveMessage(&command)) {
|
||||
|
||||
result = healthHelper.handleHealthCommand(&message);
|
||||
result = healthHelper.handleHealthCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = modeHelper.handleModeCommand(&message);
|
||||
result = modeHelper.handleModeCommand(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = handleModeReply(&message);
|
||||
result = handleModeReply(&command);
|
||||
if (result == RETURN_OK) {
|
||||
continue;
|
||||
}
|
||||
|
||||
result = handleCommandMessage(&message);
|
||||
result = handleCommandMessage(&command);
|
||||
if (result != RETURN_OK) {
|
||||
CommandMessage reply;
|
||||
reply.setReplyRejected(CommandMessage::UNKNOW_COMMAND,
|
||||
message.getCommand());
|
||||
MessageQueueMessage message;
|
||||
CommandMessage reply(&message);
|
||||
reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND,
|
||||
command.getCommand());
|
||||
replyToCommand(&reply);
|
||||
}
|
||||
}
|
||||
|
@ -44,18 +44,19 @@ ReturnValue_t AbstractTemperatureSensor::performHealthOp() {
|
||||
}
|
||||
|
||||
void AbstractTemperatureSensor::handleCommandQueue() {
|
||||
CommandMessage message;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&message);
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
result = healthHelper.handleHealthCommand(&message);
|
||||
result = healthHelper.handleHealthCommand(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
result = parameterHelper.handleParameterMessage(&message);
|
||||
result = parameterHelper.handleParameterMessage(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
message.setToUnknownCommand();
|
||||
command.setToUnknownCommand();
|
||||
commandQueue->reply(&message);
|
||||
}
|
||||
}
|
||||
|
@ -279,14 +279,15 @@ ReturnValue_t Heater::initialize() {
|
||||
}
|
||||
|
||||
void Heater::handleQueue() {
|
||||
CommandMessage message;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&message);
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
result = healthHelper.handleHealthCommand(&message);
|
||||
result = healthHelper.handleHealthCommand(&command);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
parameterHelper.handleParameterMessage(&message);
|
||||
parameterHelper.handleParameterMessage(&command);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ void TmStoreMessage::clear(CommandMessage* cmd) {
|
||||
case DELETE_STORE_CONTENT_BLOCKS:
|
||||
case DOWNLINK_STORE_CONTENT_BLOCKS:
|
||||
case REPORT_INDEX_REQUEST:
|
||||
cmd->setCommand(UNKNOW_COMMAND);
|
||||
cmd->setCommand(CommandMessage::UNKNOWN_COMMAND);
|
||||
cmd->setParameter(0);
|
||||
cmd->setParameter2(0);
|
||||
break;
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include <framework/tmstorage/TmStorePackets.h>
|
||||
#include <framework/objectmanager/SystemObjectIF.h>
|
||||
class TmStoreMessage: public CommandMessage {
|
||||
class TmStoreMessage {
|
||||
public:
|
||||
static ReturnValue_t setEnableStoringMessage(CommandMessage* cmd,
|
||||
bool setEnabled);
|
||||
|
@ -77,7 +77,10 @@ ReturnValue_t CommandingServiceBase::initialize() {
|
||||
}
|
||||
|
||||
void CommandingServiceBase::handleCommandQueue() {
|
||||
CommandMessage reply, nextCommand;
|
||||
MessageQueueMessage replyMessage;
|
||||
CommandMessage reply(&replyMessage);
|
||||
MessageQueueMessage nextCommandMessage;
|
||||
CommandMessage nextCommand(&nextCommandMessage);
|
||||
ReturnValue_t result, sendResult = RETURN_OK;
|
||||
bool isStep = false;
|
||||
for (result = commandQueue->receiveMessage(&reply); result == RETURN_OK;
|
||||
@ -268,16 +271,17 @@ void CommandingServiceBase::startExecution(
|
||||
typename FixedMap<MessageQueueId_t,
|
||||
CommandingServiceBase::CommandInfo>::Iterator *iter) {
|
||||
ReturnValue_t result, sendResult = RETURN_OK;
|
||||
CommandMessage message;
|
||||
MessageQueueMessage message;
|
||||
CommandMessage command(&message);
|
||||
(*iter)->subservice = storedPacket->getSubService();
|
||||
result = prepareCommand(&message, (*iter)->subservice,
|
||||
result = prepareCommand(&command, (*iter)->subservice,
|
||||
storedPacket->getApplicationData(),
|
||||
storedPacket->getApplicationDataSize(), &(*iter)->state,
|
||||
(*iter)->objectId);
|
||||
|
||||
switch (result) {
|
||||
case RETURN_OK:
|
||||
if (message.getCommand() != CommandMessage::CMD_NONE) {
|
||||
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
||||
sendResult = commandQueue->sendMessage((*iter).value->first,
|
||||
&message);
|
||||
}
|
||||
@ -286,20 +290,20 @@ void CommandingServiceBase::startExecution(
|
||||
(*iter)->step = 0;
|
||||
// (*iter)->state = 0;
|
||||
(*iter)->subservice = storedPacket->getSubService();
|
||||
(*iter)->command = message.getCommand();
|
||||
(*iter)->command = command.getCommand();
|
||||
(*iter)->tcInfo.ackFlags = storedPacket->getAcknowledgeFlags();
|
||||
(*iter)->tcInfo.tcPacketId = storedPacket->getPacketId();
|
||||
(*iter)->tcInfo.tcSequenceControl =
|
||||
storedPacket->getPacketSequenceControl();
|
||||
acceptPacket(TC_VERIFY::START_SUCCESS, storedPacket);
|
||||
} else {
|
||||
message.clearCommandMessage();
|
||||
command.clearCommandMessage();
|
||||
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
break;
|
||||
case EXECUTION_COMPLETE:
|
||||
if (message.getCommand() != CommandMessage::CMD_NONE) {
|
||||
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
||||
//Fire-and-forget command.
|
||||
sendResult = commandQueue->sendMessage((*iter).value->first,
|
||||
&message);
|
||||
@ -310,7 +314,7 @@ void CommandingServiceBase::startExecution(
|
||||
acceptPacket(TC_VERIFY::COMPLETION_SUCCESS, storedPacket);
|
||||
checkAndExecuteFifo(iter);
|
||||
} else {
|
||||
message.clearCommandMessage();
|
||||
command.clearCommandMessage();
|
||||
rejectPacket(TC_VERIFY::START_FAILURE, storedPacket, sendResult);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user