WIP: somethings wrong.. #19
@ -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) {
|
void ActionHelper::step(uint8_t step, MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
ActionMessage::setStepReply(&reply, commandId, step + STEP_OFFSET, result);
|
ActionMessage::setStepReply(&reply, commandId, step + STEP_OFFSET, result);
|
||||||
queueToUse->sendMessage(reportTo, &reply);
|
queueToUse->sendMessage(reportTo, &reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionHelper::finish(MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) {
|
void ActionHelper::finish(MessageQueueId_t reportTo, ActionId_t commandId, ReturnValue_t result) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
ActionMessage::setCompletionReply(&reply, commandId, result);
|
ActionMessage::setCompletionReply(&reply, commandId, result);
|
||||||
queueToUse->sendMessage(reportTo, &reply);
|
queueToUse->sendMessage(reportTo, &reply);
|
||||||
}
|
}
|
||||||
@ -56,8 +54,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
|
|||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size);
|
ReturnValue_t result = ipcStore->getData(dataAddress, &dataPtr, &size);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
ActionMessage::setStepReply(&reply, actionId, 0, result);
|
ActionMessage::setStepReply(&reply, actionId, 0, result);
|
||||||
queueToUse->sendMessage(commandedBy, &reply);
|
queueToUse->sendMessage(commandedBy, &reply);
|
||||||
return;
|
return;
|
||||||
@ -65,8 +62,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
|
|||||||
result = owner->executeAction(actionId, commandedBy, dataPtr, size);
|
result = owner->executeAction(actionId, commandedBy, dataPtr, size);
|
||||||
ipcStore->deleteData(dataAddress);
|
ipcStore->deleteData(dataAddress);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
ActionMessage::setStepReply(&reply, actionId, 0, result);
|
ActionMessage::setStepReply(&reply, actionId, 0, result);
|
||||||
queueToUse->sendMessage(commandedBy, &reply);
|
queueToUse->sendMessage(commandedBy, &reply);
|
||||||
return;
|
return;
|
||||||
@ -75,8 +71,7 @@ void ActionHelper::prepareExecution(MessageQueueId_t commandedBy, ActionId_t act
|
|||||||
|
|
||||||
ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
|
ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo,
|
||||||
ActionId_t replyId, SerializeIF* data, bool hideSender) {
|
ActionId_t replyId, SerializeIF* data, bool hideSender) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
store_address_t storeAddress;
|
store_address_t storeAddress;
|
||||||
uint8_t *dataPtr;
|
uint8_t *dataPtr;
|
||||||
size_t maxSize = data->getSerializedSize();
|
size_t maxSize = data->getSerializedSize();
|
||||||
|
@ -53,8 +53,7 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo,
|
|||||||
|
|
||||||
ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId,
|
ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId,
|
||||||
ActionId_t actionId, store_address_t storeId) {
|
ActionId_t actionId, store_address_t storeId) {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
ActionMessage::setCommand(&command, actionId, storeId);
|
ActionMessage::setCommand(&command, actionId, storeId);
|
||||||
ReturnValue_t result = queueToUse->sendMessage(queueId, &command);
|
ReturnValue_t result = queueToUse->sendMessage(queueId, &command);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
@ -36,8 +36,7 @@ void SimpleActionHelper::resetHelper() {
|
|||||||
|
|
||||||
void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy,
|
void SimpleActionHelper::prepareExecution(MessageQueueId_t commandedBy,
|
||||||
ActionId_t actionId, store_address_t dataAddress) {
|
ActionId_t actionId, store_address_t dataAddress) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
if (isExecuting) {
|
if (isExecuting) {
|
||||||
ipcStore->deleteData(dataAddress);
|
ipcStore->deleteData(dataAddress);
|
||||||
ActionMessage::setStepReply(&reply, actionId, 0,
|
ActionMessage::setStepReply(&reply, actionId, 0,
|
||||||
|
@ -56,8 +56,7 @@ MessageQueueId_t ControllerBase::getCommandQueue() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ControllerBase::handleQueue() {
|
void ControllerBase::handleQueue() {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
|
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
|
||||||
result = commandQueue->receiveMessage(&command)) {
|
result = commandQueue->receiveMessage(&command)) {
|
||||||
|
@ -21,8 +21,7 @@ ReturnValue_t HkSwitchHelper::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t HkSwitchHelper::performOperation(uint8_t operationCode) {
|
ReturnValue_t HkSwitchHelper::performOperation(uint8_t operationCode) {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
while (actionQueue->receiveMessage(&command) == HasReturnvaluesIF::RETURN_OK) {
|
while (actionQueue->receiveMessage(&command) == HasReturnvaluesIF::RETURN_OK) {
|
||||||
ReturnValue_t result = commandActionHelper.handleReply(&command);
|
ReturnValue_t result = commandActionHelper.handleReply(&command);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
@ -66,8 +66,7 @@ ReturnValue_t DataPoolAdmin::getParameter(uint8_t domainId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DataPoolAdmin::handleCommand() {
|
void DataPoolAdmin::handleCommand() {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return;
|
return;
|
||||||
@ -283,8 +282,7 @@ ReturnValue_t DataPoolAdmin::sendParameter(MessageQueueId_t to, uint32_t id,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
|
|
||||||
ParameterMessage::setParameterDumpReply(&reply, id, address);
|
ParameterMessage::setParameterDumpReply(&reply, id, address);
|
||||||
|
|
||||||
@ -296,8 +294,7 @@ ReturnValue_t DataPoolAdmin::sendParameter(MessageQueueId_t to, uint32_t id,
|
|||||||
//identical to ParameterHelper::rejectCommand()
|
//identical to ParameterHelper::rejectCommand()
|
||||||
void DataPoolAdmin::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
|
void DataPoolAdmin::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
|
||||||
Command_t initialCommand) {
|
Command_t initialCommand) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
reply.setReplyRejected(reason, initialCommand);
|
reply.setReplyRejected(reason, initialCommand);
|
||||||
commandQueue->sendMessage(to, &reply);
|
commandQueue->sendMessage(to, &reply);
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,8 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
||||||
HousekeepingMessage& message) {
|
CommandMessage* message) {
|
||||||
Command_t command = message.getCommand();
|
Command_t command = message->getCommand();
|
||||||
switch(command) {
|
switch(command) {
|
||||||
// I think those are the only commands which can be handled here..
|
// I think those are the only commands which can be handled here..
|
||||||
case(HousekeepingMessage::ADD_HK_REPORT_STRUCT):
|
case(HousekeepingMessage::ADD_HK_REPORT_STRUCT):
|
||||||
@ -55,10 +55,10 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES):
|
case(HousekeepingMessage::REPORT_DIAGNOSTICS_REPORT_STRUCTURES):
|
||||||
case(HousekeepingMessage::REPORT_HK_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_PARAMETER_REPORT):
|
||||||
case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT):
|
case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT):
|
||||||
return generateHousekeepingPacket(message.getSid());
|
//return generateHousekeepingPacket(message->getSid());
|
||||||
default:
|
default:
|
||||||
return CommandMessageIF::UNKNOWN_COMMAND;
|
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.
|
// and now we set a HK message and send it the HK packet destination.
|
||||||
MessageQueueMessage message;
|
//HousekeepingMessage hkMessage;
|
||||||
HousekeepingMessage hkMessage(&message);
|
// hkMessage.setHkReportMessage(sid, storeId);
|
||||||
hkMessage.setHkReportMessage(sid, storeId);
|
// if(hkQueue == nullptr) {
|
||||||
if(hkQueue == nullptr) {
|
// return QUEUE_NOT_SET;
|
||||||
return QUEUE_NOT_SET;
|
// }
|
||||||
}
|
//
|
||||||
|
// if(currentHkPacketDestination != MessageQueueIF::NO_QUEUE) {
|
||||||
if(currentHkPacketDestination != MessageQueueIF::NO_QUEUE) {
|
// result = hkQueue->sendMessage(currentHkPacketDestination, &hkMessage);
|
||||||
result = hkQueue->sendMessage(currentHkPacketDestination, &hkMessage);
|
// }
|
||||||
}
|
// else {
|
||||||
else {
|
// result = hkQueue->sendToDefault(&hkMessage);
|
||||||
result = hkQueue->sendToDefault(&hkMessage);
|
// }
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public:
|
|||||||
ReturnValue_t generateHousekeepingPacket(sid_t sid);
|
ReturnValue_t generateHousekeepingPacket(sid_t sid);
|
||||||
ReturnValue_t generateSetStructurePacket(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
|
* This function is used to fill the local data pool map with pool
|
||||||
|
@ -148,8 +148,7 @@ void AssemblyBase::handleModeTransitionFailed(ReturnValue_t result) {
|
|||||||
|
|
||||||
void AssemblyBase::sendHealthCommand(MessageQueueId_t sendTo,
|
void AssemblyBase::sendHealthCommand(MessageQueueId_t sendTo,
|
||||||
HealthState health) {
|
HealthState health) {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
HealthMessage::setHealthMessage(&command, HealthMessage::HEALTH_SET,
|
HealthMessage::setHealthMessage(&command, HealthMessage::HEALTH_SET,
|
||||||
health);
|
health);
|
||||||
if (commandQueue->sendMessage(sendTo, &command) == RETURN_OK) {
|
if (commandQueue->sendMessage(sendTo, &command) == RETURN_OK) {
|
||||||
|
@ -214,12 +214,7 @@ void DeviceHandlerBase::readCommandQueue() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is not ideal. What if it is not a command message? (e.g. another
|
CommandMessage command;
|
||||||
// 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);
|
|
||||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return;
|
return;
|
||||||
@ -247,8 +242,7 @@ void DeviceHandlerBase::readCommandQueue() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HousekeepingMessage hkMessage(&message);
|
result = hkManager.handleHousekeepingMessage(&command);
|
||||||
result = hkManager.handleHousekeepingMessage(hkMessage);
|
|
||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -484,13 +478,12 @@ void DeviceHandlerBase::setMode(Mode_t newMode) {
|
|||||||
|
|
||||||
void DeviceHandlerBase::replyReturnvalueToCommand(ReturnValue_t status,
|
void DeviceHandlerBase::replyReturnvalueToCommand(ReturnValue_t status,
|
||||||
uint32_t parameter) {
|
uint32_t parameter) {
|
||||||
MessageQueueMessage message;
|
|
||||||
//This is actually the reply protocol for raw and misc DH commands.
|
//This is actually the reply protocol for raw and misc DH commands.
|
||||||
if (status == RETURN_OK) {
|
if (status == RETURN_OK) {
|
||||||
CommandMessage reply(&message, CommandMessage::REPLY_COMMAND_OK, 0, parameter);
|
CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, parameter);
|
||||||
commandQueue->reply(&reply);
|
commandQueue->reply(&reply);
|
||||||
} else {
|
} else {
|
||||||
CommandMessage reply(&message, CommandMessage::REPLY_REJECTED, status, parameter);
|
CommandMessage reply(CommandMessage::REPLY_REJECTED, status, parameter);
|
||||||
commandQueue->reply(&reply);
|
commandQueue->reply(&reply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -760,8 +753,7 @@ void DeviceHandlerBase::replyRawData(const uint8_t *data, size_t len,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
|
|
||||||
DeviceHandlerMessage::setDeviceHandlerRawReplyMessage(&command,
|
DeviceHandlerMessage::setDeviceHandlerRawReplyMessage(&command,
|
||||||
getObjectId(), address, isCommand);
|
getObjectId(), address, isCommand);
|
||||||
|
@ -13,8 +13,7 @@ HealthDevice::~HealthDevice() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t HealthDevice::performOperation(uint8_t opCode) {
|
ReturnValue_t HealthDevice::performOperation(uint8_t opCode) {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
healthHelper.handleHealthCommand(&command);
|
healthHelper.handleHealthCommand(&command);
|
||||||
|
@ -65,8 +65,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health,
|
|||||||
if (parentQueue == MessageQueueMessageIF::NO_QUEUE) {
|
if (parentQueue == MessageQueueMessageIF::NO_QUEUE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageQueueMessage message;
|
CommandMessage information;
|
||||||
CommandMessage information(&message);
|
|
||||||
HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO,
|
HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO,
|
||||||
health, oldHealth);
|
health, oldHealth);
|
||||||
if (MessageQueueSenderIF::sendMessage(parentQueue, &information,
|
if (MessageQueueSenderIF::sendMessage(parentQueue, &information,
|
||||||
@ -81,8 +80,7 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) {
|
|||||||
if (command->getSender() == MessageQueueMessageIF::NO_QUEUE) {
|
if (command->getSender() == MessageQueueMessageIF::NO_QUEUE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
HealthMessage::setHealthMessage(&reply,
|
HealthMessage::setHealthMessage(&reply,
|
||||||
HealthMessage::REPLY_HEALTH_SET);
|
HealthMessage::REPLY_HEALTH_SET);
|
||||||
|
@ -1,15 +1,7 @@
|
|||||||
#include <framework/housekeeping/HousekeepingMessage.h>
|
#include <framework/housekeeping/HousekeepingMessage.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
HousekeepingMessage::HousekeepingMessage(MessageQueueMessageIF* message):
|
HousekeepingMessage::HousekeepingMessage(): CommandMessage() {
|
||||||
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() {}
|
HousekeepingMessage::~HousekeepingMessage() {}
|
||||||
@ -26,14 +18,14 @@ uint32_t HousekeepingMessage::getParameter() const {
|
|||||||
|
|
||||||
void HousekeepingMessage::setHkReportMessage(sid_t sid,
|
void HousekeepingMessage::setHkReportMessage(sid_t sid,
|
||||||
store_address_t storeId) {
|
store_address_t storeId) {
|
||||||
CommandMessageBase::setCommand(HK_REPORT);
|
CommandMessage::setCommand(HK_REPORT);
|
||||||
setSid(sid);
|
setSid(sid);
|
||||||
setParameter(storeId.raw);
|
setParameter(storeId.raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HousekeepingMessage::setHkDiagnosticsMessage(sid_t sid,
|
void HousekeepingMessage::setHkDiagnosticsMessage(sid_t sid,
|
||||||
store_address_t storeId) {
|
store_address_t storeId) {
|
||||||
CommandMessageBase::setCommand(DIAGNOSTICS_REPORT);
|
CommandMessage::setCommand(DIAGNOSTICS_REPORT);
|
||||||
setSid(sid);
|
setSid(sid);
|
||||||
setParameter(storeId.raw);
|
setParameter(storeId.raw);
|
||||||
}
|
}
|
||||||
@ -44,7 +36,7 @@ void HousekeepingMessage::setHkDiagnosticsMessage(sid_t sid,
|
|||||||
|
|
||||||
sid_t HousekeepingMessage::getSid() const {
|
sid_t HousekeepingMessage::getSid() const {
|
||||||
sid_t sid;
|
sid_t sid;
|
||||||
std::memcpy(&sid.raw, CommandMessageBase::getData(), sizeof(sid.raw));
|
std::memcpy(&sid.raw, CommandMessage::getData(), sizeof(sid.raw));
|
||||||
return sid;
|
return sid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,16 +50,16 @@ sid_t HousekeepingMessage::getHkReportMessage(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HousekeepingMessage::setSid(sid_t sid) {
|
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() {
|
uint8_t* HousekeepingMessage::getData() {
|
||||||
return CommandMessageBase::getData() + sizeof(sid_t);
|
return CommandMessage::getData() + sizeof(sid_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t* HousekeepingMessage::getData() const {
|
const uint8_t* HousekeepingMessage::getData() const {
|
||||||
return CommandMessageBase::getData() + sizeof(sid_t);
|
return CommandMessage::getData() + sizeof(sid_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HousekeepingMessage::clear() {
|
void HousekeepingMessage::clear() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef FRAMEWORK_HK_HOUSEKEEPINGMESSAGE_H_
|
#ifndef FRAMEWORK_HK_HOUSEKEEPINGMESSAGE_H_
|
||||||
#define 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/ipc/FwMessageTypes.h>
|
||||||
#include <framework/objectmanager/SystemObjectIF.h>
|
#include <framework/objectmanager/SystemObjectIF.h>
|
||||||
#include <framework/storagemanager/StorageManagerIF.h>
|
#include <framework/storagemanager/StorageManagerIF.h>
|
||||||
@ -33,7 +34,7 @@ union sid_t {
|
|||||||
* This message is slightly larger than regular command messages to accomodate
|
* This message is slightly larger than regular command messages to accomodate
|
||||||
* the uint64_t structure ID (SID).
|
* the uint64_t structure ID (SID).
|
||||||
*/
|
*/
|
||||||
class HousekeepingMessage : public CommandMessageBase {
|
class HousekeepingMessage : public CommandMessage {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static constexpr size_t HK_MESSAGE_SIZE = CommandMessageIF::HEADER_SIZE +
|
static constexpr size_t HK_MESSAGE_SIZE = CommandMessageIF::HEADER_SIZE +
|
||||||
@ -44,7 +45,7 @@ public:
|
|||||||
* the message data, see CommandMessageIF and getInternalMessage().
|
* the message data, see CommandMessageIF and getInternalMessage().
|
||||||
* @param message
|
* @param message
|
||||||
*/
|
*/
|
||||||
HousekeepingMessage(MessageQueueMessageIF* message);
|
HousekeepingMessage();
|
||||||
virtual ~HousekeepingMessage();
|
virtual ~HousekeepingMessage();
|
||||||
|
|
||||||
static constexpr uint8_t MESSAGE_ID = messagetypes::HOUSEKEEPING;
|
static constexpr uint8_t MESSAGE_ID = messagetypes::HOUSEKEEPING;
|
||||||
|
@ -1,57 +1,64 @@
|
|||||||
#include <framework/ipc/CommandMessage.h>
|
#include <framework/ipc/CommandMessage.h>
|
||||||
|
#include <framework/ipc/CommandMessageCleaner.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
CommandMessage::CommandMessage(MessageQueueMessageIF* receiverMessage):
|
CommandMessage::CommandMessage() {
|
||||||
CommandMessageBase(receiverMessage) {
|
MessageQueueMessage::setMessageSize(DEFAULT_COMMAND_MESSAGE_SIZE);
|
||||||
if(receiverMessage == nullptr) {
|
setCommand(CMD_NONE);
|
||||||
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(MessageQueueMessageIF* messageToSet,
|
CommandMessage::CommandMessage(Command_t command, uint32_t parameter1,
|
||||||
Command_t command, uint32_t parameter1, uint32_t parameter2):
|
uint32_t parameter2) {
|
||||||
CommandMessage(messageToSet) {
|
MessageQueueMessage::setMessageSize(DEFAULT_COMMAND_MESSAGE_SIZE);
|
||||||
setCommand(command);
|
setCommand(command);
|
||||||
setParameter(parameter1);
|
setParameter(parameter1);
|
||||||
setParameter2(parameter2);
|
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 CommandMessage::getParameter() const {
|
||||||
uint32_t parameter1;
|
uint32_t parameter1;
|
||||||
std::memcpy(¶meter1, CommandMessageBase::getData(), sizeof(parameter1));
|
std::memcpy(¶meter1, MessageQueueMessage::getData(), sizeof(parameter1));
|
||||||
return parameter1;
|
return parameter1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandMessage::setParameter(uint32_t parameter1) {
|
void CommandMessage::setParameter(uint32_t parameter1) {
|
||||||
std::memcpy(CommandMessageBase::getData(), ¶meter1, sizeof(parameter1));
|
std::memcpy(MessageQueueMessage::getData(), ¶meter1, sizeof(parameter1));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t CommandMessage::getParameter2() const {
|
uint32_t CommandMessage::getParameter2() const {
|
||||||
uint32_t parameter2;
|
uint32_t parameter2;
|
||||||
std::memcpy(¶meter2, CommandMessageBase::getData() + sizeof(uint32_t),
|
std::memcpy(¶meter2, MessageQueueMessage::getData() + sizeof(uint32_t),
|
||||||
sizeof(parameter2));
|
sizeof(parameter2));
|
||||||
return parameter2;
|
return parameter2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandMessage::setParameter2(uint32_t parameter2) {
|
void CommandMessage::setParameter2(uint32_t parameter2) {
|
||||||
std::memcpy(CommandMessageBase::getData() + sizeof(uint32_t), ¶meter2,
|
std::memcpy(MessageQueueMessage::getData() + sizeof(uint32_t), ¶meter2,
|
||||||
sizeof(parameter2));
|
sizeof(parameter2));
|
||||||
}
|
}
|
||||||
|
|
||||||
//size_t CommandMessage::getMinimumMessageSize() const {
|
size_t CommandMessage::getMinimumMessageSize() const {
|
||||||
// return MINIMUM_COMMAND_MESSAGE_SIZE;
|
return MINIMUM_COMMAND_MESSAGE_SIZE;
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
void CommandMessage::clear() {
|
||||||
|
CommandMessageCleaner::clearCommandMessage(this);
|
||||||
|
}
|
||||||
|
|
||||||
bool CommandMessage::isClearedCommandMessage() {
|
bool CommandMessage::isClearedCommandMessage() {
|
||||||
return getCommand() == CMD_NONE;
|
return getCommand() == CMD_NONE;
|
||||||
@ -62,3 +69,21 @@ void CommandMessage::setToUnknownCommand() {
|
|||||||
this->clear();
|
this->clear();
|
||||||
setReplyRejected(UNKNOWN_COMMAND, initialCommand);
|
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;
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef FRAMEWORK_IPC_COMMANDMESSAGE_H_
|
#ifndef FRAMEWORK_IPC_COMMANDMESSAGE_H_
|
||||||
#define 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/MessageQueueMessage.h>
|
||||||
#include <framework/ipc/FwMessageTypes.h>
|
#include <framework/ipc/FwMessageTypes.h>
|
||||||
|
|
||||||
@ -20,23 +20,21 @@
|
|||||||
* currently has an internal message size of 28 bytes.
|
* currently has an internal message size of 28 bytes.
|
||||||
* @author Bastian Baetz
|
* @author Bastian Baetz
|
||||||
*/
|
*/
|
||||||
class CommandMessage: public CommandMessageBase {
|
class CommandMessage: public MessageQueueMessage, public CommandMessageIF {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* This is the size of a message as it is seen by the MessageQueue.
|
* Default size can accomodate 2 4-byte parameters.
|
||||||
* It can hold the CommandMessage header plus 2 4-byte parameters.
|
*/
|
||||||
* 14 of the 24 available MessageQueueMessage bytes are used.
|
static constexpr size_t DEFAULT_COMMAND_MESSAGE_SIZE =
|
||||||
*/
|
CommandMessageIF::MINIMUM_COMMAND_MESSAGE_SIZE + sizeof(uint32_t);
|
||||||
static const size_t MINIMUM_COMMAND_MESSAGE_SIZE =
|
|
||||||
CommandMessageIF::HEADER_SIZE + 2 * 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
|
* This constructor should be used when receiving a Message, as the
|
||||||
* content is filled by the MessageQueue.
|
* content is filled by the MessageQueue.
|
||||||
*/
|
*/
|
||||||
CommandMessage(MessageQueueMessageIF* receiverMessage);
|
CommandMessage();
|
||||||
/**
|
/**
|
||||||
* This constructor creates a new message with all message content
|
* This constructor creates a new message with all message content
|
||||||
* initialized
|
* initialized
|
||||||
@ -45,17 +43,13 @@ public:
|
|||||||
* @param parameter1 The first parameter
|
* @param parameter1 The first parameter
|
||||||
* @param parameter2 The second parameter
|
* @param parameter2 The second parameter
|
||||||
*/
|
*/
|
||||||
CommandMessage(MessageQueueMessageIF* messageToSet, Command_t command,
|
CommandMessage(Command_t command, uint32_t parameter1, uint32_t parameter2);
|
||||||
uint32_t parameter1, uint32_t parameter2);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Default Destructor
|
* @brief Default Destructor
|
||||||
*/
|
*/
|
||||||
virtual ~CommandMessage() {}
|
virtual ~CommandMessage() {}
|
||||||
|
|
||||||
/** MessageQueueMessageIF functions used for minimum size check. */
|
|
||||||
//size_t getMinimumMessageSize() const override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the first parameter of the message
|
* Get the first parameter of the message
|
||||||
* @return 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.
|
* Sets the command to REPLY_REJECTED with parameter UNKNOWN_COMMAND.
|
||||||
* Is needed quite often, so we better code it once only.
|
* 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_ */
|
#endif /* COMMANDMESSAGE_H_ */
|
||||||
|
@ -1,86 +1,86 @@
|
|||||||
#include <framework/ipc/CommandMessageBase.h>
|
//#include <framework/ipc/CommandMessageBase.h>
|
||||||
#include <framework/ipc/CommandMessageCleaner.h>
|
//#include <framework/ipc/CommandMessageCleaner.h>
|
||||||
#include <cstring>
|
//#include <cstring>
|
||||||
|
//
|
||||||
CommandMessageBase::CommandMessageBase(MessageQueueMessageIF *message):
|
//CommandMessageBase::CommandMessageBase(MessageQueueMessageIF *message):
|
||||||
internalMessage(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);
|
|
||||||
//}
|
//}
|
||||||
|
//
|
||||||
size_t CommandMessageBase::getMessageSize() const {
|
//Command_t CommandMessageBase::getCommand() const {
|
||||||
return internalMessage->getMessageSize();
|
// Command_t command;
|
||||||
}
|
// std::memcpy(&command, internalMessage->getData(), sizeof(Command_t));
|
||||||
|
// return command;
|
||||||
MessageQueueMessageIF* CommandMessageBase::getInternalMessage() const {
|
//}
|
||||||
return internalMessage;
|
//
|
||||||
}
|
//void CommandMessageBase::setCommand(Command_t command) {
|
||||||
|
// std::memcpy(internalMessage->getData(), &command, sizeof(Command_t));
|
||||||
//size_t CommandMessageBase::getMinimumMessageSize() const {
|
//}
|
||||||
// return MINIMUM_COMMAND_MESSAGE_BASE_SIZE;
|
//
|
||||||
|
//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);
|
|
||||||
}
|
|
||||||
|
@ -23,67 +23,28 @@
|
|||||||
*/
|
*/
|
||||||
class CommandMessageBase: public CommandMessageIF {
|
class CommandMessageBase: public CommandMessageIF {
|
||||||
public:
|
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);
|
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
|
// * MessageQueueMessageIF functions, which generally just call the
|
||||||
* respective functions of the internal message queue message.
|
// * respective functions of the internal message queue message.
|
||||||
*/
|
// */
|
||||||
virtual uint8_t * getBuffer() override;
|
// virtual uint8_t * getBuffer() override;
|
||||||
virtual const uint8_t * getBuffer() const override;
|
// virtual const uint8_t * getBuffer() const override;
|
||||||
virtual void setSender(MessageQueueId_t setId) override;
|
// virtual void setSender(MessageQueueId_t setId) override;
|
||||||
virtual MessageQueueId_t getSender() const override;
|
// virtual MessageQueueId_t getSender() const override;
|
||||||
virtual uint8_t * getData() override;
|
// virtual uint8_t * getData() override;
|
||||||
virtual const uint8_t* getData() const override;
|
// virtual const uint8_t* getData() const override;
|
||||||
virtual size_t getMessageSize() 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:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief Pointer to the message containing the data.
|
* @brief Pointer to the message containing the data.
|
||||||
|
@ -5,20 +5,24 @@
|
|||||||
#include <framework/ipc/FwMessageTypes.h>
|
#include <framework/ipc/FwMessageTypes.h>
|
||||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||||
|
|
||||||
|
|
||||||
#define MAKE_COMMAND_ID( number ) ((MESSAGE_ID << 8) + (number))
|
#define MAKE_COMMAND_ID( number ) ((MESSAGE_ID << 8) + (number))
|
||||||
typedef uint16_t Command_t;
|
typedef uint16_t Command_t;
|
||||||
|
|
||||||
// TODO: actually, this interface propably does not have to implement
|
class CommandMessageIF: virtual public MessageQueueMessageIF {
|
||||||
// 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 {
|
|
||||||
public:
|
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);
|
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 uint8_t INTERFACE_ID = CLASS_ID::COMMAND_MESSAGE;
|
||||||
static const ReturnValue_t UNKNOWN_COMMAND = MAKE_RETURN_CODE(0x01);
|
static const ReturnValue_t UNKNOWN_COMMAND = MAKE_RETURN_CODE(0x01);
|
||||||
@ -60,15 +64,9 @@ public:
|
|||||||
virtual ReturnValue_t getReplyRejectedReason(
|
virtual ReturnValue_t getReplyRejectedReason(
|
||||||
Command_t* initialCommand = nullptr) const = 0;
|
Command_t* initialCommand = nullptr) const = 0;
|
||||||
|
|
||||||
/**
|
virtual void setToUnknownCommand() = 0;
|
||||||
* This function is used to get a pointer to the internal message, as
|
|
||||||
* the command message implementations always operate on the memory
|
virtual void clear() = 0;
|
||||||
* 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;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include <framework/ipc/MessageQueueMessage.h>
|
#include <framework/ipc/MessageQueueMessage.h>
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
|
#include <framework/globalfunctions/arrayprinter.h>
|
||||||
#include <string.h>
|
#include <cstring>
|
||||||
|
|
||||||
MessageQueueMessage::MessageQueueMessage() :
|
MessageQueueMessage::MessageQueueMessage() :
|
||||||
messageSize(this->HEADER_SIZE) {
|
messageSize(getMinimumMessageSize()) {
|
||||||
memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
|
memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,17 +51,15 @@ void MessageQueueMessage::setSender(MessageQueueId_t setId) {
|
|||||||
memcpy(this->internalBuffer, &setId, sizeof(MessageQueueId_t));
|
memcpy(this->internalBuffer, &setId, sizeof(MessageQueueId_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
//size_t MessageQueueMessage::getMinimumMessageSize() const {
|
void MessageQueueMessage::print(bool printWholeMessage) {
|
||||||
// return this->HEADER_SIZE;
|
sif::debug << "MessageQueueMessage content: " << std::endl;
|
||||||
//}
|
if(printWholeMessage) {
|
||||||
|
arrayprinter::print(getData(), getMaximumMessageSize());
|
||||||
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] << ":";
|
|
||||||
}
|
}
|
||||||
sif::debug << std::dec << std::endl;
|
else {
|
||||||
|
arrayprinter::print(getData(), getMessageSize());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageQueueMessage::clear() {
|
void MessageQueueMessage::clear() {
|
||||||
@ -69,9 +67,18 @@ void MessageQueueMessage::clear() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t MessageQueueMessage::getMessageSize() const {
|
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;
|
|
||||||
//}
|
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* receive messages from other tasks.
|
* receive messages from other tasks.
|
||||||
* @ingroup message_queue
|
* @ingroup message_queue
|
||||||
*/
|
*/
|
||||||
class MessageQueueMessage: public MessageQueueMessageIF {
|
class MessageQueueMessage: virtual public MessageQueueMessageIF {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief The class is initialized empty with this constructor.
|
* @brief The class is initialized empty with this constructor.
|
||||||
@ -74,11 +74,7 @@ public:
|
|||||||
* as small as possible.
|
* as small as possible.
|
||||||
*/
|
*/
|
||||||
static const size_t MAX_DATA_SIZE = 24;
|
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
|
* @brief This constant defines the maximum total size in bytes
|
||||||
* of a sent message.
|
* of a sent message.
|
||||||
@ -141,12 +137,14 @@ public:
|
|||||||
void setSender(MessageQueueId_t setId) override;
|
void setSender(MessageQueueId_t setId) override;
|
||||||
|
|
||||||
virtual size_t getMessageSize() const 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
|
* @brief This is a debug method that prints the content.
|
||||||
* (till messageSize) to the debug output.
|
|
||||||
*/
|
*/
|
||||||
void print();
|
void print(bool printWholeMessage);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MESSAGEQUEUEMESSAGE_H_ */
|
#endif /* MESSAGEQUEUEMESSAGE_H_ */
|
||||||
|
@ -18,7 +18,12 @@ typedef uint32_t MessageQueueId_t;
|
|||||||
|
|
||||||
class MessageQueueMessageIF {
|
class MessageQueueMessageIF {
|
||||||
public:
|
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() {};
|
virtual ~MessageQueueMessageIF() {};
|
||||||
|
|
||||||
@ -73,6 +78,10 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual size_t getMessageSize() const = 0;
|
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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,16 +51,14 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode,
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ipcStore->deleteData(ipcAddress);
|
ipcStore->deleteData(ipcAddress);
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
MemoryMessage::setMemoryReplyFailed(&reply, errorCode,
|
MemoryMessage::setMemoryReplyFailed(&reply, errorCode,
|
||||||
MemoryMessage::CMD_MEMORY_LOAD);
|
MemoryMessage::CMD_MEMORY_LOAD);
|
||||||
queueToUse->sendMessage(lastSender, &reply);
|
queueToUse->sendMessage(lastSender, &reply);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//Only reached on success
|
//Only reached on success
|
||||||
MessageQueueMessage message;
|
CommandMessage reply( CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
||||||
CommandMessage reply(&message, CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
|
||||||
queueToUse->sendMessage(lastSender, &reply);
|
queueToUse->sendMessage(lastSender, &reply);
|
||||||
ipcStore->deleteData(ipcAddress);
|
ipcStore->deleteData(ipcAddress);
|
||||||
}
|
}
|
||||||
@ -68,8 +66,7 @@ void MemoryHelper::completeLoad(ReturnValue_t errorCode,
|
|||||||
void MemoryHelper::completeDump(ReturnValue_t errorCode,
|
void MemoryHelper::completeDump(ReturnValue_t errorCode,
|
||||||
const uint8_t* dataToCopy, const uint32_t size) {
|
const uint8_t* dataToCopy, const uint32_t size) {
|
||||||
busy = false;
|
busy = false;
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
MemoryMessage::setMemoryReplyFailed(&reply, errorCode, lastCommand);
|
MemoryMessage::setMemoryReplyFailed(&reply, errorCode, lastCommand);
|
||||||
switch (errorCode) {
|
switch (errorCode) {
|
||||||
case HasMemoryIF::DO_IT_MYSELF:
|
case HasMemoryIF::DO_IT_MYSELF:
|
||||||
@ -154,8 +151,7 @@ void MemoryHelper::handleMemoryLoad(CommandMessage* message) {
|
|||||||
completeLoad(returnCode, p_data, size, dataPointer);
|
completeLoad(returnCode, p_data, size, dataPointer);
|
||||||
} else {
|
} else {
|
||||||
//At least inform sender.
|
//At least inform sender.
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
MemoryMessage::setMemoryReplyFailed(&reply, returnCode,
|
MemoryMessage::setMemoryReplyFailed(&reply, returnCode,
|
||||||
MemoryMessage::CMD_MEMORY_LOAD);
|
MemoryMessage::CMD_MEMORY_LOAD);
|
||||||
queueToUse->sendMessage(lastSender, &reply);
|
queueToUse->sendMessage(lastSender, &reply);
|
||||||
@ -173,8 +169,7 @@ void MemoryHelper::handleMemoryCheckOrDump(CommandMessage* message) {
|
|||||||
reservedSpaceInIPC);
|
reservedSpaceInIPC);
|
||||||
completeDump(returnCode, dataPointer, size);
|
completeDump(returnCode, dataPointer, size);
|
||||||
} else {
|
} else {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
MemoryMessage::setMemoryReplyFailed(&reply, returnCode, lastCommand);
|
MemoryMessage::setMemoryReplyFailed(&reply, returnCode, lastCommand);
|
||||||
queueToUse->sendMessage(lastSender, &reply);
|
queueToUse->sendMessage(lastSender, &reply);
|
||||||
}
|
}
|
||||||
|
@ -12,8 +12,7 @@ ModeHelper::~ModeHelper() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) {
|
ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
Mode_t mode;
|
Mode_t mode;
|
||||||
Submode_t submode;
|
Submode_t submode;
|
||||||
switch (command->getCommand()) {
|
switch (command->getCommand()) {
|
||||||
@ -79,8 +78,7 @@ void ModeHelper::modeChanged(Mode_t ownerMode, Submode_t ownerSubmode) {
|
|||||||
|
|
||||||
void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
|
void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
|
||||||
Submode_t ownerSubmode) {
|
Submode_t ownerSubmode) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
if (theOneWhoCommandedAMode != MessageQueueMessageIF::NO_QUEUE)
|
if (theOneWhoCommandedAMode != MessageQueueMessageIF::NO_QUEUE)
|
||||||
{
|
{
|
||||||
if (ownerMode != commandedMode or ownerSubmode != commandedSubmode)
|
if (ownerMode != commandedMode or ownerSubmode != commandedSubmode)
|
||||||
@ -101,8 +99,7 @@ void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
|
|||||||
|
|
||||||
void ModeHelper::sendModeInfoMessage(Mode_t ownerMode,
|
void ModeHelper::sendModeInfoMessage(Mode_t ownerMode,
|
||||||
Submode_t ownerSubmode) {
|
Submode_t ownerSubmode) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
if (theOneWhoCommandedAMode != parentQueueId
|
if (theOneWhoCommandedAMode != parentQueueId
|
||||||
and parentQueueId != MessageQueueMessageIF::NO_QUEUE)
|
and parentQueueId != MessageQueueMessageIF::NO_QUEUE)
|
||||||
{
|
{
|
||||||
|
@ -31,8 +31,7 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF
|
|||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
MessageQueueMessage message;
|
CommandMessage report;
|
||||||
CommandMessage report(&message);
|
|
||||||
MonitoringMessage::setLimitViolationReport(&report, storeId);
|
MonitoringMessage::setLimitViolationReport(&report, storeId);
|
||||||
return MessageQueueSenderIF::sendMessage(reportQueue, &report);
|
return MessageQueueSenderIF::sendMessage(reportQueue, &report);
|
||||||
}
|
}
|
||||||
|
@ -102,8 +102,7 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
|
|
||||||
ParameterMessage::setParameterDumpReply(&reply, id, address);
|
ParameterMessage::setParameterDumpReply(&reply, id, address);
|
||||||
|
|
||||||
@ -126,8 +125,7 @@ ReturnValue_t ParameterHelper::initialize() {
|
|||||||
|
|
||||||
void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
|
void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
|
||||||
Command_t initialCommand) {
|
Command_t initialCommand) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
reply.setReplyRejected(reason, initialCommand);
|
reply.setReplyRejected(reason, initialCommand);
|
||||||
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
|
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
|
||||||
}
|
}
|
||||||
|
@ -163,8 +163,7 @@ void Fuse::setAllMonitorsToUnchecked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Fuse::checkCommandQueue() {
|
void Fuse::checkCommandQueue() {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return;
|
return;
|
||||||
|
@ -74,8 +74,7 @@ void PowerSensor::setAllMonitorsToUnchecked() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PowerSensor::checkCommandQueue() {
|
void PowerSensor::checkCommandQueue() {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return;
|
return;
|
||||||
|
@ -309,8 +309,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
|
|||||||
break;
|
break;
|
||||||
case ModeSequenceMessage::READ_FREE_SEQUENCE_SLOTS: {
|
case ModeSequenceMessage::READ_FREE_SEQUENCE_SLOTS: {
|
||||||
uint32_t freeSlots = modeSequences.maxSize() - modeSequences.size();
|
uint32_t freeSlots = modeSequences.maxSize() - modeSequences.size();
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
ModeSequenceMessage::setModeSequenceMessage(&reply,
|
ModeSequenceMessage::setModeSequenceMessage(&reply,
|
||||||
ModeSequenceMessage::FREE_SEQUENCE_SLOTS, freeSlots);
|
ModeSequenceMessage::FREE_SEQUENCE_SLOTS, freeSlots);
|
||||||
commandQueue->reply(&reply);
|
commandQueue->reply(&reply);
|
||||||
@ -318,8 +317,7 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
|
|||||||
break;
|
break;
|
||||||
case ModeSequenceMessage::READ_FREE_TABLE_SLOTS: {
|
case ModeSequenceMessage::READ_FREE_TABLE_SLOTS: {
|
||||||
uint32_t free = modeTables.maxSize() - modeTables.size();
|
uint32_t free = modeTables.maxSize() - modeTables.size();
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
ModeSequenceMessage::setModeSequenceMessage(&reply,
|
ModeSequenceMessage::setModeSequenceMessage(&reply,
|
||||||
ModeSequenceMessage::FREE_TABLE_SLOTS, free);
|
ModeSequenceMessage::FREE_TABLE_SLOTS, free);
|
||||||
commandQueue->reply(&reply);
|
commandQueue->reply(&reply);
|
||||||
@ -332,12 +330,11 @@ ReturnValue_t Subsystem::handleCommandMessage(CommandMessage* message) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Subsystem::replyToCommand(ReturnValue_t status, uint32_t parameter) {
|
void Subsystem::replyToCommand(ReturnValue_t status, uint32_t parameter) {
|
||||||
MessageQueueMessage message;
|
|
||||||
if (status == RETURN_OK) {
|
if (status == RETURN_OK) {
|
||||||
CommandMessage reply(&message, CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
CommandMessage reply(CommandMessage::REPLY_COMMAND_OK, 0, 0);
|
||||||
commandQueue->reply(&reply);
|
commandQueue->reply(&reply);
|
||||||
} else {
|
} else {
|
||||||
CommandMessage reply(&message, CommandMessage::REPLY_REJECTED, status, 0);
|
CommandMessage reply(CommandMessage::REPLY_REJECTED, status, 0);
|
||||||
commandQueue->reply(&reply);
|
commandQueue->reply(&reply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -620,8 +617,7 @@ void Subsystem::sendSerializablesAsCommandMessage(Command_t command,
|
|||||||
for (uint8_t i = 0; i < count; i++) {
|
for (uint8_t i = 0; i < count; i++) {
|
||||||
elements[i]->serialize(&storeBuffer, &size, maxSize, true);
|
elements[i]->serialize(&storeBuffer, &size, maxSize, true);
|
||||||
}
|
}
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
ModeSequenceMessage::setModeSequenceMessage(&reply, command, address);
|
ModeSequenceMessage::setModeSequenceMessage(&reply, command, address);
|
||||||
if (commandQueue->reply(&reply) != RETURN_OK) {
|
if (commandQueue->reply(&reply) != RETURN_OK) {
|
||||||
IPCStore->deleteData(address);
|
IPCStore->deleteData(address);
|
||||||
|
@ -77,8 +77,7 @@ ReturnValue_t SubsystemBase::checkStateAgainstTable(
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submode_t targetSubmode) {
|
void SubsystemBase::executeTable(HybridIterator<ModeListEntry> tableIter, Submode_t targetSubmode) {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
|
|
||||||
std::map<object_id_t, ChildInfo>::iterator iter;
|
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
|
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(
|
ReturnValue_t result = commandQueue->sendMessage(
|
||||||
iter->second.commandQueue, &message);
|
iter->second.commandQueue, &command);
|
||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
++commandsOutstanding;
|
++commandsOutstanding;
|
||||||
}
|
}
|
||||||
@ -297,8 +296,7 @@ void SubsystemBase::setToExternalControl() {
|
|||||||
void SubsystemBase::announceMode(bool recursive) {
|
void SubsystemBase::announceMode(bool recursive) {
|
||||||
triggerEvent(MODE_INFO, mode, submode);
|
triggerEvent(MODE_INFO, mode, submode);
|
||||||
if (recursive) {
|
if (recursive) {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
ModeMessage::setModeMessage(&command,
|
ModeMessage::setModeMessage(&command,
|
||||||
ModeMessage::CMD_MODE_ANNOUNCE_RECURSIVELY, 0, 0);
|
ModeMessage::CMD_MODE_ANNOUNCE_RECURSIVELY, 0, 0);
|
||||||
commandAllChildren(&command);
|
commandAllChildren(&command);
|
||||||
@ -307,8 +305,7 @@ void SubsystemBase::announceMode(bool recursive) {
|
|||||||
|
|
||||||
void SubsystemBase::checkCommandQueue() {
|
void SubsystemBase::checkCommandQueue() {
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
|
|
||||||
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
|
for (result = commandQueue->receiveMessage(&command); result == RETURN_OK;
|
||||||
result = commandQueue->receiveMessage(&command)) {
|
result = commandQueue->receiveMessage(&command)) {
|
||||||
@ -330,8 +327,7 @@ void SubsystemBase::checkCommandQueue() {
|
|||||||
|
|
||||||
result = handleCommandMessage(&command);
|
result = handleCommandMessage(&command);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND,
|
reply.setReplyRejected(CommandMessage::UNKNOWN_COMMAND,
|
||||||
command.getCommand());
|
command.getCommand());
|
||||||
replyToCommand(&reply);
|
replyToCommand(&reply);
|
||||||
|
@ -44,8 +44,7 @@ ReturnValue_t AbstractTemperatureSensor::performHealthOp() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void AbstractTemperatureSensor::handleCommandQueue() {
|
void AbstractTemperatureSensor::handleCommandQueue() {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
result = healthHelper.handleHealthCommand(&command);
|
result = healthHelper.handleHealthCommand(&command);
|
||||||
@ -57,7 +56,7 @@ void AbstractTemperatureSensor::handleCommandQueue() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
command.setToUnknownCommand();
|
command.setToUnknownCommand();
|
||||||
commandQueue->reply(&message);
|
commandQueue->reply(&command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,8 +279,7 @@ ReturnValue_t Heater::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Heater::handleQueue() {
|
void Heater::handleQueue() {
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
ReturnValue_t result = commandQueue->receiveMessage(&command);
|
||||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||||
result = healthHelper.handleHealthCommand(&command);
|
result = healthHelper.handleHealthCommand(&command);
|
||||||
|
@ -76,28 +76,18 @@ ReturnValue_t CommandingServiceBase::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CommandingServiceBase::handleCommandQueue() {
|
void CommandingServiceBase::handleCommandQueue() {
|
||||||
MessageQueueMessage message;
|
CommandMessage reply;
|
||||||
CommandMessage reply(&message);
|
|
||||||
ReturnValue_t result = RETURN_FAILED;
|
ReturnValue_t result = RETURN_FAILED;
|
||||||
for (result = commandQueue->receiveMessage(&reply); result == RETURN_OK;
|
for (result = commandQueue->receiveMessage(&reply); result == RETURN_OK;
|
||||||
result = commandQueue->receiveMessage(&reply)) {
|
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);
|
handleCommandMessage(&reply);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CommandingServiceBase::handleCommandMessage(CommandMessageIF* reply) {
|
void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
|
||||||
bool isStep = false;
|
bool isStep = false;
|
||||||
MessageQueueMessage message;
|
CommandMessage nextCommand;
|
||||||
CommandMessage nextCommand(&message);
|
|
||||||
CommandMapIter iter = commandMap.find(reply->getSender());
|
CommandMapIter iter = commandMap.find(reply->getSender());
|
||||||
|
|
||||||
// handle unrequested reply first
|
// handle unrequested reply first
|
||||||
@ -303,8 +293,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
|||||||
void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
||||||
CommandMapIter iter) {
|
CommandMapIter iter) {
|
||||||
ReturnValue_t result = RETURN_OK;
|
ReturnValue_t result = RETURN_OK;
|
||||||
MessageQueueMessage message;
|
CommandMessage command;
|
||||||
CommandMessage command(&message);
|
|
||||||
iter->subservice = storedPacket->getSubService();
|
iter->subservice = storedPacket->getSubService();
|
||||||
result = prepareCommand(&command, iter->subservice,
|
result = prepareCommand(&command, iter->subservice,
|
||||||
storedPacket->getApplicationData(),
|
storedPacket->getApplicationData(),
|
||||||
@ -316,7 +305,7 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
|||||||
case RETURN_OK:
|
case RETURN_OK:
|
||||||
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
||||||
sendResult = commandQueue->sendMessage(iter.value->first,
|
sendResult = commandQueue->sendMessage(iter.value->first,
|
||||||
&message);
|
&command);
|
||||||
}
|
}
|
||||||
if (sendResult == RETURN_OK) {
|
if (sendResult == RETURN_OK) {
|
||||||
Clock::getUptime(&iter->uptimeOfStart);
|
Clock::getUptime(&iter->uptimeOfStart);
|
||||||
@ -338,7 +327,7 @@ void CommandingServiceBase::startExecution(TcPacketStored *storedPacket,
|
|||||||
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
||||||
//Fire-and-forget command.
|
//Fire-and-forget command.
|
||||||
sendResult = commandQueue->sendMessage(iter.value->first,
|
sendResult = commandQueue->sendMessage(iter.value->first,
|
||||||
&message);
|
&command);
|
||||||
}
|
}
|
||||||
if (sendResult == RETURN_OK) {
|
if (sendResult == RETURN_OK) {
|
||||||
verificationReporter.sendSuccessReport(TC_VERIFY::START_SUCCESS,
|
verificationReporter.sendSuccessReport(TC_VERIFY::START_SUCCESS,
|
||||||
@ -384,9 +373,8 @@ void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter iter) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void CommandingServiceBase::handleUnrequestedReply(CommandMessageIF* reply) {
|
void CommandingServiceBase::handleUnrequestedReply(CommandMessage* reply) {
|
||||||
CommandMessage commandReply(reply->getInternalMessage());
|
reply->clear();
|
||||||
commandReply.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ protected:
|
|||||||
* @param objectId Target object ID
|
* @param objectId Target object ID
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
virtual ReturnValue_t prepareCommand(CommandMessageIF *message,
|
virtual ReturnValue_t prepareCommand(CommandMessage* message,
|
||||||
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
|
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
|
||||||
uint32_t *state, object_id_t objectId) = 0;
|
uint32_t *state, object_id_t objectId) = 0;
|
||||||
|
|
||||||
@ -168,9 +168,9 @@ protected:
|
|||||||
* a failure verification message with the reason as the error parameter
|
* a failure verification message with the reason as the error parameter
|
||||||
* and the initial command as failure parameter 1.
|
* 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,
|
Command_t previousCommand, uint32_t *state,
|
||||||
CommandMessageIF *optionalNextCommand, object_id_t objectId,
|
CommandMessage* optionalNextCommand, object_id_t objectId,
|
||||||
bool *isStep) = 0;
|
bool *isStep) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,7 +182,7 @@ protected:
|
|||||||
* Reply which is non-const so the default implementation can clear the
|
* Reply which is non-const so the default implementation can clear the
|
||||||
* message.
|
* message.
|
||||||
*/
|
*/
|
||||||
virtual void handleUnrequestedReply(CommandMessageIF *reply);
|
virtual void handleUnrequestedReply(CommandMessage* reply);
|
||||||
|
|
||||||
virtual void doPeriodicOperation();
|
virtual void doPeriodicOperation();
|
||||||
|
|
||||||
@ -310,7 +310,7 @@ private:
|
|||||||
|
|
||||||
void startExecution(TcPacketStored *storedPacket, CommandMapIter iter);
|
void startExecution(TcPacketStored *storedPacket, CommandMapIter iter);
|
||||||
|
|
||||||
void handleCommandMessage(CommandMessageIF* reply);
|
void handleCommandMessage(CommandMessage* reply);
|
||||||
void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter,
|
void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter,
|
||||||
CommandMessageIF* nextCommand,CommandMessageIF* reply, bool& isStep);
|
CommandMessageIF* nextCommand,CommandMessageIF* reply, bool& isStep);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user