Merge branch 'mueller/master' of https://egit.irs.uni-stuttgart.de/KSat/fsfw into mueller/master
This commit is contained in:
commit
8b83541264
@ -131,9 +131,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})
|
||||
|
@ -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"
|
||||
|
@ -14,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
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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,4 +1,5 @@
|
||||
#include "MessageQueue.h"
|
||||
#include "unixUtility.h"
|
||||
|
||||
#include "../../serviceinterface/ServiceInterface.h"
|
||||
#include "../../objectmanager/ObjectManager.h"
|
||||
@ -13,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
|
||||
@ -32,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
|
||||
@ -43,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);
|
||||
@ -205,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,
|
||||
@ -222,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,
|
||||
@ -237,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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -263,29 +177,27 @@ 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;
|
||||
status = mq_setattr(id,&attrib,NULL);
|
||||
if(status != 0){
|
||||
switch(errno){
|
||||
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:
|
||||
@ -294,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;
|
||||
}
|
||||
@ -337,6 +252,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
bool ignoreFault) {
|
||||
if(message == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
<<<<<<< HEAD
|
||||
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message is "
|
||||
"nullptr!" << std::endl;
|
||||
#endif
|
||||
@ -373,11 +289,52 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
sif::error << strerror(errno) << " in "
|
||||
<<"mq_send to: " << sendTo << " sent from "
|
||||
<< sentFrom << std::endl;
|
||||
=======
|
||||
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message is nullptr!" << std::endl;
|
||||
#else
|
||||
sif::printError("MessageQueue::sendMessageFromMessageQueue: Message is nullptr!\n");
|
||||
>>>>>>> 38910143400e455f5184ad85be98e05638c2eea6
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
message->setSender(sentFrom);
|
||||
int result = mq_send(sendTo,
|
||||
reinterpret_cast<const char*>(message->getBuffer()),
|
||||
message->getMessageSize(),0);
|
||||
|
||||
//TODO: Check if we're in ISR.
|
||||
if (result != 0) {
|
||||
if(!ignoreFault){
|
||||
InternalErrorReporterIF* internalErrorReporter =
|
||||
objectManager->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
|
||||
if (internalErrorReporter != NULL) {
|
||||
internalErrorReporter->queueMessageNotSent();
|
||||
}
|
||||
}
|
||||
switch(errno){
|
||||
case EAGAIN:
|
||||
//The O_NONBLOCK flag was set when opening the queue, or the
|
||||
//MQ_NONBLOCK flag was set in its attributes, and the
|
||||
//specified queue is full.
|
||||
return MessageQueueIF::FULL;
|
||||
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::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:
|
||||
@ -388,22 +345,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");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#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),
|
||||
@ -32,6 +31,9 @@ ReturnValue_t PeriodicPosixTask::addComponent(object_id_t object) {
|
||||
#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;
|
||||
}
|
||||
@ -48,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(status != 0) {
|
||||
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){
|
||||
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
|
||||
if (status != 0) {
|
||||
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_ */
|
@ -1,7 +1,7 @@
|
||||
#ifndef FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
|
||||
#define FSFW_UNITTEST_TESTS_DATAPOOLLOCAL_LOCALPOOLOWNERBASE_H_
|
||||
|
||||
#include <testcfg/objects/systemObjectList.h>
|
||||
#include "objects/systemObjectList.h"
|
||||
|
||||
#include <fsfw/datapoollocal/HasLocalDataPoolIF.h>
|
||||
#include <fsfw/datapoollocal/LocalDataSet.h>
|
||||
|
Loading…
Reference in New Issue
Block a user