thoughts on message queuee message
new interface. What if there are MQ messages with different sizes? -> generic interface furthermore, maybe command message should be refactored to operate on a mq message instead of implementing it
This commit is contained in:
parent
2649fa1507
commit
4c41456ddf
@ -41,7 +41,7 @@ ReturnValue_t LocalDataPoolManager::initializeHousekeepingPoolEntriesOnce() {
|
||||
}
|
||||
|
||||
ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
||||
CommandMessage *message) {
|
||||
MessageQueueMessage *message) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
LocalDataPoolManager operator=(const LocalDataPoolManager&) = delete;
|
||||
|
||||
ReturnValue_t generateHousekeepingPacket(sid_t sid);
|
||||
ReturnValue_t handleHousekeepingMessage(CommandMessage* message);
|
||||
ReturnValue_t handleHousekeepingMessage(MessageQueueMessage* message);
|
||||
|
||||
/**
|
||||
* This function is used to fill the local data pool map with pool
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <framework/datapoolglob/GlobalPoolVariable.h>
|
||||
#include <framework/devicehandlers/DeviceTmReportingWrapper.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <framework/housekeeping/HousekeepingMessage.h>
|
||||
#include <framework/ipc/MessageQueueMessage.h>
|
||||
#include <framework/subsystem/SubsystemBase.h>
|
||||
#include <framework/ipc/QueueFactory.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
@ -36,7 +38,7 @@ DeviceHandlerBase::DeviceHandlerBase(object_id_t setObjectId,
|
||||
transitionSourceMode(_MODE_POWER_DOWN), transitionSourceSubMode(
|
||||
SUBMODE_NONE), deviceSwitch(setDeviceSwitch) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(cmdQueueSize,
|
||||
CommandMessage::MAX_MESSAGE_SIZE);
|
||||
MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
insertInCommandMap(RAW_COMMAND_ID);
|
||||
cookieInfo.state = COOKIE_UNUSED;
|
||||
cookieInfo.pendingCommand = deviceCommandMap.end();
|
||||
@ -212,40 +214,59 @@ void DeviceHandlerBase::readCommandQueue() {
|
||||
return;
|
||||
}
|
||||
|
||||
CommandMessage message;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&message);
|
||||
// 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.
|
||||
CommandMessage cmdMessage;
|
||||
ReturnValue_t result = commandQueue->receiveMessage(&cmdMessage);
|
||||
if (result != RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
// This is really annoying. I can't cast a parent object to a child.
|
||||
// But I want to use another message format..
|
||||
// CommandMessage* cmdMessage = dynamic_cast<CommandMessage*>(msgPtr);
|
||||
// if(cmdMessage == nullptr) {
|
||||
// sif::error << "DeviceHandlerBase::readCommandQueue: Could not cast"
|
||||
// " message to CommandMessage!" << std::endl;
|
||||
// return;
|
||||
// }
|
||||
|
||||
if(healthHelperActive) {
|
||||
result = healthHelper.handleHealthCommand(&message);
|
||||
result = healthHelper.handleHealthCommand(&cmdMessage);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
result = modeHelper.handleModeCommand(&message);
|
||||
result = modeHelper.handleModeCommand(&cmdMessage);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
result = actionHelper.handleActionMessage(&message);
|
||||
result = actionHelper.handleActionMessage(&cmdMessage);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
result = parameterHelper.handleParameterMessage(&message);
|
||||
result = parameterHelper.handleParameterMessage(&cmdMessage);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
result = handleDeviceHandlerMessage(&message);
|
||||
// HousekeepingMessage* hkMessage = dynamic_cast<HousekeepingMessage*>(msgPtr);
|
||||
// result = hkManager.handleHousekeepingMessage(hkMessage);
|
||||
// if (result == RETURN_OK) {
|
||||
// return;
|
||||
// }
|
||||
|
||||
result = handleDeviceHandlerMessage(&cmdMessage);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
result = letChildHandleMessage(&message);
|
||||
result = letChildHandleMessage(&cmdMessage);
|
||||
if (result == RETURN_OK) {
|
||||
return;
|
||||
}
|
||||
|
@ -1,5 +1,13 @@
|
||||
#include <framework/housekeeping/HousekeepingMessage.h>
|
||||
|
||||
HousekeepingMessage::HousekeepingMessage() {
|
||||
|
||||
}
|
||||
|
||||
void HousekeepingMessage::setHkReportMessage() {
|
||||
}
|
||||
|
||||
|
||||
//void HousekeepingMessage::setAddHkReportStructMessage(CommandMessage *message,
|
||||
// set_t setId, store_address_t packet) {
|
||||
// message->setCommand(ADD_HK_REPORT_STRUCT);
|
||||
|
@ -5,12 +5,14 @@
|
||||
#include <limits>
|
||||
|
||||
union sid_t {
|
||||
static constexpr uint64_t INVALID_ADDRESS = std::numeric_limits<uint64_t>::max();
|
||||
static constexpr uint64_t INVALID_ADDRESS =
|
||||
std::numeric_limits<uint64_t>::max();
|
||||
sid_t(): raw(INVALID_ADDRESS) {}
|
||||
|
||||
struct {
|
||||
object_id_t objectId ;
|
||||
// A generic 32 bit ID to identify unique HK packets for a single object.
|
||||
// A generic 32 bit ID to identify unique HK packets for a single
|
||||
// object.
|
||||
// For example, the DeviceCommandId_t is used for DeviceHandlers
|
||||
uint32_t ownerSetId;
|
||||
};
|
||||
@ -19,15 +21,17 @@ union sid_t {
|
||||
*/
|
||||
uint64_t raw;
|
||||
};
|
||||
class HousekeepingMessage {
|
||||
|
||||
|
||||
class HousekeepingMessage: public MessageQueueMessage {
|
||||
public:
|
||||
/**
|
||||
* No instances of a message shall be created, instead
|
||||
* a CommandMessage instance is manipulated.
|
||||
*/
|
||||
HousekeepingMessage() = delete;
|
||||
HousekeepingMessage(const HousekeepingMessage&) = delete;
|
||||
HousekeepingMessage operator=(const HousekeepingMessage &) = delete;
|
||||
HousekeepingMessage();
|
||||
// HousekeepingMessage(const HousekeepingMessage&) = delete;
|
||||
// HousekeepingMessage operator=(const HousekeepingMessage &) = delete;
|
||||
|
||||
static constexpr uint8_t MESSAGE_ID = MESSAGE_TYPE::HOUSEKEEPING;
|
||||
static constexpr Command_t ADD_HK_REPORT_STRUCT =
|
||||
@ -76,6 +80,7 @@ public:
|
||||
|
||||
// static void setAddHkReportStructMessage(CommandMessage* message,
|
||||
// DevisetId, store_address_t packet);
|
||||
static void setHkReportMessage();
|
||||
};
|
||||
|
||||
|
||||
|
@ -28,7 +28,8 @@ public:
|
||||
static const Command_t REPLY_REJECTED = MAKE_COMMAND_ID( 0xD1 );
|
||||
|
||||
/**
|
||||
* This is the size of a message as it is seen by the MessageQueue
|
||||
* This is the size of a message as it is seen by the MessageQueue.
|
||||
* 14 of the 24 available MessageQueueMessage bytes are used.
|
||||
*/
|
||||
static const size_t COMMAND_MESSAGE_SIZE = HEADER_SIZE
|
||||
+ sizeof(Command_t) + 2 * sizeof(uint32_t);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef MESSAGEQUEUEMESSAGE_H_
|
||||
#define MESSAGEQUEUEMESSAGE_H_
|
||||
|
||||
#include <framework/ipc/MessageQueueMessageIF.h>
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@ -23,7 +24,7 @@
|
||||
* receive messages from other tasks.
|
||||
* @ingroup message_queue
|
||||
*/
|
||||
class MessageQueueMessage {
|
||||
class MessageQueueMessage: public MessageQueueMessageIF {
|
||||
public:
|
||||
/**
|
||||
* @brief The class is initialized empty with this constructor.
|
||||
@ -43,6 +44,7 @@ public:
|
||||
* MAX_MESSAGE_SIZE and larger than MIN_MESSAGE_SIZE.
|
||||
*/
|
||||
MessageQueueMessage(uint8_t* data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief The size information of each message is stored in this attribute.
|
||||
* @details
|
||||
|
44
ipc/MessageQueueMessageIF.h
Normal file
44
ipc/MessageQueueMessageIF.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
|
||||
#define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
#include <cstddef>
|
||||
|
||||
class MessageQueueMessageIF {
|
||||
public:
|
||||
virtual ~MessageQueueMessageIF() {};
|
||||
|
||||
/**
|
||||
* @brief With this method, the whole content and the message
|
||||
* size is set to zero.
|
||||
*/
|
||||
virtual void clear() = 0;
|
||||
/**
|
||||
* @brief This is a debug method that prints the content
|
||||
* (till messageSize) to the debug output.
|
||||
*/
|
||||
virtual void print() = 0;
|
||||
virtual const uint8_t* getBuffer() const = 0;
|
||||
/**
|
||||
* @brief This method is used to get the complete data of the message.
|
||||
*/
|
||||
virtual uint8_t* getBuffer() = 0;
|
||||
/**
|
||||
* @brief This method is used to set the sender's message queue id
|
||||
* information prior to sending the message.
|
||||
* @param setId The message queue id that identifies the sending message queue.
|
||||
*/
|
||||
virtual void setSender(MessageQueueId_t setId) = 0;
|
||||
/**
|
||||
* @brief This helper function is used by the MessageQueue class to
|
||||
* check the size of an incoming message.
|
||||
* @details
|
||||
* The method must be overwritten by child classes if size checks shall
|
||||
* be more strict.
|
||||
* @return The default implementation returns HEADER_SIZE.
|
||||
*/
|
||||
virtual size_t getMinimumMessageSize() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ */
|
Loading…
Reference in New Issue
Block a user