WIP: somethings wrong.. #19

Closed
muellerr wants to merge 808 commits from source/master into master
5 changed files with 74 additions and 70 deletions
Showing only changes of commit af24cc7d04 - Show all commits

View File

@ -17,12 +17,12 @@ CommandMessage::CommandMessage(Command_t command, uint32_t parameter1,
Command_t CommandMessage::getCommand() const {
Command_t command;
std::memcpy(&command, getData(), sizeof(Command_t));
std::memcpy(&command, MessageQueueMessage::getData(), sizeof(Command_t));
return command;
}
void CommandMessage::setCommand(Command_t command) {
std::memcpy(getData(), &command, sizeof(Command_t));
std::memcpy(MessageQueueMessage::getData(), &command, sizeof(Command_t));
}
uint8_t CommandMessage::getMessageType() const {
@ -32,23 +32,23 @@ uint8_t CommandMessage::getMessageType() const {
uint32_t CommandMessage::getParameter() const {
uint32_t parameter1;
std::memcpy(&parameter1, MessageQueueMessage::getData(), sizeof(parameter1));
std::memcpy(&parameter1, this->getData(), sizeof(parameter1));
return parameter1;
}
void CommandMessage::setParameter(uint32_t parameter1) {
std::memcpy(MessageQueueMessage::getData(), &parameter1, sizeof(parameter1));
std::memcpy(this->getData(), &parameter1, sizeof(parameter1));
}
uint32_t CommandMessage::getParameter2() const {
uint32_t parameter2;
std::memcpy(&parameter2, MessageQueueMessage::getData() + sizeof(uint32_t),
std::memcpy(&parameter2, this->getData() + sizeof(uint32_t),
sizeof(parameter2));
return parameter2;
}
void CommandMessage::setParameter2(uint32_t parameter2) {
std::memcpy(MessageQueueMessage::getData() + sizeof(uint32_t), &parameter2,
std::memcpy(this->getData() + sizeof(uint32_t), &parameter2,
sizeof(parameter2));
}
@ -87,3 +87,11 @@ ReturnValue_t CommandMessage::getReplyRejectedReason(
}
return reason;
}
uint8_t* CommandMessage::getData() {
return MessageQueueMessage::getData() + sizeof(Command_t);
}
const uint8_t* CommandMessage::getData() const {
return MessageQueueMessage::getData() + sizeof(Command_t);
}

View File

@ -50,6 +50,22 @@ public:
*/
virtual ~CommandMessage() {}
/**
* 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);
virtual uint8_t* getData() override;
virtual const uint8_t* getData() const override;
/**
* Get the first parameter of the message
* @return the first Parameter of the message
@ -105,20 +121,6 @@ public:
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.

View File

@ -9,34 +9,34 @@
#include <framework/tmstorage/TmStoreMessage.h>
#include <framework/parameters/ParameterMessage.h>
void CommandMessageCleaner::clearCommandMessage(CommandMessageIF* message) {
void CommandMessageCleaner::clearCommandMessage(CommandMessage* message) {
switch(message->getMessageType()){
case messagetypes::MODE_COMMAND:
ModeMessage::clear(dynamic_cast<CommandMessage*>(message));
ModeMessage::clear(message);
break;
case messagetypes::HEALTH_COMMAND:
HealthMessage::clear(dynamic_cast<CommandMessage*>(message));
HealthMessage::clear(message);
break;
case messagetypes::MODE_SEQUENCE:
ModeSequenceMessage::clear(dynamic_cast<CommandMessage*>(message));
ModeSequenceMessage::clear(message);
break;
case messagetypes::ACTION:
ActionMessage::clear(dynamic_cast<CommandMessage*>(message));
ActionMessage::clear(message);
break;
case messagetypes::DEVICE_HANDLER_COMMAND:
DeviceHandlerMessage::clear(dynamic_cast<CommandMessage*>(message));
DeviceHandlerMessage::clear(message);
break;
case messagetypes::MEMORY:
MemoryMessage::clear(dynamic_cast<CommandMessage*>(message));
MemoryMessage::clear(message);
break;
case messagetypes::MONITORING:
MonitoringMessage::clear(dynamic_cast<CommandMessage*>(message));
MonitoringMessage::clear(message);
break;
case messagetypes::TM_STORE:
TmStoreMessage::clear(dynamic_cast<CommandMessage*>(message));
TmStoreMessage::clear(message);
break;
case messagetypes::PARAMETER:
ParameterMessage::clear(dynamic_cast<CommandMessage*>(message));
ParameterMessage::clear(message);
break;
default:
messagetypes::clearMissionMessage(message);

View File

@ -1,15 +1,15 @@
#ifndef FRAMEWORK_IPC_COMMANDMESSAGECLEANER_H_
#define FRAMEWORK_IPC_COMMANDMESSAGECLEANER_H_
#include <framework/ipc/CommandMessageIF.h>
#include <framework/ipc/CommandMessage.h>
namespace messagetypes {
// Implemented in config.
void clearMissionMessage(CommandMessageIF* message);
void clearMissionMessage(CommandMessage* message);
}
class CommandMessageCleaner {
public:
static void clearCommandMessage(CommandMessageIF* message);
static void clearCommandMessage(CommandMessage* message);
};

View File

@ -80,12 +80,6 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message,
}
ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
if(message->getMessageSize() < maxMessageSize) {
sif::error << "MessageQueue::receiveMessage: Message size "
<< message->getMessageSize() <<
" too small to receive data!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
BaseType_t result = xQueueReceive(handle,reinterpret_cast<void*>(
message->getBuffer()), 0);
if (result == pdPASS){