Merge remote-tracking branch 'upstream/master' into mueller_MessageNamespaceRenamed
This commit is contained in:
@ -5,15 +5,15 @@
|
||||
* @author baetz
|
||||
*/
|
||||
|
||||
#include <framework/devicehandlers/DeviceHandlerMessage.h>
|
||||
#include <framework/health/HealthMessage.h>
|
||||
#include <framework/ipc/CommandMessage.h>
|
||||
#include <framework/memory/MemoryMessage.h>
|
||||
#include <framework/modes/ModeMessage.h>
|
||||
#include <framework/monitoring/MonitoringMessage.h>
|
||||
#include <framework/subsystem/modes/ModeSequenceMessage.h>
|
||||
#include <framework/tmstorage/TmStoreMessage.h>
|
||||
#include <framework/parameters/ParameterMessage.h>
|
||||
#include "../devicehandlers/DeviceHandlerMessage.h"
|
||||
#include "../health/HealthMessage.h"
|
||||
#include "CommandMessage.h"
|
||||
#include "../memory/MemoryMessage.h"
|
||||
#include "../modes/ModeMessage.h"
|
||||
#include "../monitoring/MonitoringMessage.h"
|
||||
#include "../subsystem/modes/ModeSequenceMessage.h"
|
||||
#include "../tmstorage/TmStoreMessage.h"
|
||||
#include "../parameters/ParameterMessage.h"
|
||||
|
||||
namespace messagetypes {
|
||||
void clearMissionMessage(CommandMessage* message);
|
||||
@ -111,7 +111,7 @@ size_t CommandMessage::getMinimumMessageSize() const {
|
||||
void CommandMessage::setToUnknownCommand() {
|
||||
Command_t initialCommand = getCommand();
|
||||
clearCommandMessage();
|
||||
setReplyRejected(UNKNOW_COMMAND, initialCommand);
|
||||
setReplyRejected(UNKNOWN_COMMAND, initialCommand);
|
||||
}
|
||||
|
||||
void CommandMessage::setReplyRejected(ReturnValue_t reason,
|
||||
@ -120,3 +120,12 @@ void CommandMessage::setReplyRejected(ReturnValue_t reason,
|
||||
setParameter(reason);
|
||||
setParameter2(initialCommand);
|
||||
}
|
||||
|
||||
ReturnValue_t CommandMessage::getReplyRejectedReason(
|
||||
Command_t *initialCommand) const {
|
||||
ReturnValue_t reason = getParameter();
|
||||
if(initialCommand != nullptr) {
|
||||
*initialCommand = getParameter2();
|
||||
}
|
||||
return reason;
|
||||
}
|
||||
|
@ -9,10 +9,10 @@
|
||||
#define COMMANDMESSAGE_H_
|
||||
|
||||
|
||||
#include <framework/ipc/FwMessageTypes.h>
|
||||
#include "FwMessageTypes.h"
|
||||
#include <config/ipc/MissionMessageTypes.h>
|
||||
|
||||
#include <framework/ipc/MessageQueueMessage.h>
|
||||
#include "MessageQueueMessage.h"
|
||||
|
||||
#define MAKE_COMMAND_ID( number ) ((MESSAGE_ID << 8) + (number))
|
||||
typedef ReturnValue_t Command_t;
|
||||
@ -20,7 +20,7 @@ typedef ReturnValue_t Command_t;
|
||||
class CommandMessage : public MessageQueueMessage {
|
||||
public:
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_MESSAGE;
|
||||
static const ReturnValue_t UNKNOW_COMMAND = MAKE_RETURN_CODE(0x01);
|
||||
static const ReturnValue_t UNKNOWN_COMMAND = MAKE_RETURN_CODE(0x01);
|
||||
|
||||
|
||||
static const uint8_t MESSAGE_ID = messagetypes::COMMAND;
|
||||
@ -124,6 +124,9 @@ public:
|
||||
*/
|
||||
void setToUnknownCommand();
|
||||
void setReplyRejected(ReturnValue_t reason, Command_t initialCommand = CMD_NONE);
|
||||
ReturnValue_t getReplyRejectedReason(
|
||||
Command_t *initialCommand = nullptr) const;
|
||||
|
||||
size_t getMinimumMessageSize() const;
|
||||
};
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
|
||||
// COULDDO: We could support blocking calls
|
||||
|
||||
#include <framework/ipc/MessageQueueMessage.h>
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include "MessageQueueMessage.h"
|
||||
#include "MessageQueueSenderIF.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
class MessageQueueIF {
|
||||
public:
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include <framework/ipc/MessageQueueMessage.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "MessageQueueMessage.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef MESSAGEQUEUEMESSAGE_H_
|
||||
#define MESSAGEQUEUEMESSAGE_H_
|
||||
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
#include "MessageQueueSenderIF.h"
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_
|
||||
#define FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_
|
||||
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
class MessageQueueMessage;
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef FRAMEWORK_IPC_MUTEXFACTORY_H_
|
||||
#define FRAMEWORK_IPC_MUTEXFACTORY_H_
|
||||
|
||||
#include <framework/ipc/MutexIF.h>
|
||||
#include "MutexIF.h"
|
||||
/**
|
||||
* Creates Mutex.
|
||||
* This class is a "singleton" interface, i.e. it provides an
|
||||
|
@ -1,20 +1,26 @@
|
||||
#ifndef FRAMEWORK_IPC_MUTEXHELPER_H_
|
||||
#define FRAMEWORK_IPC_MUTEXHELPER_H_
|
||||
|
||||
#include <framework/ipc/MutexFactory.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include "MutexFactory.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
class MutexHelper {
|
||||
public:
|
||||
MutexHelper(MutexIF* mutex, uint32_t timeoutMs) :
|
||||
MutexHelper(MutexIF* mutex, MutexIF::TimeoutType timeoutType =
|
||||
MutexIF::TimeoutType::BLOCKING, uint32_t timeoutMs = 0) :
|
||||
internalMutex(mutex) {
|
||||
ReturnValue_t status = mutex->lockMutex(timeoutMs);
|
||||
if(status != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "MutexHelper: Lock of Mutex failed " << status << std::endl;
|
||||
ReturnValue_t status = mutex->lockMutex(timeoutType,
|
||||
timeoutMs);
|
||||
if(status == MutexIF::MUTEX_TIMEOUT) {
|
||||
sif::error << "MutexHelper: Lock of mutex failed with timeout of "
|
||||
<< timeoutMs << " milliseconds!" << std::endl;
|
||||
}
|
||||
else if(status != HasReturnvaluesIF::RETURN_OK){
|
||||
sif::error << "MutexHelper: Lock of Mutex failed with code " <<
|
||||
status << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
~MutexHelper() {
|
||||
internalMutex->unlockMutex();
|
||||
}
|
||||
|
@ -1,11 +1,35 @@
|
||||
#ifndef FRAMEWORK_IPC_MUTEXIF_H_
|
||||
#define FRAMEWORK_IPC_MUTEXIF_H_
|
||||
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
/**
|
||||
* @brief Common interface for OS Mutex objects which provide MUTual EXclusion.
|
||||
* @details https://en.wikipedia.org/wiki/Lock_(computer_science)
|
||||
* @ingroup osal
|
||||
* @ingroup interface
|
||||
*/
|
||||
class MutexIF {
|
||||
public:
|
||||
static const uint32_t NO_TIMEOUT; //!< Needs to be defined in implementation.
|
||||
/**
|
||||
* Different types of timeout for the mutex lock.
|
||||
*/
|
||||
enum TimeoutType {
|
||||
POLLING, //!< If mutex is not available, return immediately
|
||||
WAITING, //!< Wait a specified time for the mutex to become available
|
||||
BLOCKING //!< Block indefinitely until the mutex becomes available.
|
||||
};
|
||||
|
||||
/**
|
||||
* Lock the mutex. The timeout value will only be used for
|
||||
* TimeoutType::WAITING
|
||||
* @param timeoutType
|
||||
* @param timeoutMs
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t lockMutex(TimeoutType timeoutType =
|
||||
TimeoutType::BLOCKING, uint32_t timeoutMs = 0) = 0;
|
||||
virtual ReturnValue_t unlockMutex() = 0;
|
||||
|
||||
static const uint8_t INTERFACE_ID = CLASS_ID::MUTEX_IF;
|
||||
/**
|
||||
@ -57,9 +81,7 @@ public:
|
||||
*/
|
||||
static const ReturnValue_t MUTEX_DESTROYED_WHILE_WAITING = MAKE_RETURN_CODE(12);
|
||||
|
||||
virtual ~MutexIF() {}
|
||||
virtual ReturnValue_t lockMutex(uint32_t timeoutMs) = 0;
|
||||
virtual ReturnValue_t unlockMutex() = 0;
|
||||
virtual ~MutexIF() {}
|
||||
};
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef FRAMEWORK_IPC_QUEUEFACTORY_H_
|
||||
#define FRAMEWORK_IPC_QUEUEFACTORY_H_
|
||||
|
||||
#include <framework/ipc/MessageQueueIF.h>
|
||||
#include "MessageQueueIF.h"
|
||||
#include <stdint.h>
|
||||
/**
|
||||
* Creates message queues.
|
||||
@ -18,8 +18,8 @@ public:
|
||||
*/
|
||||
static QueueFactory* instance();
|
||||
|
||||
MessageQueueIF* createMessageQueue(uint32_t message_depth = 3,
|
||||
uint32_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
MessageQueueIF* createMessageQueue(uint32_t messageDepth = 3,
|
||||
size_t maxMessageSize = MessageQueueMessage::MAX_MESSAGE_SIZE);
|
||||
|
||||
void deleteMessageQueue(MessageQueueIF* queue);
|
||||
private:
|
||||
|
Reference in New Issue
Block a user