Merge remote-tracking branch 'origin/mueller/master' into tompert/devel
This commit is contained in:
commit
967d4964f1
13
CHANGELOG
13
CHANGELOG
@ -1,3 +1,16 @@
|
||||
## Changes from ASTP 1.0.0 to 1.1.0
|
||||
|
||||
### PUS
|
||||
|
||||
- Added PUS C support
|
||||
|
||||
### Configuration
|
||||
|
||||
- Additional configuration option fsfwconfig::FSFW_MAX_TM_PACKET_SIZE which
|
||||
need to be specified in FSFWConfig.h
|
||||
|
||||
|
||||
|
||||
## Changes from ASTP 0.0.1 to 1.0.0
|
||||
|
||||
### Host OSAL
|
||||
|
@ -18,6 +18,13 @@ add_library(${LIB_FSFW_NAME})
|
||||
|
||||
set_property(CACHE OS_FSFW PROPERTY STRINGS host linux rtems freertos)
|
||||
|
||||
if(NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED True)
|
||||
elseif(${CMAKE_CXX_STANDARD} LESS 11)
|
||||
message(FATAL_ERROR "Compiling the FSFW requires a minimum of C++11 support")
|
||||
endif()
|
||||
|
||||
if(NOT OS_FSFW)
|
||||
message(STATUS "No OS for FSFW via OS_FSFW set. Assuming host OS")
|
||||
# Assume host OS and autodetermine from OS_FSFW
|
||||
@ -131,9 +138,9 @@ else()
|
||||
)
|
||||
endif()
|
||||
|
||||
foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATH})
|
||||
foreach(INCLUDE_PATH ${FSFW_ADDITIONAL_INC_PATHS})
|
||||
if(IS_ABSOLUTE ${INCLUDE_PATH})
|
||||
set(CURR_ABS_INC_PATH "${FREERTOS_PATH}")
|
||||
set(CURR_ABS_INC_PATH "${INCLUDE_PATH}")
|
||||
else()
|
||||
get_filename_component(CURR_ABS_INC_PATH
|
||||
${INCLUDE_PATH} REALPATH BASE_DIR ${CMAKE_SOURCE_DIR})
|
||||
|
7
FSFW.h
Normal file
7
FSFW.h
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef FSFW_FSFW_H_
|
||||
#define FSFW_FSFW_H_
|
||||
|
||||
#include "FSFWConfig.h"
|
||||
|
||||
|
||||
#endif /* FSFW_FSFW_H_ */
|
@ -2,7 +2,7 @@
|
||||
#include "HasActionsIF.h"
|
||||
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
|
||||
ActionHelper::ActionHelper(HasActionsIF* setOwner,
|
||||
@ -25,7 +25,7 @@ ReturnValue_t ActionHelper::handleActionMessage(CommandMessage* command) {
|
||||
}
|
||||
|
||||
ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "ActionMessage.h"
|
||||
#include "HasActionsIF.h"
|
||||
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
|
||||
ActionMessage::ActionMessage() {
|
||||
@ -69,7 +69,7 @@ void ActionMessage::clear(CommandMessage* message) {
|
||||
switch(message->getCommand()) {
|
||||
case EXECUTE_ACTION:
|
||||
case DATA_REPLY: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
StorageManagerIF *ipcStore = ObjectManager::instance()->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
ipcStore->deleteData(getStoreId(message));
|
||||
|
@ -2,7 +2,8 @@
|
||||
#include "CommandActionHelper.h"
|
||||
#include "CommandsActionsIF.h"
|
||||
#include "HasActionsIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
CommandActionHelper::CommandActionHelper(CommandsActionsIF *setOwner) :
|
||||
owner(setOwner), queueToUse(NULL), ipcStore(
|
||||
@ -14,7 +15,7 @@ CommandActionHelper::~CommandActionHelper() {
|
||||
|
||||
ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo,
|
||||
ActionId_t actionId, SerializeIF *data) {
|
||||
HasActionsIF *receiver = objectManager->get<HasActionsIF>(commandTo);
|
||||
HasActionsIF *receiver = ObjectManager::instance()->get<HasActionsIF>(commandTo);
|
||||
if (receiver == NULL) {
|
||||
return CommandsActionsIF::OBJECT_HAS_NO_FUNCTIONS;
|
||||
}
|
||||
@ -40,7 +41,7 @@ ReturnValue_t CommandActionHelper::commandAction(object_id_t commandTo,
|
||||
// if (commandCount != 0) {
|
||||
// return CommandsFunctionsIF::ALREADY_COMMANDING;
|
||||
// }
|
||||
HasActionsIF *receiver = objectManager->get<HasActionsIF>(commandTo);
|
||||
HasActionsIF *receiver = ObjectManager::instance()->get<HasActionsIF>(commandTo);
|
||||
if (receiver == NULL) {
|
||||
return CommandsActionsIF::OBJECT_HAS_NO_FUNCTIONS;
|
||||
}
|
||||
@ -66,7 +67,7 @@ ReturnValue_t CommandActionHelper::sendCommand(MessageQueueId_t queueId,
|
||||
}
|
||||
|
||||
ReturnValue_t CommandActionHelper::initialize() {
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../action/HasActionsIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
ControllerBase::ControllerBase(object_id_t setObjectId, object_id_t parentId,
|
||||
size_t commandQueueDepth) :
|
||||
@ -25,7 +26,7 @@ ReturnValue_t ControllerBase::initialize() {
|
||||
|
||||
MessageQueueId_t parentQueue = 0;
|
||||
if (parentId != objects::NO_OBJECT) {
|
||||
SubsystemBase *parent = objectManager->get<SubsystemBase>(parentId);
|
||||
SubsystemBase *parent = ObjectManager::instance()->get<SubsystemBase>(parentId);
|
||||
if (parent == nullptr) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
@ -66,6 +66,10 @@ protected:
|
||||
virtual ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) override = 0;
|
||||
virtual LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override = 0;
|
||||
|
||||
// Mode abstract functions
|
||||
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||
uint32_t *msToReachTheMode) override = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -19,7 +19,8 @@ class VirtualChannelReception;
|
||||
class DataLinkLayer : public CCSDSReturnValuesIF {
|
||||
public:
|
||||
static const uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::SYSTEM_1;
|
||||
static const Event RF_AVAILABLE = MAKE_EVENT(0, severity::INFO); //!< A RF available signal was detected. P1: raw RFA state, P2: 0
|
||||
//! [EXPORT] : [COMMENT] A RF available signal was detected. P1: raw RFA state, P2: 0
|
||||
static const Event RF_AVAILABLE = MAKE_EVENT(0, severity::INFO);
|
||||
static const Event RF_LOST = MAKE_EVENT(1, severity::INFO); //!< A previously found RF available signal was lost. P1: raw RFA state, P2: 0
|
||||
static const Event BIT_LOCK = MAKE_EVENT(2, severity::INFO); //!< A Bit Lock signal. Was detected. P1: raw BLO state, P2: 0
|
||||
static const Event BIT_LOCK_LOST = MAKE_EVENT(3, severity::INFO); //!< A previously found Bit Lock signal was lost. P1: raw BLO state, P2: 0
|
||||
|
@ -1,10 +1,13 @@
|
||||
#include "MapPacketExtraction.h"
|
||||
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../tmtcpacket/SpacePacketBase.h"
|
||||
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||
#include "../tmtcservices/TmTcMessage.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
MapPacketExtraction::MapPacketExtraction(uint8_t setMapId,
|
||||
@ -131,9 +134,9 @@ void MapPacketExtraction::clearBuffers() {
|
||||
}
|
||||
|
||||
ReturnValue_t MapPacketExtraction::initialize() {
|
||||
packetStore = objectManager->get<StorageManagerIF>(objects::TC_STORE);
|
||||
AcceptsTelecommandsIF* distributor = objectManager->get<
|
||||
AcceptsTelecommandsIF>(packetDestination);
|
||||
packetStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||
AcceptsTelecommandsIF* distributor = ObjectManager::instance()->
|
||||
get<AcceptsTelecommandsIF>(packetDestination);
|
||||
if ((packetStore != NULL) && (distributor != NULL)) {
|
||||
tcQueueId = distributor->getRequestQueue();
|
||||
return RETURN_OK;
|
||||
|
@ -34,7 +34,8 @@ class LocalPoolObjectBase;
|
||||
* can be retrieved using the object manager, provided the target object is a SystemObject.
|
||||
* For example, the following line of code can be used to retrieve the interface
|
||||
*
|
||||
* HasLocalDataPoolIF* poolIF = objectManager->get<HasLocalDataPoolIF>(objects::SOME_OBJECT);
|
||||
* HasLocalDataPoolIF* poolIF = ObjectManager::instance()->
|
||||
* get<HasLocalDataPoolIF>(objects::SOME_OBJECT);
|
||||
* if(poolIF != nullptr) {
|
||||
* doSomething()
|
||||
* }
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "internal/HasLocalDpIFManagerAttorney.h"
|
||||
|
||||
#include "../housekeeping/HousekeepingSetPacket.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../housekeeping/HousekeepingSnapshot.h"
|
||||
#include "../housekeeping/AcceptsHkPacketsIF.h"
|
||||
#include "../timemanager/CCSDSTime.h"
|
||||
@ -52,7 +53,7 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
|
||||
}
|
||||
hkQueue = queueToUse;
|
||||
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if(ipcStore == nullptr) {
|
||||
/* Error, all destinations invalid */
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR,
|
||||
@ -63,8 +64,8 @@ ReturnValue_t LocalDataPoolManager::initialize(MessageQueueIF* queueToUse) {
|
||||
|
||||
|
||||
if(defaultHkDestination != objects::NO_OBJECT) {
|
||||
AcceptsHkPacketsIF* hkPacketReceiver =
|
||||
objectManager->get<AcceptsHkPacketsIF>(defaultHkDestination);
|
||||
AcceptsHkPacketsIF* hkPacketReceiver = ObjectManager::instance()->
|
||||
get<AcceptsHkPacketsIF>(defaultHkDestination);
|
||||
if(hkPacketReceiver != nullptr) {
|
||||
hkDestinationId = hkPacketReceiver->getHkQueue();
|
||||
}
|
||||
@ -360,8 +361,8 @@ void LocalDataPoolManager::resetHkUpdateResetHelper() {
|
||||
ReturnValue_t LocalDataPoolManager::subscribeForPeriodicPacket(sid_t sid,
|
||||
bool enableReporting, float collectionInterval, bool isDiagnostics,
|
||||
object_id_t packetDestination) {
|
||||
AcceptsHkPacketsIF* hkReceiverObject =
|
||||
objectManager->get<AcceptsHkPacketsIF>(packetDestination);
|
||||
AcceptsHkPacketsIF* hkReceiverObject = ObjectManager::instance()->
|
||||
get<AcceptsHkPacketsIF>(packetDestination);
|
||||
if(hkReceiverObject == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"subscribeForPeriodicPacket", QUEUE_OR_DESTINATION_INVALID);
|
||||
@ -391,7 +392,7 @@ ReturnValue_t LocalDataPoolManager::subscribeForUpdatePacket(sid_t sid,
|
||||
bool isDiagnostics, bool reportingEnabled,
|
||||
object_id_t packetDestination) {
|
||||
AcceptsHkPacketsIF* hkReceiverObject =
|
||||
objectManager->get<AcceptsHkPacketsIF>(packetDestination);
|
||||
ObjectManager::instance()->get<AcceptsHkPacketsIF>(packetDestination);
|
||||
if(hkReceiverObject == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING,
|
||||
"subscribeForPeriodicPacket", QUEUE_OR_DESTINATION_INVALID);
|
||||
@ -554,6 +555,11 @@ ReturnValue_t LocalDataPoolManager::handleHousekeepingMessage(
|
||||
case(HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT):
|
||||
case(HousekeepingMessage::GENERATE_ONE_DIAGNOSTICS_REPORT): {
|
||||
LocalPoolDataSetBase* dataSet = HasLocalDpIFManagerAttorney::getDataSetHandle(owner, sid);
|
||||
if(dataSet == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_WARNING, "handleHousekeepingMessage",
|
||||
DATASET_NOT_FOUND);
|
||||
return DATASET_NOT_FOUND;
|
||||
}
|
||||
if(command == HousekeepingMessage::GENERATE_ONE_PARAMETER_REPORT
|
||||
and LocalPoolDataSetAttorney::isDiagnostics(*dataSet)) {
|
||||
result = WRONG_HK_PACKET_TYPE;
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "internal/HasLocalDpIFUserAttorney.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../globalfunctions/bitutility.h"
|
||||
#include "../datapoollocal/LocalDataPoolManager.h"
|
||||
#include "../housekeeping/PeriodicHousekeepingHelper.h"
|
||||
@ -45,7 +46,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner,
|
||||
LocalPoolDataSetBase::LocalPoolDataSetBase(sid_t sid, PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxNumberOfVariables):
|
||||
PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(
|
||||
HasLocalDataPoolIF* hkOwner = ObjectManager::instance()->get<HasLocalDataPoolIF>(
|
||||
sid.objectId);
|
||||
if(hkOwner != nullptr) {
|
||||
AccessPoolManagerIF* accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "HasLocalDataPoolIF.h"
|
||||
#include "internal/HasLocalDpIFUserAttorney.h"
|
||||
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
|
||||
LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
|
||||
@ -43,7 +43,7 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
|
||||
"which is the NO_PARAMETER value!\n");
|
||||
#endif
|
||||
}
|
||||
HasLocalDataPoolIF* hkOwner = objectManager->get<HasLocalDataPoolIF>(poolOwner);
|
||||
HasLocalDataPoolIF* hkOwner = ObjectManager::instance()->get<HasLocalDataPoolIF>(poolOwner);
|
||||
if(hkOwner == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPoolVariable: The supplied pool owner did not implement the correct "
|
||||
|
@ -18,6 +18,7 @@
|
||||
#endif
|
||||
|
||||
#define FSFW_USE_PUS_C_TELEMETRY 1
|
||||
#define FSFW_USE_PUS_C_TELECOMMANDS 1
|
||||
|
||||
//! Can be used to disable the ANSI color sequences for C stdio.
|
||||
#define FSFW_COLORED_OUTPUT 1
|
||||
@ -67,6 +68,8 @@ static constexpr uint8_t FSFW_CSB_FIFO_DEPTH = 6;
|
||||
|
||||
static constexpr size_t FSFW_PRINT_BUFFER_SIZE = 124;
|
||||
|
||||
static constexpr size_t FSFW_MAX_TM_PACKET_SIZE = 2048;
|
||||
|
||||
}
|
||||
|
||||
#endif /* CONFIG_FSFWCONFIG_H_ */
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "ChildHandlerBase.h"
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
|
||||
ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId,
|
||||
object_id_t deviceCommunication, CookieIF * cookie,
|
||||
@ -30,7 +29,7 @@ ReturnValue_t ChildHandlerBase::initialize() {
|
||||
MessageQueueId_t parentQueue = 0;
|
||||
|
||||
if (parentId != objects::NO_OBJECT) {
|
||||
SubsystemBase *parent = objectManager->get<SubsystemBase>(parentId);
|
||||
SubsystemBase *parent = ObjectManager::instance()->get<SubsystemBase>(parentId);
|
||||
if (parent == NULL) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
communicationInterface = objectManager->get<DeviceCommunicationIF>(
|
||||
communicationInterface = ObjectManager::instance()->get<DeviceCommunicationIF>(
|
||||
deviceCommunicationId);
|
||||
if (communicationInterface == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize",
|
||||
@ -136,7 +136,7 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (IPCStore == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize",
|
||||
ObjectManagerIF::CHILD_INIT_FAILED, "IPC Store not set up");
|
||||
@ -144,8 +144,8 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
}
|
||||
|
||||
if(rawDataReceiverId != objects::NO_OBJECT) {
|
||||
AcceptsDeviceResponsesIF *rawReceiver = objectManager->get<
|
||||
AcceptsDeviceResponsesIF>(rawDataReceiverId);
|
||||
AcceptsDeviceResponsesIF *rawReceiver = ObjectManager::instance()->
|
||||
get<AcceptsDeviceResponsesIF>(rawDataReceiverId);
|
||||
|
||||
if (rawReceiver == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR,
|
||||
@ -164,7 +164,7 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
}
|
||||
|
||||
if(powerSwitcherId != objects::NO_OBJECT) {
|
||||
powerSwitcher = objectManager->get<PowerSwitchIF>(powerSwitcherId);
|
||||
powerSwitcher = ObjectManager::instance()->get<PowerSwitchIF>(powerSwitcherId);
|
||||
if (powerSwitcher == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR,
|
||||
"initialize", ObjectManagerIF::CHILD_INIT_FAILED,
|
||||
@ -226,16 +226,15 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::decrementDeviceReplyMap() {
|
||||
for (std::map<DeviceCommandId_t, DeviceReplyInfo>::iterator iter =
|
||||
deviceReplyMap.begin(); iter != deviceReplyMap.end(); iter++) {
|
||||
if (iter->second.delayCycles != 0) {
|
||||
iter->second.delayCycles--;
|
||||
if (iter->second.delayCycles == 0) {
|
||||
if (iter->second.periodic) {
|
||||
iter->second.delayCycles = iter->second.maxDelayCycles;
|
||||
for (std::pair<const DeviceCommandId_t, DeviceReplyInfo>& replyPair: deviceReplyMap) {
|
||||
if (replyPair.second.delayCycles != 0) {
|
||||
replyPair.second.delayCycles--;
|
||||
if (replyPair.second.delayCycles == 0) {
|
||||
if (replyPair.second.periodic) {
|
||||
replyPair.second.delayCycles = replyPair.second.maxDelayCycles;
|
||||
}
|
||||
replyToReply(iter, TIMEOUT);
|
||||
missedReply(iter->first);
|
||||
replyToReply(replyPair.first, replyPair.second, TIMEOUT);
|
||||
missedReply(replyPair.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -584,17 +583,28 @@ void DeviceHandlerBase::replyToCommand(ReturnValue_t status,
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter,
|
||||
void DeviceHandlerBase::replyToReply(const DeviceCommandId_t command, DeviceReplyInfo& replyInfo,
|
||||
ReturnValue_t status) {
|
||||
// No need to check if iter exists, as this is checked by callers.
|
||||
// If someone else uses the method, add check.
|
||||
if (iter->second.command == deviceCommandMap.end()) {
|
||||
if (replyInfo.command == deviceCommandMap.end()) {
|
||||
//Is most likely periodic reply. Silent return.
|
||||
return;
|
||||
}
|
||||
DeviceCommandInfo* info = &replyInfo.command->second;
|
||||
if (info == nullptr){
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR,
|
||||
"replyToReply", HasReturnvaluesIF::RETURN_FAILED,
|
||||
"Command pointer not found");
|
||||
return;
|
||||
}
|
||||
|
||||
if (info->expectedReplies > 0){
|
||||
// Check before to avoid underflow
|
||||
info->expectedReplies--;
|
||||
}
|
||||
// Check if more replies are expected. If so, do nothing.
|
||||
DeviceCommandInfo* info = &(iter->second.command->second);
|
||||
if (--info->expectedReplies == 0) {
|
||||
if (info->expectedReplies == 0) {
|
||||
// Check if it was transition or internal command.
|
||||
// Don't send any replies in that case.
|
||||
if (info->sendReplyTo != NO_COMMANDER) {
|
||||
@ -602,7 +612,7 @@ void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter,
|
||||
if(status == HasReturnvaluesIF::RETURN_OK) {
|
||||
success = true;
|
||||
}
|
||||
actionHelper.finish(success, info->sendReplyTo, iter->first, status);
|
||||
actionHelper.finish(success, info->sendReplyTo, command, status);
|
||||
}
|
||||
info->isExecuting = false;
|
||||
}
|
||||
@ -801,7 +811,7 @@ void DeviceHandlerBase::handleReply(const uint8_t* receivedData,
|
||||
replyRawReplyIfnotWiretapped(receivedData, foundLen);
|
||||
triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result, foundId);
|
||||
}
|
||||
replyToReply(iter, result);
|
||||
replyToReply(iter->first, iter->second, result);
|
||||
}
|
||||
else {
|
||||
/* Other completion failure messages are created by timeout.
|
||||
|
@ -667,7 +667,7 @@ protected:
|
||||
static const ReturnValue_t CHILD_TIMEOUT = MAKE_RETURN_CODE(0xE0);
|
||||
static const ReturnValue_t SWITCH_FAILED = MAKE_RETURN_CODE(0xE1);
|
||||
|
||||
static const MessageQueueId_t NO_COMMANDER = 0;
|
||||
static const MessageQueueId_t NO_COMMANDER = MessageQueueIF::NO_QUEUE;
|
||||
|
||||
//! Pointer to the raw packet that will be sent.
|
||||
uint8_t *rawPacket = nullptr;
|
||||
@ -1195,7 +1195,8 @@ private:
|
||||
* @foundLen the length of the packet
|
||||
*/
|
||||
void handleReply(const uint8_t *data, DeviceCommandId_t id, uint32_t foundLen);
|
||||
void replyToReply(DeviceReplyMap::iterator iter, ReturnValue_t status);
|
||||
void replyToReply(const DeviceCommandId_t command, DeviceReplyInfo& replyInfo,
|
||||
ReturnValue_t status);
|
||||
|
||||
/**
|
||||
* Build and send a command to the device.
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "DeviceHandlerFailureIsolation.h"
|
||||
|
||||
#include "../devicehandlers/DeviceHandlerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../modes/HasModesIF.h"
|
||||
#include "../health/HealthTableIF.h"
|
||||
#include "../power/Fuse.h"
|
||||
@ -175,7 +176,7 @@ ReturnValue_t DeviceHandlerFailureIsolation::initialize() {
|
||||
#endif
|
||||
return result;
|
||||
}
|
||||
ConfirmsFailuresIF* power = objectManager->get<ConfirmsFailuresIF>(
|
||||
ConfirmsFailuresIF* power = ObjectManager::instance()->get<ConfirmsFailuresIF>(
|
||||
powerConfirmationId);
|
||||
if (power != nullptr) {
|
||||
powerConfirmation = power->getEventReceptionQueue();
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "DeviceHandlerMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
store_address_t DeviceHandlerMessage::getStoreAddress(
|
||||
const CommandMessage* message) {
|
||||
@ -70,7 +70,7 @@ void DeviceHandlerMessage::clear(CommandMessage* message) {
|
||||
case REPLY_RAW_COMMAND:
|
||||
case REPLY_RAW_REPLY:
|
||||
case REPLY_DIRECT_COMMAND_DATA: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
StorageManagerIF *ipcStore = ObjectManager::instance()->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != nullptr) {
|
||||
ipcStore->deleteData(getStoreAddress(message));
|
||||
|
@ -156,11 +156,11 @@ void EventManager::printUtility(sif::OutputTypes printType, EventMessage *messag
|
||||
sif::info << "0x" << std::hex << std::setw(8) << std::setfill('0') <<
|
||||
message->getReporter() << std::setfill(' ') << std::dec;
|
||||
}
|
||||
sif::info << " report event with ID " << message->getEventId() << std::endl;
|
||||
sif::info << std::hex << "P1 Hex: 0x" << message->getParameter1() <<
|
||||
" | P1 Dec: " << std::dec << message->getParameter1() << std::hex <<
|
||||
" | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " << std::dec <<
|
||||
message->getParameter2() << std::endl;
|
||||
sif::info << " reported event with ID " << message->getEventId() << std::endl;
|
||||
sif::debug << translateEvents(message->getEvent()) << " | " <<std::hex << "P1 Hex: 0x" <<
|
||||
message->getParameter1() << " | P1 Dec: " << std::dec << message->getParameter1() <<
|
||||
std::hex << " | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " <<
|
||||
std::dec << message->getParameter2() << std::endl;
|
||||
#else
|
||||
if (string != 0) {
|
||||
sif::printInfo("Event Manager: %s reported event with ID %d\n", string,
|
||||
@ -186,11 +186,11 @@ void EventManager::printUtility(sif::OutputTypes printType, EventMessage *messag
|
||||
sif::debug << "0x" << std::hex << std::setw(8) << std::setfill('0') <<
|
||||
message->getReporter() << std::setfill(' ') << std::dec;
|
||||
}
|
||||
sif::debug << " report event with ID " << message->getEventId() << std::endl;
|
||||
sif::debug << std::hex << "P1 Hex: 0x" << message->getParameter1() <<
|
||||
" | P1 Dec: " << std::dec << message->getParameter1() << std::hex <<
|
||||
" | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " << std::dec <<
|
||||
message->getParameter2() << std::endl;
|
||||
sif::debug << " reported event with ID " << message->getEventId() << std::endl;
|
||||
sif::debug << translateEvents(message->getEvent()) << " | " <<std::hex << "P1 Hex: 0x" <<
|
||||
message->getParameter1() << " | P1 Dec: " << std::dec << message->getParameter1() <<
|
||||
std::hex << " | P2 Hex: 0x" << message->getParameter2() << " | P2 Dec: " <<
|
||||
std::dec << message->getParameter2() << std::endl;
|
||||
#else
|
||||
if (string != 0) {
|
||||
sif::printDebug("Event Manager: %s reported event with ID %d\n", string,
|
||||
|
@ -3,8 +3,7 @@
|
||||
|
||||
#include "EventManagerIF.h"
|
||||
#include "eventmatching/EventMatchTree.h"
|
||||
|
||||
#include <FSFWConfig.h>
|
||||
#include "FSFWConfig.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "EventMessage.h"
|
||||
#include "eventmatching/eventmatching.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
@ -43,7 +43,7 @@ public:
|
||||
static void triggerEvent(EventMessage* message,
|
||||
MessageQueueId_t sentFrom = 0) {
|
||||
if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) {
|
||||
EventManagerIF *eventmanager = objectManager->get<EventManagerIF>(
|
||||
EventManagerIF *eventmanager = ObjectManager::instance()->get<EventManagerIF>(
|
||||
objects::EVENT_MANAGER);
|
||||
if (eventmanager == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "../health/HasHealthIF.h"
|
||||
#include "../health/HealthMessage.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
FailureIsolationBase::FailureIsolationBase(object_id_t owner,
|
||||
object_id_t parent, uint8_t messageDepth, uint8_t parameterDomainBase) :
|
||||
@ -18,7 +18,7 @@ FailureIsolationBase::~FailureIsolationBase() {
|
||||
}
|
||||
|
||||
ReturnValue_t FailureIsolationBase::initialize() {
|
||||
EventManagerIF* manager = objectManager->get<EventManagerIF>(
|
||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(
|
||||
objects::EVENT_MANAGER);
|
||||
if (manager == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
@ -36,7 +36,7 @@ ReturnValue_t FailureIsolationBase::initialize() {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
owner = objectManager->get<HasHealthIF>(ownerId);
|
||||
owner = ObjectManager::instance()->get<HasHealthIF>(ownerId);
|
||||
if (owner == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "FailureIsolationBase::intialize: Owner object "
|
||||
@ -46,7 +46,7 @@ ReturnValue_t FailureIsolationBase::initialize() {
|
||||
}
|
||||
}
|
||||
if (faultTreeParent != objects::NO_OBJECT) {
|
||||
ConfirmsFailuresIF* parentIF = objectManager->get<ConfirmsFailuresIF>(
|
||||
ConfirmsFailuresIF* parentIF = ObjectManager::instance()->get<ConfirmsFailuresIF>(
|
||||
faultTreeParent);
|
||||
if (parentIF == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
@ -5,6 +5,15 @@
|
||||
|
||||
void arrayprinter::print(const uint8_t *data, size_t size, OutputType type,
|
||||
bool printInfo, size_t maxCharPerLine) {
|
||||
if(size == 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Size is zero, nothing to print" << std::endl;
|
||||
#else
|
||||
sif::printInfo("Size is zero, nothing to print\n");
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
if(printInfo) {
|
||||
sif::info << "Printing data with size " << size << ": " << std::endl;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "HealthHelper.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
|
||||
HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) :
|
||||
objectId(objectId), owner(owner) {
|
||||
@ -37,8 +37,8 @@ void HealthHelper::setParentQueue(MessageQueueId_t parentQueue) {
|
||||
}
|
||||
|
||||
ReturnValue_t HealthHelper::initialize() {
|
||||
healthTable = objectManager->get<HealthTableIF>(objects::HEALTH_TABLE);
|
||||
eventSender = objectManager->get<EventReportingProxyIF>(objectId);
|
||||
healthTable = ObjectManager::instance()->get<HealthTableIF>(objects::HEALTH_TABLE);
|
||||
eventSender = ObjectManager::instance()->get<EventReportingProxyIF>(objectId);
|
||||
|
||||
if (healthTable == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "HousekeepingMessage.h"
|
||||
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include <cstring>
|
||||
|
||||
HousekeepingMessage::~HousekeepingMessage() {}
|
||||
@ -161,7 +161,7 @@ void HousekeepingMessage::clear(CommandMessage* message) {
|
||||
case(UPDATE_SNAPSHOT_VARIABLE): {
|
||||
store_address_t storeId;
|
||||
getHkDataReply(message, &storeId);
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
StorageManagerIF *ipcStore = ObjectManager::instance()->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != nullptr) {
|
||||
ipcStore->deleteData(storeId);
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "CommandMessageCleaner.h"
|
||||
|
||||
#include "../memory/GenericFileSystemMessage.h"
|
||||
#include "../devicehandlers/DeviceHandlerMessage.h"
|
||||
#include "../health/HealthMessage.h"
|
||||
#include "../memory/MemoryMessage.h"
|
||||
@ -42,6 +43,9 @@ void CommandMessageCleaner::clearCommandMessage(CommandMessage* message) {
|
||||
case messagetypes::HOUSEKEEPING:
|
||||
HousekeepingMessage::clear(message);
|
||||
break;
|
||||
case messagetypes::FILE_SYSTEM_MESSAGE:
|
||||
GenericFileSystemMessage::clear(message);
|
||||
break;
|
||||
default:
|
||||
messagetypes::clearMissionMessage(message);
|
||||
break;
|
||||
|
@ -1,5 +1,5 @@
|
||||
target_sources(${LIB_FSFW_NAME}
|
||||
PRIVATE
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
MemoryHelper.cpp
|
||||
MemoryMessage.cpp
|
||||
GenericFileSystemMessage.cpp
|
||||
)
|
161
memory/GenericFileSystemMessage.cpp
Normal file
161
memory/GenericFileSystemMessage.cpp
Normal file
@ -0,0 +1,161 @@
|
||||
#include "GenericFileSystemMessage.h"
|
||||
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
|
||||
void GenericFileSystemMessage::setCreateFileCommand(CommandMessage* message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(CMD_CREATE_FILE);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setDeleteFileCommand(
|
||||
CommandMessage* message, store_address_t storeId) {
|
||||
message->setCommand(CMD_DELETE_FILE);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setCreateDirectoryCommand(
|
||||
CommandMessage* message, store_address_t storeId) {
|
||||
message->setCommand(CMD_CREATE_DIRECTORY);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setReportFileAttributesCommand(CommandMessage *message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(CMD_REPORT_FILE_ATTRIBUTES);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setReportFileAttributesReply(CommandMessage *message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(REPLY_REPORT_FILE_ATTRIBUTES);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setDeleteDirectoryCommand(CommandMessage* message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(CMD_DELETE_DIRECTORY);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setLockFileCommand(CommandMessage *message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(CMD_LOCK_FILE);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setUnlockFileCommand(CommandMessage *message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(CMD_UNLOCK_FILE);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setSuccessReply(CommandMessage *message) {
|
||||
message->setCommand(COMPLETION_SUCCESS);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setFailureReply(CommandMessage *message,
|
||||
ReturnValue_t errorCode, uint32_t errorParam) {
|
||||
message->setCommand(COMPLETION_FAILED);
|
||||
message->setParameter(errorCode);
|
||||
message->setParameter2(errorParam);
|
||||
}
|
||||
|
||||
store_address_t GenericFileSystemMessage::getStoreId(const CommandMessage* message) {
|
||||
store_address_t temp;
|
||||
temp.raw = message->getParameter2();
|
||||
return temp;
|
||||
}
|
||||
|
||||
ReturnValue_t GenericFileSystemMessage::getFailureReply(
|
||||
const CommandMessage *message, uint32_t* errorParam) {
|
||||
if(errorParam != nullptr) {
|
||||
*errorParam = message->getParameter2();
|
||||
}
|
||||
return message->getParameter();
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setFinishStopWriteCommand(CommandMessage *message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(CMD_FINISH_APPEND_TO_FILE);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setFinishStopWriteReply(CommandMessage *message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(REPLY_FINISH_APPEND);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setCopyCommand(CommandMessage* message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(CMD_COPY_FILE);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setWriteCommand(CommandMessage* message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(CMD_APPEND_TO_FILE);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setReadCommand(CommandMessage* message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(CMD_READ_FROM_FILE);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setFinishAppendReply(CommandMessage* message,
|
||||
store_address_t storageID) {
|
||||
message->setCommand(REPLY_FINISH_APPEND);
|
||||
message->setParameter2(storageID.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setReadReply(CommandMessage* message,
|
||||
bool readFinished, store_address_t storeId) {
|
||||
message->setCommand(REPLY_READ_FROM_FILE);
|
||||
message->setParameter(readFinished);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
void GenericFileSystemMessage::setReadFinishedReply(CommandMessage *message,
|
||||
store_address_t storeId) {
|
||||
message->setCommand(REPLY_READ_FINISHED_STOP);
|
||||
message->setParameter2(storeId.raw);
|
||||
}
|
||||
|
||||
bool GenericFileSystemMessage::getReadReply(const CommandMessage *message,
|
||||
store_address_t *storeId) {
|
||||
if(storeId != nullptr) {
|
||||
(*storeId).raw = message->getParameter2();
|
||||
}
|
||||
return message->getParameter();
|
||||
}
|
||||
|
||||
ReturnValue_t GenericFileSystemMessage::clear(CommandMessage* message) {
|
||||
switch(message->getCommand()) {
|
||||
case(CMD_CREATE_FILE):
|
||||
case(CMD_DELETE_FILE):
|
||||
case(CMD_CREATE_DIRECTORY):
|
||||
case(CMD_REPORT_FILE_ATTRIBUTES):
|
||||
case(REPLY_REPORT_FILE_ATTRIBUTES):
|
||||
case(CMD_LOCK_FILE):
|
||||
case(CMD_UNLOCK_FILE):
|
||||
case(CMD_COPY_FILE):
|
||||
case(REPLY_READ_FROM_FILE):
|
||||
case(CMD_READ_FROM_FILE):
|
||||
case(CMD_APPEND_TO_FILE):
|
||||
case(CMD_FINISH_APPEND_TO_FILE):
|
||||
case(REPLY_READ_FINISHED_STOP):
|
||||
case(REPLY_FINISH_APPEND): {
|
||||
store_address_t storeId = GenericFileSystemMessage::getStoreId(message);
|
||||
auto ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if(ipcStore == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return ipcStore->deleteData(storeId);
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
115
memory/GenericFileSystemMessage.h
Normal file
115
memory/GenericFileSystemMessage.h
Normal file
@ -0,0 +1,115 @@
|
||||
#ifndef MISSION_MEMORY_GENERICFILESYSTEMMESSAGE_H_
|
||||
#define MISSION_MEMORY_GENERICFILESYSTEMMESSAGE_H_
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
#include <fsfw/ipc/CommandMessageIF.h>
|
||||
#include <fsfw/ipc/FwMessageTypes.h>
|
||||
#include <fsfw/ipc/CommandMessage.h>
|
||||
#include <fsfw/storagemanager/storeAddress.h>
|
||||
|
||||
/**
|
||||
* @brief These messages are sent to an object implementing HasFilesystemIF.
|
||||
* @details
|
||||
* Enables a message-based file management. The user can add custo commands be implementing
|
||||
* this generic class.
|
||||
* @author Jakob Meier, R. Mueller
|
||||
*/
|
||||
class GenericFileSystemMessage {
|
||||
public:
|
||||
/* Instantiation forbidden */
|
||||
GenericFileSystemMessage() = delete;
|
||||
|
||||
static const uint8_t MESSAGE_ID = messagetypes::FILE_SYSTEM_MESSAGE;
|
||||
/* PUS standard (ECSS-E-ST-70-41C15 2016 p.654) */
|
||||
static const Command_t CMD_CREATE_FILE = MAKE_COMMAND_ID(1);
|
||||
static const Command_t CMD_DELETE_FILE = MAKE_COMMAND_ID(2);
|
||||
/** Report file attributes */
|
||||
static const Command_t CMD_REPORT_FILE_ATTRIBUTES = MAKE_COMMAND_ID(3);
|
||||
static const Command_t REPLY_REPORT_FILE_ATTRIBUTES = MAKE_COMMAND_ID(4);
|
||||
/** Command to lock a file, setting it read-only */
|
||||
static const Command_t CMD_LOCK_FILE = MAKE_COMMAND_ID(5);
|
||||
/** Command to unlock a file, enabling further operations on it */
|
||||
static const Command_t CMD_UNLOCK_FILE = MAKE_COMMAND_ID(6);
|
||||
/**
|
||||
* Find file in repository, using a search pattern.
|
||||
* Please note that * is the wildcard character.
|
||||
* For example, when looking for all files which start with have the
|
||||
* structure tm<something>.bin, tm*.bin can be used.
|
||||
*/
|
||||
static const Command_t CMD_FIND_FILE = MAKE_COMMAND_ID(7);
|
||||
static const Command_t CMD_CREATE_DIRECTORY = MAKE_COMMAND_ID(9);
|
||||
static const Command_t CMD_DELETE_DIRECTORY = MAKE_COMMAND_ID(10);
|
||||
static const Command_t CMD_RENAME_DIRECTORY = MAKE_COMMAND_ID(11);
|
||||
|
||||
/** Dump contents of a repository */
|
||||
static const Command_t CMD_DUMP_REPOSITORY = MAKE_COMMAND_ID(12);
|
||||
/** Repository dump reply */
|
||||
static const Command_t REPLY_DUMY_REPOSITORY = MAKE_COMMAND_ID(13);
|
||||
static constexpr Command_t CMD_COPY_FILE = MAKE_COMMAND_ID(14);
|
||||
static constexpr Command_t CMD_MOVE_FILE = MAKE_COMMAND_ID(15);
|
||||
|
||||
static const Command_t COMPLETION_SUCCESS = MAKE_COMMAND_ID(128);
|
||||
static const Command_t COMPLETION_FAILED = MAKE_COMMAND_ID(129);
|
||||
|
||||
// These command IDs will remain until CFDP has been introduced and consolidated.
|
||||
/** Append operation commands */
|
||||
static const Command_t CMD_APPEND_TO_FILE = MAKE_COMMAND_ID(130);
|
||||
static const Command_t CMD_FINISH_APPEND_TO_FILE = MAKE_COMMAND_ID(131);
|
||||
static const Command_t REPLY_FINISH_APPEND = MAKE_COMMAND_ID(132);
|
||||
|
||||
static const Command_t CMD_READ_FROM_FILE = MAKE_COMMAND_ID(140);
|
||||
static const Command_t REPLY_READ_FROM_FILE = MAKE_COMMAND_ID(141);
|
||||
static const Command_t CMD_STOP_READ = MAKE_COMMAND_ID(142);
|
||||
static const Command_t REPLY_READ_FINISHED_STOP = MAKE_COMMAND_ID(143);
|
||||
|
||||
static void setLockFileCommand(CommandMessage* message, store_address_t storeId);
|
||||
static void setUnlockFileCommand(CommandMessage* message, store_address_t storeId);
|
||||
|
||||
static void setCreateFileCommand(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
static void setDeleteFileCommand(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
|
||||
static void setReportFileAttributesCommand(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
static void setReportFileAttributesReply(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
|
||||
static void setCreateDirectoryCommand(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
static void setDeleteDirectoryCommand(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
|
||||
static void setSuccessReply(CommandMessage* message);
|
||||
static void setFailureReply(CommandMessage* message,
|
||||
ReturnValue_t errorCode, uint32_t errorParam = 0);
|
||||
static void setCopyCommand(CommandMessage* message, store_address_t storeId);
|
||||
|
||||
static void setWriteCommand(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
static void setFinishStopWriteCommand(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
static void setFinishStopWriteReply(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
static void setFinishAppendReply(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
|
||||
static void setReadCommand(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
static void setReadFinishedReply(CommandMessage* message,
|
||||
store_address_t storeId);
|
||||
static void setReadReply(CommandMessage* message, bool readFinished,
|
||||
store_address_t storeId);
|
||||
static bool getReadReply(const CommandMessage* message,
|
||||
store_address_t* storeId);
|
||||
|
||||
static store_address_t getStoreId(const CommandMessage* message);
|
||||
static ReturnValue_t getFailureReply(const CommandMessage* message,
|
||||
uint32_t* errorParam = nullptr);
|
||||
|
||||
static ReturnValue_t clear(CommandMessage* message);
|
||||
|
||||
};
|
||||
|
||||
#endif /* MISSION_MEMORY_GENERICFILESYSTEMMESSAGE_H_ */
|
@ -2,9 +2,9 @@
|
||||
#include "MemoryMessage.h"
|
||||
|
||||
#include "../globalfunctions/CRC.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../serialize/EndianConverter.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
|
||||
MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis,
|
||||
MessageQueueIF* useThisQueue):
|
||||
@ -187,7 +187,7 @@ ReturnValue_t MemoryHelper::initialize(MessageQueueIF* queueToUse_) {
|
||||
}
|
||||
|
||||
ReturnValue_t MemoryHelper::initialize() {
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore != nullptr) {
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "MemoryMessage.h"
|
||||
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
uint32_t MemoryMessage::getAddress(const CommandMessage* message) {
|
||||
return message->getParameter();
|
||||
@ -44,7 +44,7 @@ void MemoryMessage::clear(CommandMessage* message) {
|
||||
switch (message->getCommand()) {
|
||||
case CMD_MEMORY_LOAD:
|
||||
case REPLY_MEMORY_DUMP: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
StorageManagerIF *ipcStore = ObjectManager::instance()->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
ipcStore->deleteData(getStoreID(message));
|
||||
|
@ -1,13 +1,8 @@
|
||||
/**
|
||||
* @file LimitViolationReporter.cpp
|
||||
* @brief This file defines the LimitViolationReporter class.
|
||||
* @date 17.07.2014
|
||||
* @author baetz
|
||||
*/
|
||||
#include "LimitViolationReporter.h"
|
||||
#include "MonitoringIF.h"
|
||||
#include "ReceivesMonitoringReportsIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
|
||||
ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF* data) {
|
||||
@ -16,7 +11,7 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF
|
||||
return result;
|
||||
}
|
||||
store_address_t storeId;
|
||||
uint8_t* dataTarget = NULL;
|
||||
uint8_t* dataTarget = nullptr;
|
||||
size_t maxSize = data->getSerializedSize();
|
||||
if (maxSize > MonitoringIF::VIOLATION_REPORT_MAX_SIZE) {
|
||||
return MonitoringIF::INVALID_SIZE;
|
||||
@ -38,16 +33,16 @@ ReturnValue_t LimitViolationReporter::sendLimitViolationReport(const SerializeIF
|
||||
|
||||
ReturnValue_t LimitViolationReporter::checkClassLoaded() {
|
||||
if (reportQueue == 0) {
|
||||
ReceivesMonitoringReportsIF* receiver = objectManager->get<
|
||||
ReceivesMonitoringReportsIF* receiver = ObjectManager::instance()->get<
|
||||
ReceivesMonitoringReportsIF>(reportingTarget);
|
||||
if (receiver == NULL) {
|
||||
if (receiver == nullptr) {
|
||||
return ObjectManagerIF::NOT_FOUND;
|
||||
}
|
||||
reportQueue = receiver->getCommandQueue();
|
||||
}
|
||||
if (ipcStore == NULL) {
|
||||
ipcStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore == NULL) {
|
||||
if (ipcStore == nullptr) {
|
||||
ipcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (ipcStore == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
@ -56,5 +51,5 @@ ReturnValue_t LimitViolationReporter::checkClassLoaded() {
|
||||
|
||||
//Lazy initialization.
|
||||
MessageQueueId_t LimitViolationReporter::reportQueue = 0;
|
||||
StorageManagerIF* LimitViolationReporter::ipcStore = NULL;
|
||||
StorageManagerIF* LimitViolationReporter::ipcStore = nullptr;
|
||||
object_id_t LimitViolationReporter::reportingTarget = 0;
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "MonitoringMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
MonitoringMessage::~MonitoringMessage() {
|
||||
}
|
||||
@ -25,7 +25,7 @@ void MonitoringMessage::clear(CommandMessage* message) {
|
||||
message->setCommand(CommandMessage::CMD_NONE);
|
||||
switch (message->getCommand()) {
|
||||
case MonitoringMessage::LIMIT_VIOLATION_REPORT: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
StorageManagerIF *ipcStore = ObjectManager::instance()->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
ipcStore->deleteData(getStoreId(message));
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "MonitoringIF.h"
|
||||
|
||||
#include "../datapoollocal/localPoolDefinitions.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../serialize/SerialBufferAdapter.h"
|
||||
#include "../serialize/SerialFixedArrayListAdapter.h"
|
||||
#include "../serialize/SerializeElement.h"
|
||||
@ -71,7 +71,7 @@ private:
|
||||
}
|
||||
bool checkAndSetStamper() {
|
||||
if (timeStamper == nullptr) {
|
||||
timeStamper = objectManager->get<TimeStamperIF>( timeStamperId );
|
||||
timeStamper = ObjectManager::instance()->get<TimeStamperIF>( timeStamperId );
|
||||
if ( timeStamper == nullptr ) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MonitoringReportContent::checkAndSetStamper: "
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "../datapool/PIDReaderList.h"
|
||||
#include "../health/HealthTableIF.h"
|
||||
#include "../parameters/HasParametersIF.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
|
||||
//SHOULDDO: This is by far not perfect. Could be merged with new Monitor classes. But still, it's over-engineering.
|
||||
@ -64,7 +64,7 @@ public:
|
||||
return result;
|
||||
}
|
||||
ReturnValue_t initialize() {
|
||||
healthTable = objectManager->get<HealthTableIF>(objects::HEALTH_TABLE);
|
||||
healthTable = ObjectManager::instance()->get<HealthTableIF>(objects::HEALTH_TABLE);
|
||||
if (healthTable == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
@ -6,10 +6,22 @@
|
||||
#endif
|
||||
#include <cstdlib>
|
||||
|
||||
ObjectManager::ObjectManager( void (*setProducer)() ):
|
||||
produceObjects(setProducer) {
|
||||
//There's nothing special to do in the constructor.
|
||||
ObjectManager* ObjectManager::objManagerInstance = nullptr;
|
||||
|
||||
ObjectManager* ObjectManager::instance() {
|
||||
if(objManagerInstance == nullptr) {
|
||||
objManagerInstance = new ObjectManager();
|
||||
}
|
||||
return objManagerInstance;
|
||||
}
|
||||
|
||||
void ObjectManager::setObjectFactoryFunction(produce_function_t objFactoryFunc, void *factoryArgs) {
|
||||
this->objectFactoryFunction = objFactoryFunc;
|
||||
this->factoryArgs = factoryArgs;
|
||||
}
|
||||
|
||||
|
||||
ObjectManager::ObjectManager() {}
|
||||
|
||||
|
||||
ObjectManager::~ObjectManager() {
|
||||
@ -28,10 +40,13 @@ ReturnValue_t ObjectManager::insert( object_id_t id, SystemObjectIF* object) {
|
||||
return this->RETURN_OK;
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::insert: Object id " << std::hex
|
||||
<< static_cast<uint32_t>(id) << std::dec
|
||||
<< " is already in use!" << std::endl;
|
||||
sif::error << "Terminating program." << std::endl;
|
||||
sif::error << "ObjectManager::insert: Object ID " << std::hex <<
|
||||
static_cast<uint32_t>(id) << std::dec << " is already in use!" << std::endl;
|
||||
sif::error << "Terminating program" << std::endl;
|
||||
#else
|
||||
sif::printError("ObjectManager::insert: Object ID 0x%08x is already in use!\n",
|
||||
static_cast<unsigned int>(id));
|
||||
sif::printError("Terminating program");
|
||||
#endif
|
||||
//This is very severe and difficult to handle in other places.
|
||||
std::exit(INSERTION_FAILED);
|
||||
@ -66,12 +81,8 @@ SystemObjectIF* ObjectManager::getSystemObject( object_id_t id ) {
|
||||
}
|
||||
}
|
||||
|
||||
ObjectManager::ObjectManager() : produceObjects(nullptr) {
|
||||
|
||||
}
|
||||
|
||||
void ObjectManager::initialize() {
|
||||
if(produceObjects == nullptr) {
|
||||
if(objectFactoryFunction == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::initialize: Passed produceObjects "
|
||||
"functions is nullptr!" << std::endl;
|
||||
@ -80,7 +91,7 @@ void ObjectManager::initialize() {
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
this->produceObjects();
|
||||
objectFactoryFunction(factoryArgs);
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
uint32_t errorCount = 0;
|
||||
for (auto const& it : objectList) {
|
||||
@ -108,9 +119,9 @@ void ObjectManager::initialize() {
|
||||
result = it.second->checkObjectConnections();
|
||||
if ( result != RETURN_OK ) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::ObjectManager: Object " << std::hex <<
|
||||
(int) it.first << " connection check failed with code 0x"
|
||||
<< result << std::dec << std::endl;
|
||||
sif::error << "ObjectManager::ObjectManager: Object 0x" << std::hex <<
|
||||
(int) it.first << " connection check failed with code 0x" << result <<
|
||||
std::dec << std::endl;
|
||||
#endif
|
||||
errorCount++;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "SystemObjectIF.h"
|
||||
#include <map>
|
||||
|
||||
|
||||
/**
|
||||
* @brief This class implements a global object manager.
|
||||
* @details This manager handles a list of available objects with system-wide
|
||||
@ -19,15 +20,32 @@
|
||||
* @author Bastian Baetz
|
||||
*/
|
||||
class ObjectManager : public ObjectManagerIF {
|
||||
private:
|
||||
//comparison?
|
||||
public:
|
||||
|
||||
using produce_function_t = void (*) (void* args);
|
||||
|
||||
/**
|
||||
* @brief This is the map of all initialized objects in the manager.
|
||||
* @details Objects in the List must inherit the SystemObjectIF.
|
||||
* Returns the single instance of TaskFactory.
|
||||
* The implementation of #instance is found in its subclasses.
|
||||
* Thus, we choose link-time variability of the instance.
|
||||
*/
|
||||
std::map<object_id_t, SystemObjectIF*> objectList;
|
||||
static ObjectManager* instance();
|
||||
|
||||
void setObjectFactoryFunction(produce_function_t prodFunc, void* args);
|
||||
|
||||
template <typename T> T* get( object_id_t id );
|
||||
|
||||
/**
|
||||
* @brief In the class's destructor, all objects in the list are deleted.
|
||||
*/
|
||||
virtual ~ObjectManager();
|
||||
ReturnValue_t insert(object_id_t id, SystemObjectIF* object) override;
|
||||
ReturnValue_t remove(object_id_t id) override;
|
||||
void initialize() override;
|
||||
void printList() override;
|
||||
|
||||
protected:
|
||||
SystemObjectIF* getSystemObject( object_id_t id );
|
||||
SystemObjectIF* getSystemObject(object_id_t id) override;
|
||||
/**
|
||||
* @brief This attribute is initialized with the factory function
|
||||
* that creates new objects.
|
||||
@ -36,27 +54,25 @@ protected:
|
||||
* @param The id of the object to be created.
|
||||
* @return Returns a pointer to the newly created object or NULL.
|
||||
*/
|
||||
void (*produceObjects)();
|
||||
public:
|
||||
/**
|
||||
* @brief Apart from setting the producer function, nothing special
|
||||
* happens in the constructor.
|
||||
* @param setProducer A pointer to a factory function.
|
||||
*/
|
||||
ObjectManager( void (*produce)() );
|
||||
produce_function_t objectFactoryFunction = nullptr;
|
||||
void* factoryArgs = nullptr;
|
||||
|
||||
private:
|
||||
ObjectManager();
|
||||
|
||||
/**
|
||||
* @brief In the class's destructor, all objects in the list are deleted.
|
||||
* @brief This is the map of all initialized objects in the manager.
|
||||
* @details Objects in the List must inherit the SystemObjectIF.
|
||||
*/
|
||||
// SHOULDDO: If, for some reason, deleting an ObjectManager instance is
|
||||
// required, check if this works.
|
||||
virtual ~ObjectManager( void );
|
||||
ReturnValue_t insert( object_id_t id, SystemObjectIF* object );
|
||||
ReturnValue_t remove( object_id_t id );
|
||||
void initialize();
|
||||
void printList();
|
||||
std::map<object_id_t, SystemObjectIF*> objectList;
|
||||
static ObjectManager* objManagerInstance;
|
||||
};
|
||||
|
||||
|
||||
// Documentation can be found in the class method declaration above
|
||||
template <typename T>
|
||||
T* ObjectManager::get( object_id_t id ) {
|
||||
SystemObjectIF* temp = this->getSystemObject(id);
|
||||
return dynamic_cast<T*>(temp);
|
||||
}
|
||||
|
||||
#endif /* FSFW_OBJECTMANAGER_OBJECTMANAGER_H_ */
|
||||
|
@ -8,11 +8,11 @@
|
||||
|
||||
/**
|
||||
* @brief This class provides an interface to the global object manager.
|
||||
* @details This manager handles a list of available objects with system-wide
|
||||
* relevance, such as device handlers, and TM/TC services. They can be
|
||||
* inserted, removed and retrieved from the list. On getting the
|
||||
* object, the call checks if the object implements the requested
|
||||
* interface.
|
||||
* @details
|
||||
* This manager handles a list of available objects with system-wide relevance, such as device
|
||||
* handlers, and TM/TC services. They can be inserted, removed and retrieved from the list.
|
||||
* On getting the object, the call checks if the object implements the requested interface.
|
||||
* This interface does not specify a getter function because templates can't be used in interfaces.
|
||||
* @author Bastian Baetz
|
||||
* @ingroup system_objects
|
||||
*/
|
||||
@ -21,7 +21,8 @@ public:
|
||||
static constexpr uint8_t INTERFACE_ID = CLASS_ID::OBJECT_MANAGER_IF;
|
||||
static constexpr ReturnValue_t INSERTION_FAILED = MAKE_RETURN_CODE( 1 );
|
||||
static constexpr ReturnValue_t NOT_FOUND = MAKE_RETURN_CODE( 2 );
|
||||
static constexpr ReturnValue_t CHILD_INIT_FAILED = MAKE_RETURN_CODE( 3 ); //!< Can be used if the initialization of a SystemObject failed.
|
||||
//!< Can be used if the initialization of a SystemObject failed.
|
||||
static constexpr ReturnValue_t CHILD_INIT_FAILED = MAKE_RETURN_CODE( 3 );
|
||||
static constexpr ReturnValue_t INTERNAL_ERR_REPORTER_UNINIT = MAKE_RETURN_CODE( 4 );
|
||||
|
||||
protected:
|
||||
@ -49,22 +50,11 @@ public:
|
||||
* @li RETURN_OK in case the object was successfully inserted
|
||||
*/
|
||||
virtual ReturnValue_t insert( object_id_t id, SystemObjectIF* object ) = 0;
|
||||
/**
|
||||
* @brief With the get call, interfaces of an object can be retrieved in
|
||||
* a type-safe manner.
|
||||
* @details With the template-based call, the object list is searched with the
|
||||
* getSystemObject method and afterwards it is checked, if the object
|
||||
* implements the requested interface (with a dynamic_cast).
|
||||
* @param id The object id of the requested object.
|
||||
* @return The method returns a pointer to an object implementing the
|
||||
* requested interface, or NULL.
|
||||
*/
|
||||
template <typename T> T* get( object_id_t id );
|
||||
/**
|
||||
* @brief With this call, an object is removed from the list.
|
||||
* @param id The object id of the object to be removed.
|
||||
* @return \li NOT_FOUND in case the object was not found
|
||||
* \li RETURN_OK in case the object was successfully removed
|
||||
* @return @li NOT_FOUND in case the object was not found
|
||||
* @li RETURN_OK in case the object was successfully removed
|
||||
*/
|
||||
virtual ReturnValue_t remove( object_id_t id ) = 0;
|
||||
virtual void initialize() = 0;
|
||||
@ -75,24 +65,4 @@ public:
|
||||
virtual void printList() = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @brief This is the forward declaration of the global objectManager instance.
|
||||
*/
|
||||
// SHOULDDO: maybe put this in the glob namespace to explicitely mark it global?
|
||||
extern ObjectManagerIF *objectManager;
|
||||
|
||||
/*Documentation can be found in the class method declaration above.*/
|
||||
template <typename T>
|
||||
T* ObjectManagerIF::get( object_id_t id ) {
|
||||
if(objectManager == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManagerIF: Global object manager has not "
|
||||
"been initialized yet!" << std::endl;
|
||||
#endif
|
||||
}
|
||||
SystemObjectIF* temp = this->getSystemObject(id);
|
||||
return dynamic_cast<T*>(temp);
|
||||
}
|
||||
|
||||
#endif /* OBJECTMANAGERIF_H_ */
|
||||
|
@ -5,17 +5,13 @@
|
||||
SystemObject::SystemObject(object_id_t setObjectId, bool doRegister) :
|
||||
objectId(setObjectId), registered(doRegister) {
|
||||
if (registered) {
|
||||
if(objectManager != nullptr) {
|
||||
objectManager->insert(objectId, this);
|
||||
}
|
||||
ObjectManager::instance()->insert(objectId, this);
|
||||
}
|
||||
}
|
||||
|
||||
SystemObject::~SystemObject() {
|
||||
if (registered) {
|
||||
if(objectManager != nullptr) {
|
||||
objectManager->remove(objectId);
|
||||
}
|
||||
ObjectManager::instance()->remove(objectId);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ target_sources(${LIB_FSFW_NAME}
|
||||
TaskFactory.cpp
|
||||
Timekeeper.cpp
|
||||
TaskManagement.cpp
|
||||
QueueMapManager.cpp
|
||||
)
|
||||
|
||||
# FreeRTOS is required to link the FSFW now. It is recommended to compile
|
||||
|
@ -134,71 +134,3 @@ ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) {
|
||||
/ 3600.;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::convertUTCToTT(timeval utc, timeval* tt) {
|
||||
//SHOULDDO: works not for dates in the past (might have less leap seconds)
|
||||
if (timeMutex == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
uint16_t leapSeconds;
|
||||
ReturnValue_t result = getLeapSeconds(&leapSeconds);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
timeval leapSeconds_timeval = { 0, 0 };
|
||||
leapSeconds_timeval.tv_sec = leapSeconds;
|
||||
|
||||
//initial offset between UTC and TAI
|
||||
timeval UTCtoTAI1972 = { 10, 0 };
|
||||
|
||||
timeval TAItoTT = { 32, 184000 };
|
||||
|
||||
*tt = utc + leapSeconds_timeval + UTCtoTAI1972 + TAItoTT;
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
|
||||
if (checkOrCreateClockMutex() != HasReturnvaluesIF::RETURN_OK) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
leapSeconds = leapSeconds_;
|
||||
|
||||
result = timeMutex->unlockMutex();
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
|
||||
if (timeMutex == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
*leapSeconds_ = leapSeconds;
|
||||
|
||||
result = timeMutex->unlockMutex();
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::checkOrCreateClockMutex() {
|
||||
if (timeMutex == NULL) {
|
||||
MutexFactory* mutexFactory = MutexFactory::instance();
|
||||
if (mutexFactory == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
timeMutex = mutexFactory->createMutex();
|
||||
if (timeMutex == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "FixedTimeslotTask.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
uint32_t FixedTimeslotTask::deadlineMissedCount = 0;
|
||||
const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = configMINIMAL_STACK_SIZE;
|
||||
@ -66,8 +67,7 @@ ReturnValue_t FixedTimeslotTask::startTask() {
|
||||
|
||||
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
||||
uint32_t slotTimeMs, int8_t executionStep) {
|
||||
ExecutableObjectIF* handler =
|
||||
objectManager->get<ExecutableObjectIF>(componentId);
|
||||
ExecutableObjectIF* handler = ObjectManager::instance()->get<ExecutableObjectIF>(componentId);
|
||||
if (handler != nullptr) {
|
||||
pst.addSlot(componentId, slotTimeMs, executionStep, handler, this);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
@ -1,27 +1,24 @@
|
||||
#include "MessageQueue.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "QueueMapManager.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
// TODO I guess we should have a way of checking if we are in an ISR and then
|
||||
// use the "fromISR" versions of all calls
|
||||
// As a first step towards this, introduces system context variable which needs
|
||||
// to be switched manually
|
||||
// Haven't found function to find system context.
|
||||
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
|
||||
maxMessageSize(maxMessageSize) {
|
||||
handle = xQueueCreate(messageDepth, maxMessageSize);
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
if (handle == nullptr) {
|
||||
sif::error << "MessageQueue::MessageQueue:"
|
||||
<< " Creation failed." << std::endl;
|
||||
sif::error << "Specified Message Depth: " << messageDepth
|
||||
<< std::endl;
|
||||
sif::error << "Specified Maximum Message Size: "
|
||||
<< maxMessageSize << std::endl;
|
||||
|
||||
}
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::MessageQueue: Creation failed" << std::endl;
|
||||
sif::error << "Specified Message Depth: " << messageDepth << std::endl;
|
||||
sif::error << "Specified Maximum Message Size: " << maxMessageSize << std::endl;
|
||||
#else
|
||||
sif::printError("MessageQueue::MessageQueue: Creation failed\n");
|
||||
sif::printError("Specified Message Depth: %d\n", messageDepth);
|
||||
sif::printError("Specified MAximum Message Size: %d\n", maxMessageSize);
|
||||
#endif
|
||||
}
|
||||
QueueMapManager::instance()->addMessageQueue(handle, &queueId);
|
||||
}
|
||||
|
||||
MessageQueue::~MessageQueue() {
|
||||
if (handle != nullptr) {
|
||||
@ -62,13 +59,15 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo,
|
||||
callContext);
|
||||
}
|
||||
|
||||
QueueHandle_t MessageQueue::getNativeQueueHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault) {
|
||||
if (result != pdPASS) {
|
||||
if (not ignoreFault) {
|
||||
InternalErrorReporterIF* internalErrorReporter = objectManager->
|
||||
get<InternalErrorReporterIF>(
|
||||
objects::INTERNAL_ERROR_REPORTER);
|
||||
InternalErrorReporterIF* internalErrorReporter = ObjectManager::instance()->
|
||||
get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
|
||||
if (internalErrorReporter != nullptr) {
|
||||
internalErrorReporter->queueMessageNotSent();
|
||||
}
|
||||
@ -110,7 +109,7 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) {
|
||||
}
|
||||
|
||||
MessageQueueId_t MessageQueue::getId() const {
|
||||
return reinterpret_cast<MessageQueueId_t>(handle);
|
||||
return queueId;
|
||||
}
|
||||
|
||||
void MessageQueue::setDefaultDestination(MessageQueueId_t defaultDestination) {
|
||||
@ -132,29 +131,24 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
||||
bool ignoreFault, CallContext callContext) {
|
||||
BaseType_t result = pdFALSE;
|
||||
QueueHandle_t destination = nullptr;
|
||||
|
||||
if(sendTo == MessageQueueIF::NO_QUEUE or sendTo == 0x00) {
|
||||
if(sendTo == MessageQueueIF::NO_QUEUE) {
|
||||
return MessageQueueIF::DESTINATION_INVALID;
|
||||
}
|
||||
else {
|
||||
destination = reinterpret_cast<QueueHandle_t>(sendTo);
|
||||
|
||||
QueueHandle_t destination = QueueMapManager::instance()->getMessageQueue(sendTo);
|
||||
if(destination == nullptr) {
|
||||
return MessageQueueIF::DESTINATION_INVALID;
|
||||
}
|
||||
|
||||
message->setSender(sentFrom);
|
||||
|
||||
|
||||
if(callContext == CallContext::TASK) {
|
||||
result = xQueueSendToBack(destination,
|
||||
static_cast<const void*>(message->getBuffer()), 0);
|
||||
result = xQueueSendToBack(destination, static_cast<const void*>(message->getBuffer()), 0);
|
||||
}
|
||||
else {
|
||||
/* If the call context is from an interrupt,
|
||||
* request a context switch if a higher priority task
|
||||
* was blocked by the interrupt. */
|
||||
/* If the call context is from an interrupt, request a context switch if a higher priority
|
||||
task was blocked by the interrupt. */
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
result = xQueueSendFromISR(reinterpret_cast<QueueHandle_t>(sendTo),
|
||||
static_cast<const void*>(message->getBuffer()),
|
||||
result = xQueueSendFromISR(destination, static_cast<const void*>(message->getBuffer()),
|
||||
&xHigherPriorityTaskWoken);
|
||||
if(xHigherPriorityTaskWoken == pdTRUE) {
|
||||
TaskManagement::requestContextSwitch(callContext);
|
||||
|
@ -11,11 +11,6 @@
|
||||
#include <freertos/queue.h>
|
||||
#include <fsfw/ipc/MessageQueueMessage.h>
|
||||
|
||||
// TODO: this class assumes that MessageQueueId_t is the same size as void*
|
||||
// (the FreeRTOS handle type), compiler will catch this but it might be nice
|
||||
// to have something checking or even an always working solution
|
||||
// https://scaryreasoner.wordpress.com/2009/02/28/checking-sizeof-at-compile-time/
|
||||
|
||||
/**
|
||||
* @brief This class manages sending and receiving of
|
||||
* message queue messages.
|
||||
@ -112,6 +107,8 @@ public:
|
||||
|
||||
bool isDefaultDestinationSet() const override;
|
||||
|
||||
QueueHandle_t getNativeQueueHandle();
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @brief Implementation to be called from any send Call within
|
||||
@ -141,6 +138,8 @@ protected:
|
||||
private:
|
||||
bool defaultDestinationSet = false;
|
||||
QueueHandle_t handle;
|
||||
MessageQueueId_t queueId = MessageQueueIF::NO_QUEUE;
|
||||
|
||||
MessageQueueId_t defaultDestination = MessageQueueIF::NO_QUEUE;
|
||||
MessageQueueId_t lastPartner = MessageQueueIF::NO_QUEUE;
|
||||
const size_t maxMessageSize;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "PeriodicTask.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../tasks/ExecutableObjectIF.h"
|
||||
|
||||
PeriodicTask::PeriodicTask(const char *name, TaskPriority setPriority,
|
||||
@ -100,7 +101,7 @@ void PeriodicTask::taskFunctionality() {
|
||||
}
|
||||
|
||||
ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
|
||||
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
||||
ExecutableObjectIF* newObject = ObjectManager::instance()->get<ExecutableObjectIF>(
|
||||
object);
|
||||
if (newObject == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
58
osal/FreeRTOS/QueueMapManager.cpp
Normal file
58
osal/FreeRTOS/QueueMapManager.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
#include "QueueMapManager.h"
|
||||
#include "../../ipc/MutexFactory.h"
|
||||
#include "../../ipc/MutexGuard.h"
|
||||
|
||||
QueueMapManager* QueueMapManager::mqManagerInstance = nullptr;
|
||||
|
||||
QueueMapManager::QueueMapManager() {
|
||||
mapLock = MutexFactory::instance()->createMutex();
|
||||
}
|
||||
|
||||
QueueMapManager* QueueMapManager::instance() {
|
||||
if (mqManagerInstance == nullptr){
|
||||
mqManagerInstance = new QueueMapManager();
|
||||
}
|
||||
return QueueMapManager::mqManagerInstance;
|
||||
}
|
||||
|
||||
ReturnValue_t QueueMapManager::addMessageQueue(QueueHandle_t queue, MessageQueueId_t* id) {
|
||||
MutexGuard lock(mapLock);
|
||||
uint32_t currentId = queueCounter++;
|
||||
auto returnPair = queueMap.emplace(currentId, queue);
|
||||
if(not returnPair.second) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "QueueMapManager::addMessageQueue This ID is already "
|
||||
"inside the map!" << std::endl;
|
||||
#else
|
||||
sif::printError("QueueMapManager::addMessageQueue This ID is already "
|
||||
"inside the map!\n");
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (id != nullptr) {
|
||||
*id = currentId;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
||||
}
|
||||
|
||||
QueueHandle_t QueueMapManager::getMessageQueue(MessageQueueId_t messageQueueId) const {
|
||||
auto queueIter = queueMap.find(messageQueueId);
|
||||
if(queueIter != queueMap.end()) {
|
||||
return queueIter->second;
|
||||
}
|
||||
else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "QueueMapManager::getQueueHandle: The ID " << messageQueueId <<
|
||||
" does not exists in the map!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("QueueMapManager::getQueueHandle: The ID %d does not exist in the map!\n",
|
||||
messageQueueId);
|
||||
#endif
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
QueueMapManager::~QueueMapManager() {
|
||||
MutexFactory::instance()->deleteMutex(mapLock);
|
||||
}
|
50
osal/FreeRTOS/QueueMapManager.h
Normal file
50
osal/FreeRTOS/QueueMapManager.h
Normal file
@ -0,0 +1,50 @@
|
||||
#ifndef FSFW_OSAL_FREERTOS_QUEUEMAPMANAGER_H_
|
||||
#define FSFW_OSAL_FREERTOS_QUEUEMAPMANAGER_H_
|
||||
|
||||
#include "../../ipc/MutexIF.h"
|
||||
#include "../../ipc/messageQueueDefinitions.h"
|
||||
#include "../../ipc/MessageQueueIF.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/queue.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
using QueueMap = std::map<MessageQueueId_t, QueueHandle_t>;
|
||||
|
||||
class QueueMapManager {
|
||||
public:
|
||||
|
||||
//! Returns the single instance of QueueMapManager
|
||||
static QueueMapManager* instance();
|
||||
|
||||
/**
|
||||
* Insert a message queue and the corresponding QueueHandle into the map
|
||||
* @param queue The message queue to insert.
|
||||
* @param id The passed value will be set unless a nullptr is passed
|
||||
* @return
|
||||
*/
|
||||
ReturnValue_t addMessageQueue(QueueHandle_t queue, MessageQueueId_t* id);
|
||||
|
||||
/**
|
||||
* Get the message queue handle by providing a message queue ID. Returns nullptr
|
||||
* if the queue ID does not exist in the internal map.
|
||||
* @param messageQueueId
|
||||
* @return
|
||||
*/
|
||||
QueueHandle_t getMessageQueue(MessageQueueId_t messageQueueId) const;
|
||||
|
||||
private:
|
||||
//! External instantiation forbidden. Constructor still required for singleton instantiation.
|
||||
QueueMapManager();
|
||||
~QueueMapManager();
|
||||
|
||||
uint32_t queueCounter = 0;
|
||||
MutexIF* mapLock;
|
||||
QueueMap queueMap;
|
||||
static QueueMapManager* mqManagerInstance;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_OSAL_FREERTOS_QUEUEMAPMANAGER_H_ */
|
@ -6,7 +6,7 @@
|
||||
#include "../../container/SharedRingBuffer.h"
|
||||
#include "../../ipc/MessageQueueSenderIF.h"
|
||||
#include "../../ipc/MutexGuard.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../tmtcservices/TmTcMessage.h"
|
||||
@ -41,7 +41,7 @@ ReturnValue_t TcpTmTcServer::initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
tcStore = objectManager->get<StorageManagerIF>(objects::TC_STORE);
|
||||
tcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||
if (tcStore == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "TcpTmTcServer::initialize: TC store uninitialized!" << std::endl;
|
||||
@ -51,7 +51,7 @@ ReturnValue_t TcpTmTcServer::initialize() {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
tmtcBridge = objectManager->get<TcpTmTcBridge>(tmtcBridgeId);
|
||||
tmtcBridge = ObjectManager::instance()->get<TcpTmTcBridge>(tmtcBridgeId);
|
||||
|
||||
int retval = 0;
|
||||
struct addrinfo *addrResult = nullptr;
|
||||
|
@ -2,7 +2,8 @@
|
||||
#include "tcpipHelpers.h"
|
||||
#include "../../platform.h"
|
||||
#include "../../globalfunctions/arrayprinter.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
|
||||
#ifdef PLATFORM_WIN
|
||||
#include <winsock2.h>
|
||||
@ -116,7 +117,7 @@ ReturnValue_t UdpTcPollingTask::handleSuccessfullTcRead(size_t bytesRead) {
|
||||
}
|
||||
|
||||
ReturnValue_t UdpTcPollingTask::initialize() {
|
||||
tcStore = objectManager->get<StorageManagerIF>(objects::TC_STORE);
|
||||
tcStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||
if (tcStore == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "UdpTcPollingTask::initialize: TC store uninitialized!" << std::endl;
|
||||
@ -124,7 +125,7 @@ ReturnValue_t UdpTcPollingTask::initialize() {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
tmtcBridge = objectManager->get<UdpTmTcBridge>(tmtcBridgeId);
|
||||
tmtcBridge = ObjectManager::instance()->get<UdpTmTcBridge>(tmtcBridgeId);
|
||||
if(tmtcBridge == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "UdpTcPollingTask::initialize: Invalid TMTC bridge object!" <<
|
||||
|
@ -171,71 +171,3 @@ ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) {
|
||||
/ 3600.;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::convertUTCToTT(timeval utc, timeval* tt) {
|
||||
//SHOULDDO: works not for dates in the past (might have less leap seconds)
|
||||
if (timeMutex == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
uint16_t leapSeconds;
|
||||
ReturnValue_t result = getLeapSeconds(&leapSeconds);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
timeval leapSeconds_timeval = { 0, 0 };
|
||||
leapSeconds_timeval.tv_sec = leapSeconds;
|
||||
|
||||
//initial offset between UTC and TAI
|
||||
timeval UTCtoTAI1972 = { 10, 0 };
|
||||
|
||||
timeval TAItoTT = { 32, 184000 };
|
||||
|
||||
*tt = utc + leapSeconds_timeval + UTCtoTAI1972 + TAItoTT;
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
|
||||
if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
ReturnValue_t result = timeMutex->lockMutex();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
leapSeconds = leapSeconds_;
|
||||
|
||||
result = timeMutex->unlockMutex();
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
|
||||
if(timeMutex == nullptr){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
ReturnValue_t result = timeMutex->lockMutex();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
*leapSeconds_ = leapSeconds;
|
||||
|
||||
result = timeMutex->unlockMutex();
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::checkOrCreateClockMutex(){
|
||||
if(timeMutex == nullptr){
|
||||
MutexFactory* mutexFactory = MutexFactory::instance();
|
||||
if (mutexFactory == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
timeMutex = mutexFactory->createMutex();
|
||||
if (timeMutex == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include "taskHelpers.h"
|
||||
|
||||
#include "../../platform.h"
|
||||
#include "../../osal/host/FixedTimeslotTask.h"
|
||||
#include "../../ipc/MutexFactory.h"
|
||||
#include "../../osal/host/Mutex.h"
|
||||
#include "../../osal/host/FixedTimeslotTask.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../tasks/ExecutableObjectIF.h"
|
||||
|
||||
@ -110,7 +112,7 @@ void FixedTimeslotTask::taskFunctionality() {
|
||||
|
||||
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
||||
uint32_t slotTimeMs, int8_t executionStep) {
|
||||
ExecutableObjectIF* executableObject = objectManager->
|
||||
ExecutableObjectIF* executableObject = ObjectManager::instance()->
|
||||
get<ExecutableObjectIF>(componentId);
|
||||
if (executableObject != nullptr) {
|
||||
pollingSeqTable.addSlot(componentId, slotTimeMs, executionStep,
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "MessageQueue.h"
|
||||
#include "QueueMapManager.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../ipc/MutexFactory.h"
|
||||
#include "../../ipc/MutexGuard.h"
|
||||
|
||||
@ -13,8 +14,9 @@ MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
|
||||
auto result = QueueMapManager::instance()->addMessageQueue(this, &mqId);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::MessageQueue:"
|
||||
<< " Could not be created" << std::endl;
|
||||
sif::error << "MessageQueue::MessageQueue: Could not be created" << std::endl;
|
||||
#else
|
||||
sif::printError("MessageQueue::MessageQueue: Could not be created\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -121,9 +123,8 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
QueueMapManager::instance()->getMessageQueue(sendTo));
|
||||
if(targetQueue == nullptr) {
|
||||
if(not ignoreFault) {
|
||||
InternalErrorReporterIF* internalErrorReporter =
|
||||
objectManager->get<InternalErrorReporterIF>(
|
||||
objects::INTERNAL_ERROR_REPORTER);
|
||||
InternalErrorReporterIF* internalErrorReporter = ObjectManager::instance()->
|
||||
get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
|
||||
if (internalErrorReporter != nullptr) {
|
||||
internalErrorReporter->queueMessageNotSent();
|
||||
}
|
||||
|
@ -4,7 +4,8 @@
|
||||
|
||||
#include "../../platform.h"
|
||||
#include "../../ipc/MutexFactory.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../tasks/ExecutableObjectIF.h"
|
||||
|
||||
#include <thread>
|
||||
@ -103,7 +104,7 @@ void PeriodicTask::taskFunctionality() {
|
||||
}
|
||||
|
||||
ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
|
||||
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
||||
ExecutableObjectIF* newObject = ObjectManager::instance()->get<ExecutableObjectIF>(
|
||||
object);
|
||||
if (newObject == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
|
@ -23,9 +23,7 @@ QueueMapManager* QueueMapManager::instance() {
|
||||
|
||||
ReturnValue_t QueueMapManager::addMessageQueue(
|
||||
MessageQueueIF* queueToInsert, MessageQueueId_t* id) {
|
||||
/* Not thread-safe, but it is assumed all message queues are created at software initialization
|
||||
now. If this is to be made thread-safe in the future, it propably would be sufficient to lock
|
||||
the increment operation here. */
|
||||
MutexGuard lock(mapLock);
|
||||
uint32_t currentId = queueCounter++;
|
||||
auto returnPair = queueMap.emplace(currentId, queueToInsert);
|
||||
if(not returnPair.second) {
|
||||
@ -47,7 +45,6 @@ ReturnValue_t QueueMapManager::addMessageQueue(
|
||||
|
||||
MessageQueueIF* QueueMapManager::getMessageQueue(
|
||||
MessageQueueId_t messageQueueId) const {
|
||||
MutexGuard(mapLock, MutexIF::TimeoutType::WAITING, 50);
|
||||
auto queueIter = queueMap.find(messageQueueId);
|
||||
if(queueIter != queueMap.end()) {
|
||||
return queueIter->second;
|
||||
@ -60,7 +57,7 @@ MessageQueueIF* QueueMapManager::getMessageQueue(
|
||||
sif::printWarning("QueueMapManager::getQueueHandle: The ID %d does not exist in the map!\n",
|
||||
messageQueueId);
|
||||
#endif
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,7 +15,9 @@ using QueueMap = std::unordered_map<MessageQueueId_t, MessageQueueIF*>;
|
||||
*/
|
||||
class QueueMapManager {
|
||||
public:
|
||||
//! Returns the single instance of SemaphoreFactory.
|
||||
|
||||
|
||||
//! Returns the single instance of QueueMapManager.
|
||||
static QueueMapManager* instance();
|
||||
|
||||
/**
|
||||
@ -27,14 +29,15 @@ public:
|
||||
ReturnValue_t addMessageQueue(MessageQueueIF* queue, MessageQueueId_t*
|
||||
id = nullptr);
|
||||
/**
|
||||
* Get the message queue handle by providing a message queue ID.
|
||||
* Get the message queue handle by providing a message queue ID. Returns nullptr
|
||||
* if the queue ID is not contained inside the internal map.
|
||||
* @param messageQueueId
|
||||
* @return
|
||||
*/
|
||||
MessageQueueIF* getMessageQueue(MessageQueueId_t messageQueueId) const;
|
||||
|
||||
private:
|
||||
//! External instantiation is forbidden.
|
||||
//! External instantiation is forbidden. Constructor still required for singleton instantiation.
|
||||
QueueMapManager();
|
||||
~QueueMapManager();
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "BinarySemaphore.h"
|
||||
#include "unixUtility.h"
|
||||
#include "../../serviceinterface/ServiceInterfacePrinter.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
@ -44,10 +45,7 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType,
|
||||
timeOut.tv_nsec = nseconds - timeOut.tv_sec * 1000000000;
|
||||
result = sem_timedwait(&handle, &timeOut);
|
||||
if(result != 0 and errno == EINVAL) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "BinarySemaphore::acquire: Invalid time value possible"
|
||||
<< std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "acquire", "sem_timedwait");
|
||||
}
|
||||
}
|
||||
if(result == 0) {
|
||||
@ -57,19 +55,21 @@ ReturnValue_t BinarySemaphore::acquire(TimeoutType timeoutType,
|
||||
switch(errno) {
|
||||
case(EAGAIN):
|
||||
// Operation could not be performed without blocking (for sem_trywait)
|
||||
case(ETIMEDOUT):
|
||||
case(ETIMEDOUT): {
|
||||
// Semaphore is 0
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "acquire", "ETIMEDOUT");
|
||||
return SemaphoreIF::SEMAPHORE_TIMEOUT;
|
||||
case(EINVAL):
|
||||
}
|
||||
case(EINVAL): {
|
||||
// Semaphore invalid
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "acquire", "EINVAL");
|
||||
return SemaphoreIF::SEMAPHORE_INVALID;
|
||||
case(EINTR):
|
||||
}
|
||||
case(EINTR): {
|
||||
// Call was interrupted by signal handler
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "BinarySemaphore::acquire: Signal handler interrupted."
|
||||
"Code " << strerror(errno) << std::endl;
|
||||
#endif
|
||||
/* No break */
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "acquire", "EINTR");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
default:
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
@ -91,11 +91,16 @@ ReturnValue_t BinarySemaphore::release(sem_t *handle) {
|
||||
}
|
||||
|
||||
switch(errno) {
|
||||
case(EINVAL):
|
||||
case(EINVAL): {
|
||||
// Semaphore invalid
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "release", "EINVAL");
|
||||
return SemaphoreIF::SEMAPHORE_INVALID;
|
||||
case(EOVERFLOW):
|
||||
}
|
||||
case(EOVERFLOW): {
|
||||
// SEM_MAX_VALUE overflow. This should never happen
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "release", "EOVERFLOW");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
default:
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
@ -128,17 +133,14 @@ void BinarySemaphore::initSemaphore(uint8_t initCount) {
|
||||
auto result = sem_init(&handle, true, initCount);
|
||||
if(result == -1) {
|
||||
switch(errno) {
|
||||
case(EINVAL):
|
||||
// Value exceeds SEM_VALUE_MAX
|
||||
case(EINVAL): {
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "initSemaphore", "EINVAL");
|
||||
break;
|
||||
}
|
||||
case(ENOSYS): {
|
||||
// System does not support process-shared semaphores
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "BinarySemaphore: Init failed with "
|
||||
<< strerror(errno) << std::endl;
|
||||
#else
|
||||
sif::printError("BinarySemaphore: Init failed with %s\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "initSemaphore", "ENOSYS");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -151,8 +153,7 @@ ReturnValue_t BinarySemaphore::checkCount(sem_t* handle, uint8_t maxCount) {
|
||||
// Binary Semaphore special case.
|
||||
// This is a config error use lightweight printf is this is called
|
||||
// from an interrupt
|
||||
printf("BinarySemaphore::release: Value of binary semaphore greater"
|
||||
" than 1!\n");
|
||||
printf("BinarySemaphore::release: Value of binary semaphore greater than 1!\n");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return SemaphoreIF::SEMAPHORE_NOT_OWNED;
|
||||
|
@ -76,6 +76,7 @@ public:
|
||||
static ReturnValue_t checkCount(sem_t* handle, uint8_t maxCount);
|
||||
protected:
|
||||
sem_t handle;
|
||||
static constexpr const char* CLASS_NAME = "BinarySemaphore";
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_OSAL_FREERTOS_BINARYSEMPAHORE_H_ */
|
||||
|
@ -15,6 +15,7 @@ target_sources(${LIB_FSFW_NAME}
|
||||
TaskFactory.cpp
|
||||
Timer.cpp
|
||||
tcpipHelpers.cpp
|
||||
unixUtility.cpp
|
||||
)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
@ -153,71 +153,3 @@ ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) {
|
||||
/ 3600.;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::convertUTCToTT(timeval utc, timeval* tt) {
|
||||
//SHOULDDO: works not for dates in the past (might have less leap seconds)
|
||||
if (timeMutex == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
uint16_t leapSeconds;
|
||||
ReturnValue_t result = getLeapSeconds(&leapSeconds);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
timeval leapSeconds_timeval = { 0, 0 };
|
||||
leapSeconds_timeval.tv_sec = leapSeconds;
|
||||
|
||||
//initial offset between UTC and TAI
|
||||
timeval UTCtoTAI1972 = { 10, 0 };
|
||||
|
||||
timeval TAItoTT = { 32, 184000 };
|
||||
|
||||
*tt = utc + leapSeconds_timeval + UTCtoTAI1972 + TAItoTT;
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
|
||||
if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
leapSeconds = leapSeconds_;
|
||||
|
||||
result = timeMutex->unlockMutex();
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
|
||||
if(timeMutex==NULL){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
ReturnValue_t result = timeMutex->lockMutex(MutexIF::TimeoutType::BLOCKING);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
*leapSeconds_ = leapSeconds;
|
||||
|
||||
result = timeMutex->unlockMutex();
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::checkOrCreateClockMutex(){
|
||||
if(timeMutex == nullptr){
|
||||
MutexFactory* mutexFactory = MutexFactory::instance();
|
||||
if (mutexFactory == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
timeMutex = mutexFactory->createMutex();
|
||||
if (timeMutex == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "../../osal/linux/CountingSemaphore.h"
|
||||
#include "CountingSemaphore.h"
|
||||
#include "unixUtility.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <errno.h>
|
||||
@ -7,8 +9,11 @@ CountingSemaphore::CountingSemaphore(const uint8_t maxCount, uint8_t initCount):
|
||||
maxCount(maxCount), initCount(initCount) {
|
||||
if(initCount > maxCount) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CountingSemaphoreUsingTask: Max count bigger than "
|
||||
"intial cout. Setting initial count to max count." << std::endl;
|
||||
sif::warning << "CountingSemaphoreUsingTask: Max count bigger than "
|
||||
"intial cout. Setting initial count to max count" << std::endl;
|
||||
#else
|
||||
sif::printWarning("CountingSemaphoreUsingTask: Max count bigger than "
|
||||
"intial cout. Setting initial count to max count\n");
|
||||
#endif
|
||||
initCount = maxCount;
|
||||
}
|
||||
@ -42,11 +47,18 @@ ReturnValue_t CountingSemaphore::release(sem_t* handle) {
|
||||
}
|
||||
|
||||
switch(errno) {
|
||||
case(EINVAL):
|
||||
case(EINVAL): {
|
||||
// Semaphore invalid
|
||||
utility::printUnixErrorGeneric("CountingSemaphore", "release", "EINVAL");
|
||||
return SemaphoreIF::SEMAPHORE_INVALID;
|
||||
case(EOVERFLOW):
|
||||
}
|
||||
|
||||
case(EOVERFLOW): {
|
||||
// SEM_MAX_VALUE overflow. This should never happen
|
||||
utility::printUnixErrorGeneric("CountingSemaphore", "release", "EOVERFLOW");
|
||||
return SemaphoreIF::SEMAPHORE_INVALID;
|
||||
}
|
||||
|
||||
default:
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "FixedTimeslotTask.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
@ -40,7 +42,7 @@ uint32_t FixedTimeslotTask::getPeriodMs() const {
|
||||
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
||||
uint32_t slotTimeMs, int8_t executionStep) {
|
||||
ExecutableObjectIF* executableObject =
|
||||
objectManager->get<ExecutableObjectIF>(componentId);
|
||||
ObjectManager::instance()->get<ExecutableObjectIF>(componentId);
|
||||
if (executableObject != nullptr) {
|
||||
pst.addSlot(componentId, slotTimeMs, executionStep,
|
||||
executableObject,this);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#include "MessageQueue.h"
|
||||
#include "unixUtility.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
@ -12,9 +14,7 @@
|
||||
|
||||
MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize):
|
||||
id(MessageQueueIF::NO_QUEUE),lastPartner(MessageQueueIF::NO_QUEUE),
|
||||
defaultDestination(MessageQueueIF::NO_QUEUE),
|
||||
maxMessageSize(maxMessageSize) {
|
||||
//debug << "MessageQueue::MessageQueue: Creating a queue" << std::endl;
|
||||
defaultDestination(MessageQueueIF::NO_QUEUE), maxMessageSize(maxMessageSize) {
|
||||
mq_attr attributes;
|
||||
this->id = 0;
|
||||
//Set attributes
|
||||
@ -31,7 +31,7 @@ MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize):
|
||||
mode_t mode = S_IWUSR | S_IREAD | S_IWGRP | S_IRGRP | S_IROTH | S_IWOTH;
|
||||
mqd_t tempId = mq_open(name, oflag, mode, &attributes);
|
||||
if (tempId == -1) {
|
||||
handleError(&attributes, messageDepth);
|
||||
handleOpenError(&attributes, messageDepth);
|
||||
}
|
||||
else {
|
||||
//Successful mq_open call
|
||||
@ -42,102 +42,14 @@ MessageQueue::MessageQueue(uint32_t messageDepth, size_t maxMessageSize):
|
||||
MessageQueue::~MessageQueue() {
|
||||
int status = mq_close(this->id);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::Destructor: mq_close Failed with status: "
|
||||
<< strerror(errno) <<std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "~MessageQueue", "close");
|
||||
}
|
||||
status = mq_unlink(name);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::Destructor: mq_unlink Failed with status: "
|
||||
<< strerror(errno) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "~MessageQueue", "unlink");
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::handleError(mq_attr* attributes,
|
||||
uint32_t messageDepth) {
|
||||
switch(errno) {
|
||||
case(EINVAL): {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::MessageQueue: Invalid name or attributes"
|
||||
" for message size" << std::endl;
|
||||
#endif
|
||||
size_t defaultMqMaxMsg = 0;
|
||||
// Not POSIX conformant, but should work for all UNIX systems.
|
||||
// Just an additional helpful printout :-)
|
||||
if(std::ifstream("/proc/sys/fs/mqueue/msg_max",std::ios::in) >>
|
||||
defaultMqMaxMsg and defaultMqMaxMsg < messageDepth) {
|
||||
/*
|
||||
See: https://www.man7.org/linux/man-pages/man3/mq_open.3.html
|
||||
This happens if the msg_max value is not large enough
|
||||
It is ignored if the executable is run in privileged mode.
|
||||
Run the unlockRealtime script or grant the mode manually by using:
|
||||
sudo setcap 'CAP_SYS_RESOURCE=+ep' <pathToBinary>
|
||||
|
||||
Persistent solution for session:
|
||||
echo <newMsgMax> | sudo tee /proc/sys/fs/mqueue/msg_max
|
||||
|
||||
Permanent solution:
|
||||
sudo nano /etc/sysctl.conf
|
||||
Append at end: fs/mqueue/msg_max = <newMsgMaxLen>
|
||||
Apply changes with: sudo sysctl -p
|
||||
*/
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::MessageQueue: Default MQ size "
|
||||
<< defaultMqMaxMsg << " is too small for requested size "
|
||||
<< messageDepth << std::endl;
|
||||
sif::error << "This error can be fixed by setting the maximum "
|
||||
"allowed message size higher!" << std::endl;
|
||||
#endif
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(EEXIST): {
|
||||
// An error occured during open
|
||||
// We need to distinguish if it is caused by an already created queue
|
||||
//There's another queue with the same name
|
||||
//We unlink the other queue
|
||||
int status = mq_unlink(name);
|
||||
if (status != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "mq_unlink Failed with status: " << strerror(errno)
|
||||
<< std::endl;
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
// Successful unlinking, try to open again
|
||||
mqd_t tempId = mq_open(name,
|
||||
O_NONBLOCK | O_RDWR | O_CREAT | O_EXCL,
|
||||
S_IWUSR | S_IREAD | S_IWGRP | S_IRGRP, attributes);
|
||||
if (tempId != -1) {
|
||||
//Successful mq_open
|
||||
this->id = tempId;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
// Failed either the first time or the second time
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::MessageQueue: Creating Queue " << name
|
||||
<< " failed with status: " << strerror(errno) << std::endl;
|
||||
#else
|
||||
sif::printError("MessageQueue::MessageQueue: Creating Queue %s"
|
||||
" failed with status: %s\n", name, strerror(errno));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::sendMessage(MessageQueueId_t sendTo,
|
||||
MessageQueueMessageIF* message, bool ignoreFault) {
|
||||
return sendMessageFrom(sendTo, message, this->getId(), false);
|
||||
@ -204,14 +116,12 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
||||
//O_NONBLOCK or MQ_NONBLOCK was set and there are no messages
|
||||
//currently on the specified queue.
|
||||
return MessageQueueIF::EMPTY;
|
||||
case EBADF:
|
||||
case EBADF: {
|
||||
//mqdes doesn't represent a valid queue open for reading.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::receive: configuration error "
|
||||
<< strerror(errno) << std::endl;
|
||||
#endif
|
||||
/*NO BREAK*/
|
||||
case EINVAL:
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "receiveMessage", "EBADF");
|
||||
break;
|
||||
}
|
||||
case EINVAL: {
|
||||
/*
|
||||
* This value indicates one of the following:
|
||||
* - The pointer to the buffer for storing the received message,
|
||||
@ -221,12 +131,10 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
||||
* queue, and the QNX extended option MQ_READBUF_DYNAMIC hasn't
|
||||
* been set in the queue's mq_flags.
|
||||
*/
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::receive: configuration error "
|
||||
<< strerror(errno) << std::endl;
|
||||
#endif
|
||||
/*NO BREAK*/
|
||||
case EMSGSIZE:
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "receiveMessage", "EINVAL");
|
||||
break;
|
||||
}
|
||||
case EMSGSIZE: {
|
||||
/*
|
||||
* This value indicates one of the following:
|
||||
* - the QNX extended option MQ_READBUF_DYNAMIC hasn't been set,
|
||||
@ -236,18 +144,25 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
||||
* given msg_len is too short for the message that would have
|
||||
* been received.
|
||||
*/
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::receive: configuration error "
|
||||
<< strerror(errno) << std::endl;
|
||||
#endif
|
||||
/*NO BREAK*/
|
||||
case EINTR:
|
||||
//The operation was interrupted by a signal.
|
||||
default:
|
||||
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "receiveMessage", "EMSGSIZE");
|
||||
break;
|
||||
}
|
||||
|
||||
case EINTR: {
|
||||
//The operation was interrupted by a signal.
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "receiveMessage", "EINTR");
|
||||
break;
|
||||
}
|
||||
case ETIMEDOUT: {
|
||||
//The operation was interrupted by a signal.
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "receiveMessage", "ETIMEDOUT");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
@ -262,16 +177,17 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) {
|
||||
switch(errno){
|
||||
case EBADF:
|
||||
//mqdes doesn't represent a valid message queue.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::flush configuration error, "
|
||||
"called flush with an invalid queue ID" << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "flush", "EBADF");
|
||||
break;
|
||||
/*NO BREAK*/
|
||||
case EINVAL:
|
||||
//mq_attr is NULL
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "flush", "EINVAL");
|
||||
break;
|
||||
default:
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*count = attrib.mq_curmsgs;
|
||||
attrib.mq_curmsgs = 0;
|
||||
@ -280,11 +196,8 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) {
|
||||
switch(errno) {
|
||||
case EBADF:
|
||||
//mqdes doesn't represent a valid message queue.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::flush configuration error, "
|
||||
"called flush with an invalid queue ID" << std::endl;
|
||||
#endif
|
||||
/*NO BREAK*/
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "flush", "EBADF");
|
||||
break;
|
||||
case EINVAL:
|
||||
/*
|
||||
* This value indicates one of the following:
|
||||
@ -293,9 +206,12 @@ ReturnValue_t MessageQueue::flush(uint32_t* count) {
|
||||
* mq_flags includes a 0 in the MQ_MULT_NOTIFY bit. Once
|
||||
* MQ_MULT_NOTIFY has been turned on, it may never be turned off.
|
||||
*/
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "flush", "EINVAL");
|
||||
break;
|
||||
default:
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
@ -336,8 +252,9 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
bool ignoreFault) {
|
||||
if(message == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message is "
|
||||
"nullptr!" << std::endl;
|
||||
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message is nullptr!" << std::endl;
|
||||
#else
|
||||
sif::printError("MessageQueue::sendMessageFromMessageQueue: Message is nullptr!\n");
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
@ -350,9 +267,8 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
//TODO: Check if we're in ISR.
|
||||
if (result != 0) {
|
||||
if(!ignoreFault){
|
||||
InternalErrorReporterIF* internalErrorReporter =
|
||||
objectManager->get<InternalErrorReporterIF>(
|
||||
objects::INTERNAL_ERROR_REPORTER);
|
||||
InternalErrorReporterIF* internalErrorReporter = ObjectManager::instance()->
|
||||
get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
|
||||
if (internalErrorReporter != NULL) {
|
||||
internalErrorReporter->queueMessageNotSent();
|
||||
}
|
||||
@ -366,17 +282,20 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
case EBADF: {
|
||||
//mq_des doesn't represent a valid message queue descriptor,
|
||||
//or mq_des wasn't opened for writing.
|
||||
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "sendMessageFromMessageQueue", "EBADF");
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::sendMessage: Configuration error, MQ"
|
||||
<< " destination invalid." << std::endl;
|
||||
sif::error << strerror(errno) << " in "
|
||||
<<"mq_send to: " << sendTo << " sent from "
|
||||
<< sentFrom << std::endl;
|
||||
sif::warning << "mq_send to: " << sendTo << " sent from "
|
||||
<< sentFrom << "failed" << std::endl;
|
||||
#else
|
||||
sif::printWarning("mq_send to: %d sent from %d failed\n", sendTo, sentFrom);
|
||||
#endif
|
||||
return DESTINATION_INVALID;
|
||||
}
|
||||
case EINTR:
|
||||
//The call was interrupted by a signal.
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "sendMessageFromMessageQueue", "EINTR");
|
||||
break;
|
||||
case EINVAL:
|
||||
/*
|
||||
* This value indicates one of the following:
|
||||
@ -387,22 +306,87 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
* - MQ_PRIO_RESTRICT is set in the mq_attr of mq_des, and
|
||||
* msg_prio is greater than the priority of the calling process.
|
||||
*/
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::sendMessage: Configuration error "
|
||||
<< strerror(errno) << " in mq_send" << std::endl;
|
||||
#endif
|
||||
/*NO BREAK*/
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "sendMessageFromMessageQueue", "EINVAL");
|
||||
break;
|
||||
case EMSGSIZE:
|
||||
// The msg_len is greater than the msgsize associated with
|
||||
//the specified queue.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::sendMessage: Size error [" <<
|
||||
strerror(errno) << "] in mq_send" << std::endl;
|
||||
#endif
|
||||
/*NO BREAK*/
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "sendMessageFromMessageQueue", "EMSGSIZE");
|
||||
break;
|
||||
default:
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::handleOpenError(mq_attr* attributes,
|
||||
uint32_t messageDepth) {
|
||||
switch(errno) {
|
||||
case(EINVAL): {
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "MessageQueue", "EINVAL");
|
||||
size_t defaultMqMaxMsg = 0;
|
||||
// Not POSIX conformant, but should work for all UNIX systems.
|
||||
// Just an additional helpful printout :-)
|
||||
if(std::ifstream("/proc/sys/fs/mqueue/msg_max",std::ios::in) >>
|
||||
defaultMqMaxMsg and defaultMqMaxMsg < messageDepth) {
|
||||
/*
|
||||
See: https://www.man7.org/linux/man-pages/man3/mq_open.3.html
|
||||
This happens if the msg_max value is not large enough
|
||||
It is ignored if the executable is run in privileged mode.
|
||||
Run the unlockRealtime script or grant the mode manually by using:
|
||||
sudo setcap 'CAP_SYS_RESOURCE=+ep' <pathToBinary>
|
||||
|
||||
Persistent solution for session:
|
||||
echo <newMsgMax> | sudo tee /proc/sys/fs/mqueue/msg_max
|
||||
|
||||
Permanent solution:
|
||||
sudo nano /etc/sysctl.conf
|
||||
Append at end: fs/mqueue/msg_max = <newMsgMaxLen>
|
||||
Apply changes with: sudo sysctl -p
|
||||
*/
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MessageQueue::MessageQueue: Default MQ size " << defaultMqMaxMsg <<
|
||||
" is too small for requested size " << messageDepth << std::endl;
|
||||
sif::error << "This error can be fixed by setting the maximum "
|
||||
"allowed message size higher!" << std::endl;
|
||||
#else
|
||||
sif::printError("MessageQueue::MessageQueue: Default MQ size %d is too small for"
|
||||
"requested size %d\n");
|
||||
sif::printError("This error can be fixes by setting the maximum allowed"
|
||||
"message size higher!\n");
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
}
|
||||
case(EEXIST): {
|
||||
// An error occured during open.
|
||||
// We need to distinguish if it is caused by an already created queue
|
||||
// There's another queue with the same name
|
||||
// We unlink the other queue
|
||||
int status = mq_unlink(name);
|
||||
if (status != 0) {
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "MessageQueue", "EEXIST");
|
||||
}
|
||||
else {
|
||||
// Successful unlinking, try to open again
|
||||
mqd_t tempId = mq_open(name,
|
||||
O_NONBLOCK | O_RDWR | O_CREAT | O_EXCL,
|
||||
S_IWUSR | S_IREAD | S_IWGRP | S_IRGRP, attributes);
|
||||
if (tempId != -1) {
|
||||
//Successful mq_open
|
||||
this->id = tempId;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
// Failed either the first time or the second time
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "MessageQueue", "Unknown");
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
@ -181,7 +181,8 @@ private:
|
||||
static uint16_t queueCounter;
|
||||
const size_t maxMessageSize;
|
||||
|
||||
ReturnValue_t handleError(mq_attr* attributes, uint32_t messageDepth);
|
||||
static constexpr const char* CLASS_NAME = "MessageQueue";
|
||||
ReturnValue_t handleOpenError(mq_attr* attributes, uint32_t messageDepth);
|
||||
};
|
||||
|
||||
#endif /* FSFW_OSAL_LINUX_MESSAGEQUEUE_H_ */
|
||||
|
@ -1,43 +1,34 @@
|
||||
#include "Mutex.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "unixUtility.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../timemanager/Clock.h"
|
||||
|
||||
uint8_t Mutex::count = 0;
|
||||
|
||||
|
||||
#include <cstring>
|
||||
#include <errno.h>
|
||||
|
||||
uint8_t Mutex::count = 0;
|
||||
|
||||
Mutex::Mutex() {
|
||||
pthread_mutexattr_t mutexAttr;
|
||||
int status = pthread_mutexattr_init(&mutexAttr);
|
||||
if (status != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Mutex: Attribute init failed with: " << strerror(status) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric("Mutex", "Mutex", "pthread_mutexattr_init");
|
||||
}
|
||||
status = pthread_mutexattr_setprotocol(&mutexAttr, PTHREAD_PRIO_INHERIT);
|
||||
if (status != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Mutex: Attribute set PRIO_INHERIT failed with: " << strerror(status)
|
||||
<< std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric("Mutex", "Mutex", "pthread_mutexattr_setprotocol");
|
||||
}
|
||||
status = pthread_mutex_init(&mutex, &mutexAttr);
|
||||
if (status != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Mutex: creation with name, id " << mutex.__data.__count
|
||||
<< ", " << " failed with " << strerror(status) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric("Mutex", "Mutex", "pthread_mutex_init");
|
||||
}
|
||||
// After a mutex attributes object has been used to initialize one or more
|
||||
// mutexes, any function affecting the attributes object
|
||||
// (including destruction) shall not affect any previously initialized mutexes.
|
||||
status = pthread_mutexattr_destroy(&mutexAttr);
|
||||
if (status != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Mutex: Attribute destroy failed with " << strerror(status) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric("Mutex", "Mutex", "pthread_mutexattr_destroy");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
#include "../../tasks/ExecutableObjectIF.h"
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include <errno.h>
|
||||
#include "PeriodicPosixTask.h"
|
||||
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../tasks/ExecutableObjectIF.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
PeriodicPosixTask::PeriodicPosixTask(const char* name_, int priority_,
|
||||
size_t stackSize_, uint32_t period_, void(deadlineMissedFunc_)()):
|
||||
PosixThread(name_, priority_, stackSize_), objectList(), started(false),
|
||||
@ -22,12 +25,15 @@ void* PeriodicPosixTask::taskEntryPoint(void* arg) {
|
||||
}
|
||||
|
||||
ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) {
|
||||
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(
|
||||
ExecutableObjectIF* newObject = ObjectManager::instance()->get<ExecutableObjectIF>(
|
||||
object);
|
||||
if (newObject == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PeriodicTask::addComponent: Invalid object. Make sure"
|
||||
<< " it implements ExecutableObjectIF!" << std::endl;
|
||||
#else
|
||||
sif::printError("PeriodicTask::addComponent: Invalid object. Make sure it "
|
||||
"implements ExecutableObjectIF!\n");
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
@ -44,9 +50,6 @@ ReturnValue_t PeriodicPosixTask::sleepFor(uint32_t ms) {
|
||||
|
||||
ReturnValue_t PeriodicPosixTask::startTask(void) {
|
||||
started = true;
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
//sif::info << stackSize << std::endl;
|
||||
#endif
|
||||
PosixThread::createTask(&taskEntryPoint,this);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include "PosixThread.h"
|
||||
#include "unixUtility.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
@ -49,8 +50,10 @@ void PosixThread::suspend() {
|
||||
sigwait(&waitSignal, &caughtSig);
|
||||
if (caughtSig != SIGUSR1) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "FixedTimeslotTask: Unknown Signal received: " <<
|
||||
caughtSig << std::endl;
|
||||
sif::error << "FixedTimeslotTask::suspend: Unknown Signal received: " << caughtSig <<
|
||||
std::endl;
|
||||
#else
|
||||
sif::printError("FixedTimeslotTask::suspend: Unknown Signal received: %d\n", caughtSig);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -133,18 +136,11 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
||||
pthread_attr_t attributes;
|
||||
int status = pthread_attr_init(&attributes);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Posix Thread attribute init failed with: " <<
|
||||
strerror(status) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_init");
|
||||
}
|
||||
void* stackPointer;
|
||||
status = posix_memalign(&stackPointer, sysconf(_SC_PAGESIZE), stackSize);
|
||||
if(status != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PosixThread::createTask: Stack init failed with: " <<
|
||||
strerror(status) << std::endl;
|
||||
#endif
|
||||
if(errno == ENOMEM) {
|
||||
size_t stackMb = stackSize/10e6;
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
@ -154,35 +150,35 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
||||
sif::printError("PosixThread::createTask: Insufficient memory for "
|
||||
"the requested %lu MB\n", static_cast<unsigned long>(stackMb));
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "ENOMEM");
|
||||
}
|
||||
else if(errno == EINVAL) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PosixThread::createTask: Wrong alignment argument!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printError("PosixThread::createTask: "
|
||||
"Wrong alignment argument!\n");
|
||||
sif::printError("PosixThread::createTask: Wrong alignment argument!\n");
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "EINVAL");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
status = pthread_attr_setstack(&attributes, stackPointer, stackSize);
|
||||
if(status != 0) {
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_setstack");
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PosixThread::createTask: pthread_attr_setstack "
|
||||
" failed with: " << strerror(status) << std::endl;
|
||||
sif::error << "Make sure the specified stack size is valid and is "
|
||||
sif::warning << "Make sure the specified stack size is valid and is "
|
||||
"larger than the minimum allowed stack size." << std::endl;
|
||||
#else
|
||||
sif::printWarning("Make sure the specified stack size is valid and is "
|
||||
"larger than the minimum allowed stack size.\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
status = pthread_attr_setinheritsched(&attributes, PTHREAD_EXPLICIT_SCHED);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Posix Thread attribute setinheritsched failed with: " <<
|
||||
strerror(status) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_setinheritsched");
|
||||
}
|
||||
#ifndef FSFW_USE_REALTIME_FOR_LINUX
|
||||
#error "Please define FSFW_USE_REALTIME_FOR_LINUX with either 0 or 1"
|
||||
@ -191,20 +187,14 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
||||
// FIFO -> This needs root privileges for the process
|
||||
status = pthread_attr_setschedpolicy(&attributes,SCHED_FIFO);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Posix Thread attribute schedule policy failed with: " <<
|
||||
strerror(status) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_setschedpolicy");
|
||||
}
|
||||
|
||||
sched_param scheduleParams;
|
||||
scheduleParams.__sched_priority = priority;
|
||||
status = pthread_attr_setschedparam(&attributes, &scheduleParams);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Posix Thread attribute schedule params failed with: " <<
|
||||
strerror(status) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_setschedparam");
|
||||
}
|
||||
#endif
|
||||
//Set Signal Mask for suspend until startTask is called
|
||||
@ -213,23 +203,17 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
||||
sigaddset(&waitSignal, SIGUSR1);
|
||||
status = pthread_sigmask(SIG_BLOCK, &waitSignal, NULL);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Posix Thread sigmask failed failed with: " <<
|
||||
strerror(status) << " errno: " << strerror(errno) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_sigmask");
|
||||
}
|
||||
|
||||
|
||||
status = pthread_create(&thread,&attributes,fnc_,arg_);
|
||||
if(status != 0){
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_create");
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PosixThread::createTask: Failed with: " <<
|
||||
strerror(status) << std::endl;
|
||||
sif::error << "For FSFW_USE_REALTIME_FOR_LINUX == 1 make sure to call " <<
|
||||
"\"all sudo setcap 'cap_sys_nice=eip'\" on the application or set "
|
||||
"/etc/security/limit.conf" << std::endl;
|
||||
#else
|
||||
sif::printError("PosixThread::createTask: Create failed with: %s\n", strerror(status));
|
||||
sif::printError("For FSFW_USE_REALTIME_FOR_LINUX == 1 make sure to call "
|
||||
"\"all sudo setcap 'cap_sys_nice=eip'\" on the application or set "
|
||||
"/etc/security/limit.conf\n");
|
||||
@ -238,31 +222,25 @@ void PosixThread::createTask(void* (*fnc_)(void*), void* arg_) {
|
||||
|
||||
status = pthread_setname_np(thread,name);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PosixThread::createTask: setname failed with: " <<
|
||||
strerror(status) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_setname_np");
|
||||
if(status == ERANGE) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PosixThread::createTask: Task name length longer"
|
||||
sif::warning << "PosixThread::createTask: Task name length longer"
|
||||
" than 16 chars. Truncating.." << std::endl;
|
||||
#else
|
||||
sif::printWarning("PosixThread::createTask: Task name length longer"
|
||||
" than 16 chars. Truncating..\n");
|
||||
#endif
|
||||
name[15] = '\0';
|
||||
status = pthread_setname_np(thread,name);
|
||||
if(status != 0){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PosixThread::createTask: Setting name"
|
||||
" did not work.." << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_setname_np");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
status = pthread_attr_destroy(&attributes);
|
||||
if (status != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Posix Thread attribute destroy failed with: " <<
|
||||
strerror(status) << std::endl;
|
||||
#endif
|
||||
utility::printUnixErrorGeneric(CLASS_NAME, "createTask", "pthread_attr_destroy");
|
||||
}
|
||||
}
|
||||
|
@ -72,6 +72,8 @@ private:
|
||||
char name[PTHREAD_MAX_NAMELEN];
|
||||
int priority;
|
||||
size_t stackSize = 0;
|
||||
|
||||
static constexpr const char* CLASS_NAME = "PosixThread";
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_OSAL_LINUX_POSIXTHREAD_H_ */
|
||||
|
32
osal/linux/unixUtility.cpp
Normal file
32
osal/linux/unixUtility.cpp
Normal file
@ -0,0 +1,32 @@
|
||||
#include "FSFWConfig.h"
|
||||
#include "unixUtility.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <errno.h>
|
||||
|
||||
void utility::printUnixErrorGeneric(const char* const className,
|
||||
const char* const function, const char* const failString,
|
||||
sif::OutputTypes outputType) {
|
||||
if(className == nullptr or failString == nullptr or function == nullptr) {
|
||||
return;
|
||||
}
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
if(outputType == sif::OutputTypes::OUT_ERROR) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << className << "::" << function << ":" << failString << " error: "
|
||||
<< strerror(errno) << std::endl;
|
||||
#else
|
||||
sif::printError("%s::%s: %s error: %s\n", className, function, failString, strerror(errno));
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << className << "::" << function << ":" << failString << " error: "
|
||||
<< strerror(errno) << std::endl;
|
||||
#else
|
||||
sif::printWarning("%s::%s: %s error: %s\n", className, function, failString, strerror(errno));
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
}
|
13
osal/linux/unixUtility.h
Normal file
13
osal/linux/unixUtility.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef FSFW_OSAL_LINUX_UNIXUTILITY_H_
|
||||
#define FSFW_OSAL_LINUX_UNIXUTILITY_H_
|
||||
|
||||
#include "../../serviceinterface/serviceInterfaceDefintions.h"
|
||||
|
||||
namespace utility {
|
||||
|
||||
void printUnixErrorGeneric(const char* const className, const char* const function,
|
||||
const char* const failString, sif::OutputTypes outputType = sif::OutputTypes::OUT_ERROR);
|
||||
|
||||
}
|
||||
|
||||
#endif /* FSFW_OSAL_LINUX_UNIXUTILITY_H_ */
|
@ -154,65 +154,3 @@ ReturnValue_t Clock::convertTimevalToJD2000(timeval time, double* JD2000) {
|
||||
/ 3600.;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::convertUTCToTT(timeval utc, timeval* tt) {
|
||||
//SHOULDDO: works not for dates in the past (might have less leap seconds)
|
||||
if (timeMutex == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
uint16_t leapSeconds;
|
||||
ReturnValue_t result = getLeapSeconds(&leapSeconds);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
timeval leapSeconds_timeval = { 0, 0 };
|
||||
leapSeconds_timeval.tv_sec = leapSeconds;
|
||||
|
||||
//initial offset between UTC and TAI
|
||||
timeval UTCtoTAI1972 = { 10, 0 };
|
||||
|
||||
timeval TAItoTT = { 32, 184000 };
|
||||
|
||||
*tt = utc + leapSeconds_timeval + UTCtoTAI1972 + TAItoTT;
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::setLeapSeconds(const uint16_t leapSeconds_) {
|
||||
if(checkOrCreateClockMutex()!=HasReturnvaluesIF::RETURN_OK){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
MutexGuard helper(timeMutex);
|
||||
|
||||
|
||||
leapSeconds = leapSeconds_;
|
||||
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::getLeapSeconds(uint16_t* leapSeconds_) {
|
||||
if(timeMutex==nullptr){
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
MutexGuard helper(timeMutex);
|
||||
|
||||
*leapSeconds_ = leapSeconds;
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t Clock::checkOrCreateClockMutex(){
|
||||
if(timeMutex==nullptr){
|
||||
MutexFactory* mutexFactory = MutexFactory::instance();
|
||||
if (mutexFactory == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
timeMutex = mutexFactory->createMutex();
|
||||
if (timeMutex == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "../../tasks/FixedSequenceSlot.h"
|
||||
#include "../../objectmanager/SystemObjectIF.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
|
||||
@ -81,7 +81,7 @@ ReturnValue_t FixedTimeslotTask::startTask() {
|
||||
|
||||
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
||||
uint32_t slotTimeMs, int8_t executionStep) {
|
||||
ExecutableObjectIF* object = objectManager->get<ExecutableObjectIF>(componentId);
|
||||
ExecutableObjectIF* object = ObjectManager::instance()->get<ExecutableObjectIF>(componentId);
|
||||
if (object != nullptr) {
|
||||
pst.addSlot(componentId, slotTimeMs, executionStep, object, this);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
@ -1,8 +1,11 @@
|
||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "MessageQueue.h"
|
||||
#include "RtemsBasic.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
MessageQueue::MessageQueue(size_t message_depth, size_t max_message_size) :
|
||||
id(0), lastPartner(0), defaultDestination(NO_QUEUE), internalErrorReporter(nullptr) {
|
||||
rtems_name name = ('Q' << 24) + (queueCounter++ << 8);
|
||||
@ -94,7 +97,7 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo,
|
||||
//TODO: Check if we're in ISR.
|
||||
if (result != RTEMS_SUCCESSFUL && !ignoreFault) {
|
||||
if (internalErrorReporter == nullptr) {
|
||||
internalErrorReporter = objectManager->get<InternalErrorReporterIF>(
|
||||
internalErrorReporter = ObjectManager::instance()->get<InternalErrorReporterIF>(
|
||||
objects::INTERNAL_ERROR_REPORTER);
|
||||
}
|
||||
if (internalErrorReporter != nullptr) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "PeriodicTask.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../tasks/ExecutableObjectIF.h"
|
||||
|
||||
PeriodicTask::PeriodicTask(const char *name, rtems_task_priority setPriority,
|
||||
@ -68,7 +69,7 @@ void PeriodicTask::taskFunctionality() {
|
||||
}
|
||||
|
||||
ReturnValue_t PeriodicTask::addComponent(object_id_t object) {
|
||||
ExecutableObjectIF* newObject = objectManager->get<ExecutableObjectIF>(object);
|
||||
ExecutableObjectIF* newObject = ObjectManager::instance()->get<ExecutableObjectIF>(object);
|
||||
if (newObject == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "ParameterHelper.h"
|
||||
#include "ParameterMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
ParameterHelper::ParameterHelper(ReceivesParameterMessagesIF* owner):
|
||||
owner(owner) {}
|
||||
@ -124,7 +125,7 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id,
|
||||
ReturnValue_t ParameterHelper::initialize() {
|
||||
ownerQueueId = owner->getCommandQueue();
|
||||
|
||||
storage = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
storage = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (storage == nullptr) {
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "../parameters/ParameterMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "ParameterMessage.h"
|
||||
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
ParameterId_t ParameterMessage::getParameterId(const CommandMessage* message) {
|
||||
return message->getParameter();
|
||||
@ -51,7 +52,7 @@ void ParameterMessage::clear(CommandMessage* message) {
|
||||
switch (message->getCommand()) {
|
||||
case CMD_PARAMETER_LOAD:
|
||||
case REPLY_PARAMETER_DUMP: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
StorageManagerIF *ipcStore = ObjectManager::instance()->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != NULL) {
|
||||
ipcStore->deleteData(getStoreId(message));
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "../monitoring/LimitViolationReporter.h"
|
||||
#include "../monitoring/MonitoringMessageContent.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../serialize/SerialFixedArrayListAdapter.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
|
||||
@ -44,7 +44,7 @@ ReturnValue_t Fuse::initialize() {
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
powerIF = objectManager->get<PowerSwitchIF>(powerSwitchId);
|
||||
powerIF = ObjectManager::instance()->get<PowerSwitchIF>(powerSwitchId);
|
||||
if (powerIF == NULL) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "PowerSwitcher.h"
|
||||
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
|
||||
PowerSwitcher::PowerSwitcher(uint8_t setSwitch1, uint8_t setSwitch2,
|
||||
PowerSwitcher::State_t setStartState):
|
||||
@ -10,7 +10,7 @@ PowerSwitcher::PowerSwitcher(uint8_t setSwitch1, uint8_t setSwitch2,
|
||||
}
|
||||
|
||||
ReturnValue_t PowerSwitcher::initialize(object_id_t powerSwitchId) {
|
||||
power = objectManager->get<PowerSwitchIF>(powerSwitchId);
|
||||
power = ObjectManager::instance()->get<PowerSwitchIF>(powerSwitchId);
|
||||
if (power == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
@ -2,7 +2,8 @@
|
||||
#include "servicepackets/Service200Packets.h"
|
||||
|
||||
#include "../modes/HasModesIF.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../serialize/SerialLinkedListAdapter.h"
|
||||
#include "../modes/ModeMessage.h"
|
||||
|
||||
@ -40,7 +41,7 @@ ReturnValue_t CService200ModeCommanding::getMessageQueueAndObject(
|
||||
|
||||
ReturnValue_t CService200ModeCommanding::checkInterfaceAndAcquireMessageQueue(
|
||||
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
|
||||
HasModesIF * destination = objectManager->get<HasModesIF>(*objectId);
|
||||
HasModesIF * destination = ObjectManager::instance()->get<HasModesIF>(*objectId);
|
||||
if(destination == nullptr) {
|
||||
return CommandingServiceBase::INVALID_OBJECT;
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include "CService201HealthCommanding.h"
|
||||
#include "servicepackets/Service201Packets.h"
|
||||
|
||||
#include "../health/HasHealthIF.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../health/HealthMessage.h"
|
||||
#include "servicepackets/Service201Packets.h"
|
||||
|
||||
|
||||
CService201HealthCommanding::CService201HealthCommanding(object_id_t objectId,
|
||||
uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands,
|
||||
@ -43,7 +45,7 @@ ReturnValue_t CService201HealthCommanding::getMessageQueueAndObject(
|
||||
|
||||
ReturnValue_t CService201HealthCommanding::checkInterfaceAndAcquireMessageQueue(
|
||||
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
|
||||
HasHealthIF * destination = objectManager->get<HasHealthIF>(*objectId);
|
||||
HasHealthIF * destination = ObjectManager::instance()->get<HasHealthIF>(*objectId);
|
||||
if(destination == nullptr) {
|
||||
return CommandingServiceBase::INVALID_OBJECT;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../objectmanager/SystemObject.h"
|
||||
#include "../tmtcpacket/pus/TmPacketStored.h"
|
||||
#include "../tmtcpacket/pus/tm/TmPacketStored.h"
|
||||
|
||||
|
||||
Service17Test::Service17Test(object_id_t objectId,
|
||||
|
@ -2,8 +2,9 @@
|
||||
#include "servicepackets/Service1Packets.h"
|
||||
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../tmtcservices/PusVerificationReport.h"
|
||||
#include "../tmtcpacket/pus/TmPacketStored.h"
|
||||
#include "../tmtcpacket/pus/tm/TmPacketStored.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../tmtcservices/AcceptsTelemetryIF.h"
|
||||
|
||||
@ -99,7 +100,7 @@ ReturnValue_t Service1TelecommandVerification::generateSuccessReport(
|
||||
|
||||
ReturnValue_t Service1TelecommandVerification::initialize() {
|
||||
// Get target object for TC verification messages
|
||||
AcceptsTelemetryIF* funnel = objectManager->
|
||||
AcceptsTelemetryIF* funnel = ObjectManager::instance()->
|
||||
get<AcceptsTelemetryIF>(targetDestination);
|
||||
if(funnel == nullptr){
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
@ -1,11 +1,11 @@
|
||||
#include "Service20ParameterManagement.h"
|
||||
#include "servicepackets/Service20Packets.h"
|
||||
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/parameters/HasParametersIF.h>
|
||||
#include <fsfw/parameters/ParameterMessage.h>
|
||||
#include <fsfw/parameters/ReceivesParameterMessagesIF.h>
|
||||
#include <tmtc/pusIds.h>
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../parameters/HasParametersIF.h"
|
||||
#include "../parameters/ParameterMessage.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../parameters/ReceivesParameterMessagesIF.h"
|
||||
|
||||
|
||||
Service20ParameterManagement::Service20ParameterManagement(object_id_t objectId, uint16_t apid,
|
||||
@ -65,7 +65,7 @@ ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue
|
||||
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
|
||||
// check ReceivesParameterMessagesIF property of target
|
||||
ReceivesParameterMessagesIF* possibleTarget =
|
||||
objectManager->get<ReceivesParameterMessagesIF>(*objectId);
|
||||
ObjectManager::instance()->get<ReceivesParameterMessagesIF>(*objectId);
|
||||
if(possibleTarget == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Service20ParameterManagement::checkInterfaceAndAcquire"
|
||||
@ -133,6 +133,9 @@ ReturnValue_t Service20ParameterManagement::prepareLoadCommand(
|
||||
store_address_t storeAddress;
|
||||
size_t parameterDataLen = tcDataLen - sizeof(object_id_t) - sizeof(ParameterId_t) -
|
||||
sizeof(uint32_t);
|
||||
if(parameterDataLen == 0) {
|
||||
return CommandingServiceBase::INVALID_TC;
|
||||
}
|
||||
ReturnValue_t result = IPCStore->getFreeElement(&storeAddress,
|
||||
parameterDataLen, &storePointer);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
#ifndef FSFW_PUS_SERVICE20PARAMETERMANAGEMENT_H_
|
||||
#define FSFW_PUS_SERVICE20PARAMETERMANAGEMENT_H_
|
||||
|
||||
#include <fsfw/tmtcservices/CommandingServiceBase.h>
|
||||
#include "../tmtcservices/CommandingServiceBase.h"
|
||||
|
||||
/**
|
||||
* @brief PUS Service 20 Parameter Service implementation
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "Service2DeviceAccess.h"
|
||||
#include "servicepackets/Service2Packets.h"
|
||||
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../devicehandlers/DeviceHandlerIF.h"
|
||||
#include "../storagemanager/StorageManagerIF.h"
|
||||
#include "../devicehandlers/DeviceHandlerMessage.h"
|
||||
@ -47,7 +48,7 @@ ReturnValue_t Service2DeviceAccess::getMessageQueueAndObject(
|
||||
ReturnValue_t Service2DeviceAccess::checkInterfaceAndAcquireMessageQueue(
|
||||
MessageQueueId_t * messageQueueToSet, object_id_t *objectId) {
|
||||
DeviceHandlerIF* possibleTarget =
|
||||
objectManager->get<DeviceHandlerIF>(*objectId);
|
||||
ObjectManager::instance()->get<DeviceHandlerIF>(*objectId);
|
||||
if(possibleTarget == nullptr) {
|
||||
return CommandingServiceBase::INVALID_OBJECT;
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "Service3Housekeeping.h"
|
||||
#include "servicepackets/Service3Packets.h"
|
||||
#include "../datapoollocal/HasLocalDataPoolIF.h"
|
||||
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../datapoollocal/HasLocalDataPoolIF.h"
|
||||
|
||||
Service3Housekeeping::Service3Housekeeping(object_id_t objectId, uint16_t apid,
|
||||
uint8_t serviceId):
|
||||
@ -56,7 +57,7 @@ ReturnValue_t Service3Housekeeping::checkInterfaceAndAcquireMessageQueue(
|
||||
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
|
||||
// check HasLocalDataPoolIF property of target
|
||||
HasLocalDataPoolIF* possibleTarget =
|
||||
objectManager->get<HasLocalDataPoolIF>(*objectId);
|
||||
ObjectManager::instance()->get<HasLocalDataPoolIF>(*objectId);
|
||||
if(possibleTarget == nullptr){
|
||||
return CommandingServiceBase::INVALID_OBJECT;
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
#include "Service5EventReporting.h"
|
||||
#include "servicepackets/Service5Packets.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../events/EventManagerIF.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
#include "../tmtcpacket/pus/TmPacketStored.h"
|
||||
#include "../tmtcpacket/pus/tm/TmPacketStored.h"
|
||||
|
||||
|
||||
Service5EventReporting::Service5EventReporting(object_id_t objectId,
|
||||
@ -89,7 +90,7 @@ ReturnValue_t Service5EventReporting::handleRequest(uint8_t subservice) {
|
||||
// In addition to the default PUSServiceBase initialization, this service needs
|
||||
// to be registered to the event manager to listen for events.
|
||||
ReturnValue_t Service5EventReporting::initialize() {
|
||||
EventManagerIF* manager = objectManager->get<EventManagerIF>(
|
||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(
|
||||
objects::EVENT_MANAGER);
|
||||
if (manager == NULL) {
|
||||
return RETURN_FAILED;
|
||||
|
@ -1,11 +1,12 @@
|
||||
#include "Service8FunctionManagement.h"
|
||||
#include "servicepackets/Service8Packets.h"
|
||||
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../objectmanager/SystemObjectIF.h"
|
||||
#include "../action/HasActionsIF.h"
|
||||
#include "../devicehandlers/DeviceHandlerIF.h"
|
||||
#include "../serialize/SerializeAdapter.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
|
||||
Service8FunctionManagement::Service8FunctionManagement(object_id_t objectId,
|
||||
uint16_t apid, uint8_t serviceId, uint8_t numParallelCommands,
|
||||
@ -41,7 +42,7 @@ ReturnValue_t Service8FunctionManagement::getMessageQueueAndObject(
|
||||
ReturnValue_t Service8FunctionManagement::checkInterfaceAndAcquireMessageQueue(
|
||||
MessageQueueId_t* messageQueueToSet, object_id_t* objectId) {
|
||||
// check HasActionIF property of target
|
||||
HasActionsIF* possibleTarget = objectManager->get<HasActionsIF>(*objectId);
|
||||
HasActionsIF* possibleTarget = ObjectManager::instance()->get<HasActionsIF>(*objectId);
|
||||
if(possibleTarget == nullptr){
|
||||
return CommandingServiceBase::INVALID_OBJECT;
|
||||
}
|
||||
|
@ -27,12 +27,11 @@ public:
|
||||
ParameterCommand(uint8_t* storePointer, size_t parameterDataLen):
|
||||
parameterBuffer(storePointer, parameterDataLen) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
if(parameterDataLen < sizeof(object_id_t) + sizeof(ParameterId_t) + 4) {
|
||||
if(parameterDataLen == 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ParameterCommand: Parameter data length is less than 12!"
|
||||
<< std::endl;
|
||||
sif::warning << "ParameterCommand: Parameter data length is 0" << std::endl;
|
||||
#else
|
||||
sif::printWarning("ParameterCommand: Parameter data length is less than 12!\n");
|
||||
sif::printWarning("ParameterCommand: Parameter data length is 0!\n");
|
||||
#endif
|
||||
}
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
|
@ -72,6 +72,10 @@ enum: uint8_t {
|
||||
PUS_SERVICE_3, //PUS3
|
||||
PUS_SERVICE_9, //PUS9
|
||||
FILE_SYSTEM, //FILS
|
||||
HAL_SPI, //HSPI
|
||||
HAL_UART, //HURT
|
||||
HAL_I2C, //HI2C
|
||||
HAL_GPIO, //HGIO
|
||||
FW_CLASS_ID_COUNT // [EXPORT] : [END]
|
||||
|
||||
};
|
||||
|
@ -35,7 +35,7 @@ ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage,
|
||||
colorPrefix = sif::ANSI_COLOR_GREEN;
|
||||
}
|
||||
else if(setMessage.find("WARNING") != std::string::npos) {
|
||||
colorPrefix = sif::ANSI_COLOR_YELLOW;
|
||||
colorPrefix = sif::ANSI_COLOR_MAGENTA;
|
||||
}
|
||||
else if(setMessage.find("ERROR") != std::string::npos) {
|
||||
colorPrefix = sif::ANSI_COLOR_RED;
|
||||
@ -171,6 +171,10 @@ bool ServiceInterfaceBuffer::crAdditionEnabled() const {
|
||||
return addCrToPreamble;
|
||||
}
|
||||
|
||||
void ServiceInterfaceBuffer::setAsciiColorPrefix(std::string colorPrefix) {
|
||||
this->colorPrefix = colorPrefix;
|
||||
}
|
||||
|
||||
#ifdef UT699
|
||||
#include "../osal/rtems/Interrupt.h"
|
||||
|
||||
|
@ -48,6 +48,7 @@ private:
|
||||
|
||||
#if FSFW_COLORED_OUTPUT == 1
|
||||
std::string colorPrefix;
|
||||
void setAsciiColorPrefix(std::string colorPrefix);
|
||||
#endif
|
||||
|
||||
// For EOF detection
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
//! https://stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format
|
||||
//! Can be used to print out binary numbers in human-readable format.
|
||||
//! Example usage:
|
||||
//! sif::printInfo("Status register: " BYTE_TO_BINARY_PATTERN "\n",BYTE_TO_BINARY(0x1f));
|
||||
#define BYTE_TO_BINARY_PATTERN "%c%c%c%c%c%c%c%c"
|
||||
#define BYTE_TO_BINARY(byte) \
|
||||
(byte & 0x80 ? '1' : '0'), \
|
||||
|
@ -19,5 +19,9 @@ bool ServiceInterfaceStream::crAdditionEnabled() const {
|
||||
return streambuf.crAdditionEnabled();
|
||||
}
|
||||
|
||||
void ServiceInterfaceStream::setAsciiColorPrefix(std::string asciiColorCode) {
|
||||
streambuf.setAsciiColorPrefix(asciiColorCode);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -46,6 +46,8 @@ public:
|
||||
*/
|
||||
bool crAdditionEnabled() const;
|
||||
|
||||
void setAsciiColorPrefix(std::string asciiColorCode);
|
||||
|
||||
protected:
|
||||
ServiceInterfaceBuffer streambuf;
|
||||
};
|
||||
|
@ -1,5 +1,8 @@
|
||||
#include "LocalPool.h"
|
||||
#include <FSFWConfig.h>
|
||||
#include "FSFWConfig.h"
|
||||
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig,
|
||||
@ -185,7 +188,7 @@ ReturnValue_t LocalPool::initialize() {
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
internalErrorReporter = objectManager->get<InternalErrorReporterIF>(
|
||||
internalErrorReporter = ObjectManager::instance()->get<InternalErrorReporterIF>(
|
||||
objects::INTERNAL_ERROR_REPORTER);
|
||||
if (internalErrorReporter == nullptr){
|
||||
return ObjectManagerIF::INTERNAL_ERR_REPORTER_UNINIT;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "Subsystem.h"
|
||||
|
||||
#include "../health/HealthMessage.h"
|
||||
#include "../objectmanager/ObjectManagerIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../serialize/SerialArrayListAdapter.h"
|
||||
#include "../serialize/SerialFixedArrayListAdapter.h"
|
||||
#include "../serialize/SerializeElement.h"
|
||||
@ -477,13 +478,13 @@ ReturnValue_t Subsystem::initialize() {
|
||||
return result;
|
||||
}
|
||||
|
||||
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
if (IPCStore == NULL) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
#if FSFW_USE_MODESTORE == 1
|
||||
modeStore = objectManager->get<ModeStoreIF>(objects::MODE_STORE);
|
||||
modeStore = ObjectManager::instance()->get<ModeStoreIF>(objects::MODE_STORE);
|
||||
|
||||
if (modeStore == nullptr) {
|
||||
return RETURN_FAILED;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "../subsystem/SubsystemBase.h"
|
||||
#include "SubsystemBase.h"
|
||||
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../ipc/QueueFactory.h"
|
||||
|
||||
SubsystemBase::SubsystemBase(object_id_t setObjectId, object_id_t parent,
|
||||
@ -19,10 +20,10 @@ SubsystemBase::~SubsystemBase() {
|
||||
ReturnValue_t SubsystemBase::registerChild(object_id_t objectId) {
|
||||
ChildInfo info;
|
||||
|
||||
HasModesIF *child = objectManager->get<HasModesIF>(objectId);
|
||||
HasModesIF *child = ObjectManager::instance()->get<HasModesIF>(objectId);
|
||||
// This is a rather ugly hack to have the changedHealth info for all
|
||||
// children available.
|
||||
HasHealthIF* healthChild = objectManager->get<HasHealthIF>(objectId);
|
||||
HasHealthIF* healthChild = ObjectManager::instance()->get<HasHealthIF>(objectId);
|
||||
if (child == nullptr) {
|
||||
if (healthChild == nullptr) {
|
||||
return CHILD_DOESNT_HAVE_MODES;
|
||||
@ -174,7 +175,7 @@ ReturnValue_t SubsystemBase::initialize() {
|
||||
}
|
||||
|
||||
if (parentId != objects::NO_OBJECT) {
|
||||
SubsystemBase *parent = objectManager->get<SubsystemBase>(parentId);
|
||||
SubsystemBase *parent = ObjectManager::instance()->get<SubsystemBase>(parentId);
|
||||
if (parent == nullptr) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "ModeSequenceMessage.h"
|
||||
|
||||
#include "../../objectmanager/ObjectManagerIF.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
#include "../../storagemanager/StorageManagerIF.h"
|
||||
|
||||
void ModeSequenceMessage::setModeSequenceMessage(CommandMessage* message,
|
||||
@ -50,7 +50,7 @@ void ModeSequenceMessage::clear(CommandMessage *message) {
|
||||
case TABLE_LIST:
|
||||
case TABLE:
|
||||
case SEQUENCE: {
|
||||
StorageManagerIF *ipcStore = objectManager->get<StorageManagerIF>(
|
||||
StorageManagerIF *ipcStore = ObjectManager::instance()->get<StorageManagerIF>(
|
||||
objects::IPC_STORE);
|
||||
if (ipcStore != nullptr){
|
||||
ipcStore->deleteData(ModeSequenceMessage::getStoreAddress(message));
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user