removed CommandMessageBase, changed interfaces

This commit is contained in:
Robin Müller 2020-06-24 00:24:15 +02:00
parent 905c1a92e3
commit 3bf29a7315
34 changed files with 348 additions and 382 deletions

View File

@ -33,15 +33,13 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
}
void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
ActionMessage::setStepReply(&reply, commandId, step + STEP_OFFSET, result);
queueToUse->sendMessage(reportTo, &reply);
}
void ActionHelper::finish(MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
ActionMessage::setCompletionReply(&reply, commandId, result);
queueToUse->sendMessage(reportTo, &reply);
}
@ -56,8 +54,7 @@ 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) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
ActionMessage::setStepReply(&reply, actionId, 0, result);
queueToUse->sendMessage(commandedBy, &reply);
return;
@ -65,8 +62,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
result = owner->executeAction(actionId, commandedBy, dataPtr, size);
ipcStore->deleteData(dataAddress);
if (result != HasReturnvaluesIF::RETURN_OK) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
ActionMessage::setStepReply(&reply, actionId, 0, result);
queueToUse->sendMessage(commandedBy, &reply);
return;
@ -75,8 +71,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
ActionId_t replyId, SerializeIF* data, bool hideSender) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
store_address_t storeAddress;
uint8_t *dataPtr;
size_t maxSize = data->getSerializedSize();

View File

@ -53,8 +53,7 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo,
ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId,
ActionId_t actionId, store_address_t storeId) {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
ActionMessage::setCommand(&command, actionId, storeId);
ReturnValue_t result = queueToUse->sendMessage(queueId, &command);
if (result != HasReturnvaluesIF::RETURN_OK) {

View File

@ -36,8 +36,7 @@ void SimpleActionHelper::resetHelper() {
void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy,
ActionId_t actionId, store_address_t dataAddress) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
if (isExecuting) {
ipcStore->deleteData(dataAddress);
ActionMessage::setStepReply(&reply, actionId, 0,

View File

@ -56,8 +56,7 @@ MessageQueueId_t ControllerBase::getCommandQueue() const {
}
void ControllerBase::handleQueue() {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
ReturnValue_t result;
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
result = commandQueue->receiveMessage(&command)) {

View File

@ -21,8 +21,7 @@ ReturnValue_t HkSwitchHelper::initialize() {
}
ReturnValue_t HkSwitchHelper::performOperation(uint8_t operationCode) {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
while (actionQueue->receiveMessage(&command) == HasReturnvaluesIF::RETURN_OK) {
ReturnValue_t result = commandActionHelper.handleReply(&command);
if (result == HasReturnvaluesIF::RETURN_OK) {

View File

@ -66,8 +66,7 @@ ReturnValue_t DataPoolAdmin::getParameter(uint8_t domainId,
}
void DataPoolAdmin::handleCommand() {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result != RETURN_OK) {
return;
@ -283,8 +282,7 @@ ReturnValue_t DataPoolAdmin::sendParameter(MessageQueueId_t to, uint32_t id,
return result;
}
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
ParameterMessage::setParameterDumpReply(&reply, id, address);
@ -296,8 +294,7 @@ 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) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
reply.setReplyRejected(reason, initialCommand);
commandQueue->sendMessage(to, &reply);
}

View File

@ -45,8 +45,8 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
}
ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
HousekeepingMessage& message) {
Command_t command = message.getCommand();
CommandMessage* message) {
Command_t command = message->getCommand();
switch(command) {
// I think those are the only commands which can be handled here..
case(HousekeepingMessage::ADD_HK_REPORT_STRUCT):
@ -55,10 +55,10 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
return HasReturnvaluesIF::RETURN_OK;
case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES):
case(HousekeepingMessage::REPORT_HK_REPORT_STRUCTURES):
return generateSetStructurePacket(message.getSid());
//return generateSetStructurePacket(message->getSid());
case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT):
case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT):
return generateHousekeepingPacket(message.getSid());
//return generateHousekeepingPacket(message->getSid());
default:
return CommandMessageIF::UNKNOWN_COMMAND;
}
@ -105,19 +105,18 @@ ReturnValue_t LocalDataPoolManager::generateHousekeepingPacket(sid_t sid) {
}
// and now we set a HK message and send it the HK packet destination.
MessageQueueMessage message;
HousekeepingMessage hkMessage(&message);
hkMessage.setHkReportMessage(sid, storeId);
if(hkQueue == nullptr) {
return QUEUE_NOT_SET;
}
if(currentHkPacketDestination != MessageQueueIF::NO_QUEUE) {
result = hkQueue->sendMessage(currentHkPacketDestination, &hkMessage);
}
else {
result = hkQueue->sendToDefault(&hkMessage);
}
//HousekeepingMessage hkMessage;
// hkMessage.setHkReportMessage(sid, storeId);
// if(hkQueue == nullptr) {
// return QUEUE_NOT_SET;
// }
//
// if(currentHkPacketDestination != MessageQueueIF::NO_QUEUE) {
// result = hkQueue->sendMessage(currentHkPacketDestination, &hkMessage);
// }
// else {
// result = hkQueue->sendToDefault(&hkMessage);
// }
return result;
}

View File

@ -58,7 +58,7 @@ public:
ReturnValue_t generateHousekeepingPacket(sid_t sid);
ReturnValue_t generateSetStructurePacket(sid_t sid);
ReturnValue_t handleHousekeepingMessage(HousekeepingMessage& message);
ReturnValue_t handleHousekeepingMessage(CommandMessage* message);
/**
* This function is used to fill the local data pool map with pool

View File

@ -148,8 +148,7 @@ void AssemblyBase::handleModeTransitionFailed(ReturnValue_t result) {
void AssemblyBase::sendHealthCommand(MessageQueueId_t sendTo,
HealthState health) {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
HealthMessage::setHealthMessage(&command, HealthMessage::HEALTH_SET,
health);
if (commandQueue->sendMessage(sendTo, &command) == RETURN_OK) {

View File

@ -214,12 +214,7 @@ void DeviceHandlerBase::readCommandQueue() {
return;
}
// This is not ideal. What if it is not a command message? (e.g. another
// 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.
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result != RETURN_OK) {
return;
@ -247,8 +242,7 @@ void DeviceHandlerBase::readCommandQueue() {
return;
}
HousekeepingMessage hkMessage(&message);
result = hkManager.handleHousekeepingMessage(hkMessage);
result = hkManager.handleHousekeepingMessage(&command);
if (result == RETURN_OK) {
return;
}
@ -484,13 +478,12 @@ 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(&message, CommandMessage::REPLY_COMMAND_OK, 0, parameter);
CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, parameter);
commandQueue->reply(&reply);
} else {
CommandMessage reply(&message, CommandMessage::REPLY_REJECTED, status, parameter);
CommandMessage reply(CommandMessage::REPLY_REJECTED, status, parameter);
commandQueue->reply(&reply);
}
}
@ -760,8 +753,7 @@ void DeviceHandlerBase::replyRawData(const uint8_t *data, size_t len,
return;
}
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
DeviceHandlerMessage::setDeviceHandlerRawReplyMessage(&command,
getObjectId(), address, isCommand);

View File

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

View File

@ -65,8 +65,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health,
if (parentQueue == MessageQueueMessageIF::NO_QUEUE) {
return;
}
MessageQueueMessage message;
CommandMessage information(&message);
CommandMessage information;
HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO,
health, oldHealth);
if (MessageQueueSenderIF::sendMessage(parentQueue, &information,
@ -81,8 +80,7 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) {
if (command->getSender() == MessageQueueMessageIF::NO_QUEUE) {
return;
}
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
if (result == HasReturnvaluesIF::RETURN_OK) {
HealthMessage::setHealthMessage(&reply,
HealthMessage::REPLY_HEALTH_SET);

View File

@ -1,15 +1,7 @@
#include <framework/housekeeping/HousekeepingMessage.h>
#include <cstring>
HousekeepingMessage::HousekeepingMessage(MessageQueueMessageIF* message):
CommandMessageBase(message) {
if(message->getMessageSize() < HK_MESSAGE_SIZE) {
sif::error << "HousekeepingMessage::HousekeepingMessage: Passed "
"message buffer can not hold minimum " << HK_MESSAGE_SIZE
<< " bytes!" << std::endl;
return;
}
//message->setMessageSize(HK_MESSAGE_SIZE);
HousekeepingMessage::HousekeepingMessage(): CommandMessage() {
}
HousekeepingMessage::~HousekeepingMessage() {}
@ -26,14 +18,14 @@ uint32_t HousekeepingMessage::getParameter() const {
void HousekeepingMessage::setHkReportMessage(sid_t sid,
store_address_t storeId) {
CommandMessageBase::setCommand(HK_REPORT);
CommandMessage::setCommand(HK_REPORT);
setSid(sid);
setParameter(storeId.raw);
}
void HousekeepingMessage::setHkDiagnosticsMessage(sid_t sid,
store_address_t storeId) {
CommandMessageBase::setCommand(DIAGNOSTICS_REPORT);
CommandMessage::setCommand(DIAGNOSTICS_REPORT);
setSid(sid);
setParameter(storeId.raw);
}
@ -44,7 +36,7 @@ void HousekeepingMessage::setHkDiagnosticsMessage(sid_t sid,
sid_t HousekeepingMessage::getSid() const {
sid_t sid;
std::memcpy(&sid.raw, CommandMessageBase::getData(), sizeof(sid.raw));
std::memcpy(&sid.raw, CommandMessage::getData(), sizeof(sid.raw));
return sid;
}
@ -58,16 +50,16 @@ sid_t HousekeepingMessage::getHkReportMessage(
}
void HousekeepingMessage::setSid(sid_t sid) {
std::memcpy(CommandMessageBase::getData(), &sid.raw, sizeof(sid.raw));
std::memcpy(CommandMessage::getData(), &sid.raw, sizeof(sid.raw));
}
uint8_t* HousekeepingMessage::getData() {
return CommandMessageBase::getData() + sizeof(sid_t);
return CommandMessage::getData() + sizeof(sid_t);
}
const uint8_t* HousekeepingMessage::getData() const {
return CommandMessageBase::getData() + sizeof(sid_t);
return CommandMessage::getData() + sizeof(sid_t);
}
void HousekeepingMessage::clear() {

View File

@ -1,6 +1,7 @@
#ifndef FRAMEWORK_HK_HOUSEKEEPINGMESSAGE_H_
#define FRAMEWORK_HK_HOUSEKEEPINGMESSAGE_H_
#include <framework/ipc/CommandMessageBase.h>
#include <framework/ipc/CommandMessage.h>
#include <framework/ipc/FwMessageTypes.h>
#include <framework/objectmanager/SystemObjectIF.h>
#include <framework/storagemanager/StorageManagerIF.h>
@ -33,7 +34,7 @@ union sid_t {
* This message is slightly larger than regular command messages to accomodate
* the uint64_t structure ID (SID).
*/
class HousekeepingMessage : public CommandMessageBase {
class HousekeepingMessage : public CommandMessage {
public:
static constexpr size_t HK_MESSAGE_SIZE = CommandMessageIF::HEADER_SIZE +
@ -44,7 +45,7 @@ public:
* the message data, see CommandMessageIF and getInternalMessage().
* @param message
*/
HousekeepingMessage(MessageQueueMessageIF* message);
HousekeepingMessage();
virtual ~HousekeepingMessage();
static constexpr uint8_t MESSAGE_ID = messagetypes::HOUSEKEEPING;

View File

@ -1,57 +1,64 @@
#include <framework/ipc/CommandMessage.h>
#include <framework/ipc/CommandMessageCleaner.h>
#include <cstring>
CommandMessage::CommandMessage(MessageQueueMessageIF* receiverMessage):
CommandMessageBase(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;
return;
}
// if(receiverMessage->getMessageSize() <
// getMinimumMessageSize()) {
// sif::error << "CommandMessage::ComandMessage: Passed message buffer"
// " can not hold minimum "<< getMinimumMessageSize()
// << " bytes!" << std::endl;
// return;
// }
// internalMessage->setMessageSize(getMinimumMessageSize());
CommandMessage::CommandMessage() {
MessageQueueMessage::setMessageSize(DEFAULT_COMMAND_MESSAGE_SIZE);
setCommand(CMD_NONE);
}
CommandMessage::CommandMessage(MessageQueueMessageIF* messageToSet,
Command_t command, uint32_t parameter1, uint32_t parameter2):
CommandMessage(messageToSet) {
CommandMessage::CommandMessage(Command_t command, uint32_t parameter1,
uint32_t parameter2) {
MessageQueueMessage::setMessageSize(DEFAULT_COMMAND_MESSAGE_SIZE);
setCommand(command);
setParameter(parameter1);
setParameter2(parameter2);
}
Command_t CommandMessage::getCommand() const {
Command_t command;
std::memcpy(&command, getData(), sizeof(Command_t));
return command;
}
void CommandMessage::setCommand(Command_t command) {
std::memcpy(getData(), &command, sizeof(Command_t));
}
uint8_t CommandMessage::getMessageType() const {
// first byte of command ID.
return getCommand() >> 8 & 0xff;
}
uint32_t CommandMessage::getParameter() const {
uint32_t parameter1;
std::memcpy(&parameter1, CommandMessageBase::getData(), sizeof(parameter1));
std::memcpy(&parameter1, MessageQueueMessage::getData(), sizeof(parameter1));
return parameter1;
}
void CommandMessage::setParameter(uint32_t parameter1) {
std::memcpy(CommandMessageBase::getData(), &parameter1, sizeof(parameter1));
std::memcpy(MessageQueueMessage::getData(), &parameter1, sizeof(parameter1));
}
uint32_t CommandMessage::getParameter2() const {
uint32_t parameter2;
std::memcpy(&parameter2, CommandMessageBase::getData() + sizeof(uint32_t),
std::memcpy(&parameter2, MessageQueueMessage::getData() + sizeof(uint32_t),
sizeof(parameter2));
return parameter2;
}
void CommandMessage::setParameter2(uint32_t parameter2) {
std::memcpy(CommandMessageBase::getData() + sizeof(uint32_t), &parameter2,
std::memcpy(MessageQueueMessage::getData() + sizeof(uint32_t), &parameter2,
sizeof(parameter2));
}
//size_t CommandMessage::getMinimumMessageSize() const {
// return MINIMUM_COMMAND_MESSAGE_SIZE;
//}
size_t CommandMessage::getMinimumMessageSize() const {
return MINIMUM_COMMAND_MESSAGE_SIZE;
}
void CommandMessage::clear() {
CommandMessageCleaner::clearCommandMessage(this);
}
bool CommandMessage::isClearedCommandMessage() {
return getCommand() == CMD_NONE;
@ -62,3 +69,21 @@ void CommandMessage::setToUnknownCommand() {
this->clear();
setReplyRejected(UNKNOWN_COMMAND, initialCommand);
}
void CommandMessage::setReplyRejected(ReturnValue_t reason,
Command_t initialCommand) {
std::memcpy(getData(), &reason, sizeof(reason));
std::memcpy(getData() + sizeof(reason), &initialCommand,
sizeof(initialCommand));
}
ReturnValue_t CommandMessage::getReplyRejectedReason(
Command_t *initialCommand) const {
ReturnValue_t reason = HasReturnvaluesIF::RETURN_FAILED;
std::memcpy(&reason, getData(), sizeof(reason));
if(initialCommand != nullptr) {
std::memcpy(initialCommand, getData() + sizeof(reason),
sizeof(Command_t));
}
return reason;
}

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_IPC_COMMANDMESSAGE_H_
#define FRAMEWORK_IPC_COMMANDMESSAGE_H_
#include <framework/ipc/CommandMessageBase.h>
#include <framework/ipc/CommandMessageIF.h>
#include <framework/ipc/MessageQueueMessage.h>
#include <framework/ipc/FwMessageTypes.h>
@ -20,23 +20,21 @@
* currently has an internal message size of 28 bytes.
* @author Bastian Baetz
*/
class CommandMessage: public CommandMessageBase {
class CommandMessage: public MessageQueueMessage, public CommandMessageIF {
public:
/**
* This is the size of a message as it is seen by the MessageQueue.
* It can hold the CommandMessage header plus 2 4-byte parameters.
* 14 of the 24 available MessageQueueMessage bytes are used.
*/
static const size_t MINIMUM_COMMAND_MESSAGE_SIZE =
CommandMessageIF::HEADER_SIZE + 2 * sizeof(uint32_t);
/**
* Default size can accomodate 2 4-byte parameters.
*/
static constexpr size_t DEFAULT_COMMAND_MESSAGE_SIZE =
CommandMessageIF::MINIMUM_COMMAND_MESSAGE_SIZE + sizeof(uint32_t);
/**
* Default Constructor, does not initialize anything.
*
* @brief Default Constructor, does not initialize anything.
* @details
* This constructor should be used when receiving a Message, as the
* content is filled by the MessageQueue.
*/
CommandMessage(MessageQueueMessageIF* receiverMessage);
CommandMessage();
/**
* This constructor creates a new message with all message content
* initialized
@ -45,17 +43,13 @@ public:
* @param parameter1 The first parameter
* @param parameter2 The second parameter
*/
CommandMessage(MessageQueueMessageIF* messageToSet, Command_t command,
uint32_t parameter1, uint32_t parameter2);
CommandMessage(Command_t command, uint32_t parameter1, uint32_t parameter2);
/**
* @brief Default Destructor
*/
virtual ~CommandMessage() {}
/** MessageQueueMessageIF functions used for minimum size check. */
//size_t getMinimumMessageSize() const override;
/**
* Get the first parameter of the message
* @return the first Parameter of the message
@ -91,8 +85,49 @@ public:
* Sets the command to REPLY_REJECTED with parameter UNKNOWN_COMMAND.
* Is needed quite often, so we better code it once only.
*/
void setToUnknownCommand();
void setToUnknownCommand() override;
/**
* A command message can be rejected and needs to offer a function
* to set a rejected reply
* @param reason
* @param initialCommand
*/
void setReplyRejected(ReturnValue_t reason,
Command_t initialCommand) override;
/**
* Corrensonding getter function.
* @param initialCommand
* @return
*/
ReturnValue_t getReplyRejectedReason(
Command_t* initialCommand = nullptr) const override;
virtual void clear() override;
/**
* Read the DeviceHandlerCommand_t that is stored in the message,
* usually used after receiving.
*
* @return the Command stored in the Message
*/
virtual Command_t getCommand() const override;
/**
* Set the command type of the message. Default implementation also
* sets the message type, which will be the first byte of the command ID.
* @param the Command to be sent
*/
virtual void setCommand(Command_t command);
/**
* Extract message ID, which is the first byte of the command ID for the
* default implementation.
* @return
*/
virtual uint8_t getMessageType() const override;
/** MessageQueueMessageIF functions used for minimum size check. */
size_t getMinimumMessageSize() const override;
};
#endif /* COMMANDMESSAGE_H_ */

View File

@ -1,86 +1,86 @@
#include <framework/ipc/CommandMessageBase.h>
#include <framework/ipc/CommandMessageCleaner.h>
#include <cstring>
CommandMessageBase::CommandMessageBase(MessageQueueMessageIF *message):
internalMessage(message) {
}
Command_t CommandMessageBase::getCommand() const {
Command_t command;
std::memcpy(&command, internalMessage->getData(), sizeof(Command_t));
return command;
}
void CommandMessageBase::setCommand(Command_t command) {
std::memcpy(internalMessage->getData(), &command, sizeof(Command_t));
}
uint8_t CommandMessageBase::getMessageType() const {
// first byte of command ID.
return getCommand() >> 8 & 0xff;
}
MessageQueueId_t CommandMessageBase::getSender() const {
return internalMessage->getSender();
}
uint8_t* CommandMessageBase::getBuffer() {
return internalMessage->getBuffer();
}
void CommandMessageBase::setSender(MessageQueueId_t setId) {
internalMessage->setSender(setId);
}
const uint8_t* CommandMessageBase::getBuffer() const {
return internalMessage->getBuffer();
}
// Header includes command ID.
uint8_t* CommandMessageBase::getData() {
return internalMessage->getData() + sizeof(Command_t);
}
// Header includes command ID.
const uint8_t* CommandMessageBase::getData() const {
return internalMessage->getData() + sizeof(Command_t);
}
//void CommandMessageBase::setMessageSize(size_t messageSize) {
// //internalMessage->setMessageSize(messageSize);
//#include <framework/ipc/CommandMessageBase.h>
//#include <framework/ipc/CommandMessageCleaner.h>
//#include <cstring>
//
//CommandMessageBase::CommandMessageBase(MessageQueueMessageIF *message):
// internalMessage(message) {
//}
size_t CommandMessageBase::getMessageSize() const {
return internalMessage->getMessageSize();
}
MessageQueueMessageIF* CommandMessageBase::getInternalMessage() const {
return internalMessage;
}
//size_t CommandMessageBase::getMinimumMessageSize() const {
// return MINIMUM_COMMAND_MESSAGE_BASE_SIZE;
//
//Command_t CommandMessageBase::getCommand() const {
// Command_t command;
// std::memcpy(&command, internalMessage->getData(), sizeof(Command_t));
// return command;
//}
//
//void CommandMessageBase::setCommand(Command_t command) {
// std::memcpy(internalMessage->getData(), &command, sizeof(Command_t));
//}
//
//uint8_t CommandMessageBase::getMessageType() const {
// // first byte of command ID.
// return getCommand() >> 8 & 0xff;
//}
//
//MessageQueueId_t CommandMessageBase::getSender() const {
// return internalMessage->getSender();
//}
//
//uint8_t* CommandMessageBase::getBuffer() {
// return internalMessage->getBuffer();
//}
//
//void CommandMessageBase::setSender(MessageQueueId_t setId) {
// internalMessage->setSender(setId);
//}
//
//const uint8_t* CommandMessageBase::getBuffer() const {
// return internalMessage->getBuffer();
//}
//
//// Header includes command ID.
//uint8_t* CommandMessageBase::getData() {
// return internalMessage->getData() + sizeof(Command_t);
//}
//
//// Header includes command ID.
//const uint8_t* CommandMessageBase::getData() const {
// return internalMessage->getData() + sizeof(Command_t);
//}
//
////void CommandMessageBase::setMessageSize(size_t messageSize) {
//// //internalMessage->setMessageSize(messageSize);
////}
//
//size_t CommandMessageBase::getMessageSize() const {
// return internalMessage->getMessageSize();
//}
//
//MessageQueueMessageIF* CommandMessageBase::getInternalMessage() const {
// return internalMessage;
//}
//
////size_t CommandMessageBase::getMinimumMessageSize() const {
//// return MINIMUM_COMMAND_MESSAGE_BASE_SIZE;
////}
//
//void CommandMessageBase::setReplyRejected(ReturnValue_t reason,
// Command_t initialCommand) {
// std::memcpy(getData(), &reason, sizeof(reason));
// std::memcpy(getData() + sizeof(reason), &initialCommand,
// sizeof(initialCommand));
//}
//
//ReturnValue_t CommandMessageBase::getReplyRejectedReason(
// Command_t *initialCommand) const {
// ReturnValue_t reason = HasReturnvaluesIF::RETURN_FAILED;
// std::memcpy(&reason, getData(), sizeof(reason));
// if(initialCommand != nullptr) {
// std::memcpy(initialCommand, getData() + sizeof(reason),
// sizeof(Command_t));
// }
// return reason;
//}
//
//void CommandMessageBase::clear() {
// CommandMessageCleaner::clearCommandMessage(this);
//}
void CommandMessageBase::setReplyRejected(ReturnValue_t reason,
Command_t initialCommand) {
std::memcpy(getData(), &reason, sizeof(reason));
std::memcpy(getData() + sizeof(reason), &initialCommand,
sizeof(initialCommand));
}
ReturnValue_t CommandMessageBase::getReplyRejectedReason(
Command_t *initialCommand) const {
ReturnValue_t reason = HasReturnvaluesIF::RETURN_FAILED;
std::memcpy(&reason, getData(), sizeof(reason));
if(initialCommand != nullptr) {
std::memcpy(initialCommand, getData() + sizeof(reason),
sizeof(Command_t));
}
return reason;
}
void CommandMessageBase::clear() {
CommandMessageCleaner::clearCommandMessage(this);
}

View File

@ -23,67 +23,28 @@
*/
class CommandMessageBase: public CommandMessageIF {
public:
//! This minimum size is derived from the interface requirement to be able
//! to set a rejected reply, which contains a returnvalue and the initial
//! command.
static constexpr size_t MINIMUM_COMMAND_MESSAGE_BASE_SIZE =
CommandMessageIF::HEADER_SIZE + sizeof(ReturnValue_t) +
sizeof(Command_t);
CommandMessageBase(MessageQueueMessageIF* message);
/**
* Read the DeviceHandlerCommand_t that is stored in the message,
* usually used after receiving.
*
* @return the Command stored in the Message
*/
virtual Command_t getCommand() const override;
/**
* Set the command type of the message. Default implementation also
* sets the message type, which will be the first byte of the command ID.
* @param the Command to be sent
*/
virtual void setCommand(Command_t command);
/**
* Extract message ID, which is the first byte of the command ID for the
* default implementation.
* @return
*/
virtual uint8_t getMessageType() const override;
/*
* MessageQueueMessageIF functions, which generally just call the
* respective functions of the internal message queue message.
*/
virtual uint8_t * getBuffer() override;
virtual const uint8_t * getBuffer() const override;
virtual void setSender(MessageQueueId_t setId) override;
virtual MessageQueueId_t getSender() const override;
virtual uint8_t * getData() override;
virtual const uint8_t* getData() const override;
virtual size_t getMessageSize() const override;
// /*
// * MessageQueueMessageIF functions, which generally just call the
// * respective functions of the internal message queue message.
// */
// virtual uint8_t * getBuffer() override;
// virtual const uint8_t * getBuffer() const override;
// virtual void setSender(MessageQueueId_t setId) override;
// virtual MessageQueueId_t getSender() const override;
// virtual uint8_t * getData() override;
// virtual const uint8_t* getData() const override;
// virtual size_t getMessageSize() const override;
/**
* A command message can be rejected and needs to offer a function
* to set a rejected reply
* @param reason
* @param initialCommand
*/
void setReplyRejected(ReturnValue_t reason,
Command_t initialCommand) override;
/**
* Corrensonding getter function.
* @param initialCommand
* @return
*/
ReturnValue_t getReplyRejectedReason(
Command_t* initialCommand = nullptr) const override;
virtual MessageQueueMessageIF* getInternalMessage() const override;
//virtual MessageQueueMessageIF* getInternalMessage() const override;
virtual void clear() override;
protected:
/**
* @brief Pointer to the message containing the data.

View File

@ -5,20 +5,24 @@
#include <framework/ipc/FwMessageTypes.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
#define MAKE_COMMAND_ID( number ) ((MESSAGE_ID << 8) + (number))
typedef uint16_t Command_t;
// TODO: actually, this interface propably does not have to implement
// MQM IF, because there is a getter function for the internal message..
// But it is also convenient to have the full access to all MQM IF functions.
// That way, I can just pass CommandMessages to functions expecting a MQM IF.
// The command message implementations just forwards the calls. Maybe
// we should just leave it like that.
class CommandMessageIF: public MessageQueueMessageIF {
class CommandMessageIF: virtual public MessageQueueMessageIF {
public:
static constexpr size_t HEADER_SIZE = sizeof(MessageQueueId_t) +
/**
* Header consists of sender ID and command ID.
*/
static constexpr size_t HEADER_SIZE = MessageQueueMessageIF::HEADER_SIZE +
sizeof(Command_t);
/**
* This minimum size is derived from the interface requirement to be able
* to set a rejected reply, which contains a returnvalue and the initial
* command.
*/
static constexpr size_t MINIMUM_COMMAND_MESSAGE_SIZE =
CommandMessageIF::HEADER_SIZE + sizeof(ReturnValue_t) +
sizeof(Command_t);
static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_MESSAGE;
static const ReturnValue_t UNKNOWN_COMMAND = MAKE_RETURN_CODE(0x01);
@ -60,15 +64,9 @@ public:
virtual ReturnValue_t getReplyRejectedReason(
Command_t* initialCommand = nullptr) const = 0;
/**
* This function is used to get a pointer to the internal message, as
* the command message implementations always operate on the memory
* contained in the message queue message implementation.
* This pointer can be used to set the internal message of different
* command message implementations.
* @return
*/
virtual MessageQueueMessageIF* getInternalMessage() const = 0;
virtual void setToUnknownCommand() = 0;
virtual void clear() = 0;
};

View File

@ -1,10 +1,10 @@
#include <framework/ipc/MessageQueueMessage.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <string.h>
#include <framework/globalfunctions/arrayprinter.h>
#include <cstring>
MessageQueueMessage::MessageQueueMessage() :
messageSize(this->HEADER_SIZE) {
messageSize(getMinimumMessageSize()) {
memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
}
@ -51,17 +51,15 @@ void MessageQueueMessage::setSender(MessageQueueId_t setId) {
memcpy(this->internalBuffer, &setId, sizeof(MessageQueueId_t));
}
//size_t MessageQueueMessage::getMinimumMessageSize() const {
// return this->HEADER_SIZE;
//}
void MessageQueueMessage::print() {
sif::debug << "MessageQueueMessage has size: " << this->messageSize <<
std::hex << std::endl;
for (uint8_t count = 0; count < this->messageSize; count++) {
sif::debug << (uint32_t) this->internalBuffer[count] << ":";
void MessageQueueMessage::print(bool printWholeMessage) {
sif::debug << "MessageQueueMessage content: " << std::endl;
if(printWholeMessage) {
arrayprinter::print(getData(), getMaximumMessageSize());
}
sif::debug << std::dec << std::endl;
else {
arrayprinter::print(getData(), getMessageSize());
}
}
void MessageQueueMessage::clear() {
@ -69,9 +67,18 @@ void MessageQueueMessage::clear() {
}
size_t MessageQueueMessage::getMessageSize() const {
return this->MAX_MESSAGE_SIZE;
return this->messageSize;
}
void MessageQueueMessage::setMessageSize(size_t messageSize) {
this->messageSize = messageSize;
}
size_t MessageQueueMessage::getMinimumMessageSize() const {
return this->MIN_MESSAGE_SIZE;
}
size_t MessageQueueMessage::getMaximumMessageSize() const {
return this->MAX_MESSAGE_SIZE;
}
//void MessageQueueMessage::setMessageSize(size_t messageSize) {
// this->messageSize = messageSize;
//}

View File

@ -23,7 +23,7 @@
* receive messages from other tasks.
* @ingroup message_queue
*/
class MessageQueueMessage: public MessageQueueMessageIF {
class MessageQueueMessage: virtual public MessageQueueMessageIF {
public:
/**
* @brief The class is initialized empty with this constructor.
@ -74,11 +74,7 @@ public:
* as small as possible.
*/
static const size_t MAX_DATA_SIZE = 24;
/**
* @brief This constants defines the size of the header,
* which is added to every message.
*/
static const size_t HEADER_SIZE = sizeof(MessageQueueId_t);
/**
* @brief This constant defines the maximum total size in bytes
* of a sent message.
@ -141,12 +137,14 @@ public:
void setSender(MessageQueueId_t setId) override;
virtual size_t getMessageSize() const override;
virtual void setMessageSize(size_t messageSize) override;
virtual size_t getMinimumMessageSize() const override;
virtual size_t getMaximumMessageSize() const override;
/**
* @brief This is a debug method that prints the content
* (till messageSize) to the debug output.
* @brief This is a debug method that prints the content.
*/
void print();
void print(bool printWholeMessage);
};
#endif /* MESSAGEQUEUEMESSAGE_H_ */

View File

@ -18,7 +18,12 @@ typedef uint32_t MessageQueueId_t;
class MessageQueueMessageIF {
public:
static const MessageQueueId_t NO_QUEUE = 0xffffffff;
static const MessageQueueId_t NO_QUEUE = -1;
/**
* @brief This constants defines the size of the header,
* which is added to every message.
*/
static const size_t HEADER_SIZE = sizeof(MessageQueueId_t);
virtual ~MessageQueueMessageIF() {};
@ -73,6 +78,10 @@ public:
*/
virtual size_t getMessageSize() const = 0;
virtual void setMessageSize(size_t messageSize) = 0;
virtual size_t getMinimumMessageSize() const = 0;
virtual size_t getMaximumMessageSize() const = 0;
};

View File

@ -51,16 +51,14 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode,
break;
default:
ipcStore->deleteData(ipcAddress);
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
MemoryMessage::setMemoryReplyFailed(&reply, errorCode,
MemoryMessage::CMD_MEMORY_LOAD);
queueToUse->sendMessage(lastSender, &reply);
return;
}
//Only reached on success
MessageQueueMessage message;
CommandMessage reply(&message, CommandMessage::REPLY_COMMAND_OK, 0, 0);
CommandMessage reply( CommandMessage::REPLY_COMMAND_OK, 0, 0);
queueToUse->sendMessage(lastSender, &reply);
ipcStore->deleteData(ipcAddress);
}
@ -68,8 +66,7 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode,
void MemoryHelper::completeDump(ReturnValue_t errorCode,
const uint8_t* dataToCopy, const uint32_t size) {
busy = false;
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
MemoryMessage::setMemoryReplyFailed(&reply, errorCode, lastCommand);
switch (errorCode) {
case HasMemoryIF::DO_IT_MYSELF:
@ -154,8 +151,7 @@ void MemoryHelper::handleMemoryLoad(CommandMessage* message) {
completeLoad(returnCode, p_data, size, dataPointer);
} else {
//At least inform sender.
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
MemoryMessage::setMemoryReplyFailed(&reply, returnCode,
MemoryMessage::CMD_MEMORY_LOAD);
queueToUse->sendMessage(lastSender, &reply);
@ -173,8 +169,7 @@ void MemoryHelper::handleMemoryCheckOrDump(CommandMessage* message) {
reservedSpaceInIPC);
completeDump(returnCode, dataPointer, size);
} else {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
MemoryMessage::setMemoryReplyFailed(&reply, returnCode, lastCommand);
queueToUse->sendMessage(lastSender, &reply);
}

View File

@ -12,8 +12,7 @@ ModeHelper::~ModeHelper() {
}
ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
Mode_t mode;
Submode_t submode;
switch (command->getCommand()) {
@ -79,8 +78,7 @@ void ModeHelper::modeChanged(Mode_t ownerMode, Submode_t ownerSubmode) {
void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
Submode_t ownerSubmode) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
if (theOneWhoCommandedAMode != MessageQueueMessageIF::NO_QUEUE)
{
if (ownerMode != commandedMode or ownerSubmode != commandedSubmode)
@ -101,8 +99,7 @@ void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
void ModeHelper::sendModeInfoMessage(Mode_t ownerMode,
Submode_t ownerSubmode) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
if (theOneWhoCommandedAMode != parentQueueId
and parentQueueId != MessageQueueMessageIF::NO_QUEUE)
{

View File

@ -31,8 +31,7 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
MessageQueueMessage message;
CommandMessage report(&message);
CommandMessage report;
MonitoringMessage::setLimitViolationReport(&report, storeId);
return MessageQueueSenderIF::sendMessage(reportQueue, &report);
}

View File

@ -102,8 +102,7 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id,
return result;
}
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
ParameterMessage::setParameterDumpReply(&reply, id, address);
@ -126,8 +125,7 @@ ReturnValue_t ParameterHelper::initialize() {
void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
Command_t initialCommand) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
reply.setReplyRejected(reason, initialCommand);
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
}

View File

@ -163,8 +163,7 @@ void Fuse::setAllMonitorsToUnchecked() {
}
void Fuse::checkCommandQueue() {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result != HasReturnvaluesIF::RETURN_OK) {
return;

View File

@ -74,8 +74,7 @@ void PowerSensor::setAllMonitorsToUnchecked() {
}
void PowerSensor::checkCommandQueue() {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result != HasReturnvaluesIF::RETURN_OK) {
return;

View File

@ -309,8 +309,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
break;
case ModeSequenceMessage::READ_FREE_SEQUENCE_SLOTS: {
uint32_t freeSlots = modeSequences.maxSize() - modeSequences.size();
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
ModeSequenceMessage::setModeSequenceMessage(&reply,
ModeSequenceMessage::FREE_SEQUENCE_SLOTS, freeSlots);
commandQueue->reply(&reply);
@ -318,8 +317,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
break;
case ModeSequenceMessage::READ_FREE_TABLE_SLOTS: {
uint32_t free = modeTables.maxSize() - modeTables.size();
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
ModeSequenceMessage::setModeSequenceMessage(&reply,
ModeSequenceMessage::FREE_TABLE_SLOTS, free);
commandQueue->reply(&reply);
@ -332,12 +330,11 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
}
void Subsystem::replyToCommand(ReturnValue_t status, uint32_t parameter) {
MessageQueueMessage message;
if (status == RETURN_OK) {
CommandMessage reply(&message, CommandMessage::REPLY_COMMAND_OK, 0, 0);
CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, 0);
commandQueue->reply(&reply);
} else {
CommandMessage reply(&message, CommandMessage::REPLY_REJECTED, status, 0);
CommandMessage reply(CommandMessage::REPLY_REJECTED, status, 0);
commandQueue->reply(&reply);
}
}
@ -620,8 +617,7 @@ void Subsystem::sendSerializablesAsCommandMessage(Command_t command,
for (uint8_t i = 0; i < count; i++) {
elements[i]->serialize(&storeBuffer, &size, maxSize, true);
}
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
ModeSequenceMessage::setModeSequenceMessage(&reply, command, address);
if (commandQueue->reply(&reply) != RETURN_OK) {
IPCStore->deleteData(address);

View File

@ -77,8 +77,7 @@ ReturnValue_t SubsystemBase::checkStateAgainstTable(
}
void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submode_t targetSubmode) {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
std::map<object_id_t, ChildInfo>::iterator iter;
@ -129,7 +128,7 @@ void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submod
continue; //don't send redundant mode commands (produces event spam), but still command if mode is forced to reach lower levels
}
ReturnValue_t result = commandQueue->sendMessage(
iter->second.commandQueue, &message);
iter->second.commandQueue, &command);
if (result == RETURN_OK) {
++commandsOutstanding;
}
@ -297,8 +296,7 @@ void SubsystemBase::setToExternalControl() {
void SubsystemBase::announceMode(bool recursive) {
triggerEvent(MODE_INFO, mode, submode);
if (recursive) {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
ModeMessage::setModeMessage(&command,
ModeMessage::CMD_MODE_ANNOUNCE_RECURSIVELY, 0, 0);
commandAllChildren(&command);
@ -307,8 +305,7 @@ void SubsystemBase::announceMode(bool recursive) {
void SubsystemBase::checkCommandQueue() {
ReturnValue_t result;
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
result = commandQueue->receiveMessage(&command)) {
@ -330,8 +327,7 @@ void SubsystemBase::checkCommandQueue() {
result = handleCommandMessage(&command);
if (result != RETURN_OK) {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND,
command.getCommand());
replyToCommand(&reply);

View File

@ -44,8 +44,7 @@ ReturnValue_t AbstractTemperatureSensor::performHealthOp() {
}
void AbstractTemperatureSensor::handleCommandQueue() {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result == HasReturnvaluesIF::RETURN_OK) {
result = healthHelper.handleHealthCommand(&command);
@ -57,7 +56,7 @@ void AbstractTemperatureSensor::handleCommandQueue() {
return;
}
command.setToUnknownCommand();
commandQueue->reply(&message);
commandQueue->reply(&command);
}
}

View File

@ -279,8 +279,7 @@ ReturnValue_t Heater::initialize() {
}
void Heater::handleQueue() {
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
ReturnValue_t result = commandQueue->receiveMessage(&command);
if (result == HasReturnvaluesIF::RETURN_OK) {
result = healthHelper.handleHealthCommand(&command);

View File

@ -76,28 +76,18 @@ ReturnValue_t CommandingServiceBase::initialize() {
}
void CommandingServiceBase::handleCommandQueue() {
MessageQueueMessage message;
CommandMessage reply(&message);
CommandMessage reply;
ReturnValue_t result = RETURN_FAILED;
for (result = commandQueue->receiveMessage(&reply); result == RETURN_OK;
result = commandQueue->receiveMessage(&reply)) {
if(reply.getInternalMessage() == nullptr) {
// This should never happen unless the passed message maximum size
// is too small!
sif::error << "CommandingServiceBase::handleCommandMessage: Reply"
"does not satisfy minimum requirements for a command "
"message!" << std::endl;
continue;
}
handleCommandMessage(&reply);
}
}
void CommandingServiceBase::handleCommandMessage(CommandMessageIF* reply) {
void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
bool isStep = false;
MessageQueueMessage message;
CommandMessage nextCommand(&message);
CommandMessage nextCommand;
CommandMapIter iter = commandMap.find(reply->getSender());
// handle unrequested reply first
@ -303,8 +293,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
CommandMapIter iter) {
ReturnValue_t result = RETURN_OK;
MessageQueueMessage message;
CommandMessage command(&message);
CommandMessage command;
iter->subservice = storedPacket->getSubService();
result = prepareCommand(&command, iter->subservice,
storedPacket->getApplicationData(),
@ -316,7 +305,7 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
case RETURN_OK:
if (command.getCommand() != CommandMessage::CMD_NONE) {
sendResult = commandQueue->sendMessage(iter.value->first,
&message);
&command);
}
if (sendResult == RETURN_OK) {
Clock::getUptime(&iter->uptimeOfStart);
@ -338,7 +327,7 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
if (command.getCommand() != CommandMessage::CMD_NONE) {
//Fire-and-forget command.
sendResult = commandQueue->sendMessage(iter.value->first,
&message);
&command);
}
if (sendResult == RETURN_OK) {
verificationReporter.sendSuccessReport(TC_VERIFY::START_SUCCESS,
@ -384,9 +373,8 @@ void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter iter) {
}
void CommandingServiceBase::handleUnrequestedReply(CommandMessageIF* reply) {
CommandMessage commandReply(reply->getInternalMessage());
commandReply.clear();
void CommandingServiceBase::handleUnrequestedReply(CommandMessage* reply) {
reply->clear();
}

View File

@ -139,7 +139,7 @@ protected:
* @param objectId Target object ID
* @return
*/
virtual ReturnValue_t prepareCommand(CommandMessageIF *message,
virtual ReturnValue_t prepareCommand(CommandMessage* message,
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
uint32_t *state, object_id_t objectId) = 0;
@ -168,9 +168,9 @@ protected:
* a failure verification message with the reason as the error parameter
* and the initial command as failure parameter 1.
*/
virtual ReturnValue_t handleReply(const CommandMessageIF *reply,
virtual ReturnValue_t handleReply(const CommandMessage* reply,
Command_t previousCommand, uint32_t *state,
CommandMessageIF *optionalNextCommand, object_id_t objectId,
CommandMessage* optionalNextCommand, object_id_t objectId,
bool *isStep) = 0;
/**
@ -182,7 +182,7 @@ protected:
* Reply which is non-const so the default implementation can clear the
* message.
*/
virtual void handleUnrequestedReply(CommandMessageIF *reply);
virtual void handleUnrequestedReply(CommandMessage* reply);
virtual void doPeriodicOperation();
@ -310,7 +310,7 @@ private:
void startExecution(TcPacketStored *storedPacket, CommandMapIter iter);
void handleCommandMessage(CommandMessageIF* reply);
void handleCommandMessage(CommandMessage* reply);
void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter,
CommandMessageIF* nextCommand,CommandMessageIF* reply, bool& isStep);