init changing all printout types
This commit is contained in:
parent
77055a1579
commit
1b34b90ae0
@ -442,7 +442,7 @@ string(CONCAT POST_BUILD_COMMENT
|
||||
# The additional / is important to remove the last character from the path.
|
||||
# Note that it does not matter if the OS uses / or \, because we are only
|
||||
# saving the path size.
|
||||
string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE)
|
||||
string(LENGTH "${CMAKE_SOURCE_DIR}/" FSFW_SOURCE_PATH_SIZE)
|
||||
target_compile_definitions(${LIB_FSFW_NAME} PRIVATE "-DFSFW_SOURCE_PATH_SIZE=${FSFW_SOURCE_PATH_SIZE}")
|
||||
|
||||
add_custom_command(
|
||||
|
@ -26,19 +26,10 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
|
||||
std::string deviceFile;
|
||||
|
||||
if (cookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::initializeInterface: Invalid cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("{}", "initializeInterface: Invalid cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
I2cCookie* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||
if (i2cCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::initializeInterface: Invalid I2C cookie!" << std::endl;
|
||||
#endif
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||
i2cAddress = i2cCookie->getAddress();
|
||||
|
||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||
@ -47,20 +38,14 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
|
||||
I2cInstance i2cInstance = {std::vector<uint8_t>(maxReplyLen), 0};
|
||||
auto statusPair = i2cDeviceMap.emplace(i2cAddress, i2cInstance);
|
||||
if (not statusPair.second) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::initializeInterface: Failed to insert device with address "
|
||||
<< i2cAddress << "to I2C device "
|
||||
<< "map" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n",
|
||||
i2cAddress);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::initializeInterface: Device with address " << i2cAddress
|
||||
<< "already in use" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("initializeInterface: Device with address {} already in use\n", i2cAddress);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -70,9 +55,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
std::string deviceFile;
|
||||
|
||||
if (sendData == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::sendMessage: Send Data is nullptr" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "sendMessage: Send Data is nullptr\n");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -80,21 +63,16 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
I2cCookie* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||
if (i2cCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::sendMessage: Invalid I2C Cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "sendMessage: Invalid I2C Cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
address_t i2cAddress = i2cCookie->getAddress();
|
||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not "
|
||||
<< "registered in i2cDeviceMap" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "sendMessage: I2C address of cookie not registered in I2C device map\n");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -109,11 +87,8 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
}
|
||||
|
||||
if (write(fd, sendData, sendLen) != static_cast<int>(sendLen)) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::sendMessage: Failed to send data to I2C "
|
||||
"device with error code "
|
||||
<< errno << ". Error description: " << strerror(errno) << std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("sendMessage: Failed to send data to I2C device with error code {} | {}\n", errno,
|
||||
strerror(errno));
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -135,11 +110,9 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
I2cCookie* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||
if (i2cCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::requestReceiveMessage: Invalid I2C Cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "requestReceiveMessage: Invalid I2C Cookie\n");
|
||||
i2cDeviceMapIter->second.replyLen = 0;
|
||||
return NULLPOINTER;
|
||||
}
|
||||
@ -147,10 +120,8 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
||||
address_t i2cAddress = i2cCookie->getAddress();
|
||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::requestReceiveMessage: i2cAddress of Cookie not "
|
||||
<< "registered in i2cDeviceMap" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("requestReceiveMessage: I2C address {} of Cookie not registered in i2cDeviceMap",
|
||||
i2cAddress);
|
||||
i2cDeviceMapIter->second.replyLen = 0;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
@ -168,20 +139,13 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
||||
|
||||
uint8_t* replyBuffer = i2cDeviceMapIter->second.replyBuffer.data();
|
||||
|
||||
int readLen = read(fd, replyBuffer, requestLen);
|
||||
ssize_t readLen = read(fd, replyBuffer, requestLen);
|
||||
if (readLen != static_cast<int>(requestLen)) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1 and FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::requestReceiveMessage: Reading from I2C "
|
||||
<< "device failed with error code " << errno << ". Description"
|
||||
<< " of error: " << strerror(errno) << std::endl;
|
||||
sif::error << "I2cComIF::requestReceiveMessage: Read only " << readLen << " from " << requestLen
|
||||
<< " bytes" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT(
|
||||
"requestReceiveMessage: Reading from I2C device failed with error code "
|
||||
"{} | {}\nRead only {} from {} bytes\n",
|
||||
errno, strerror(errno), readLen, requestLen);
|
||||
i2cDeviceMapIter->second.replyLen = 0;
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen
|
||||
<< " bytes" << std::endl;
|
||||
#endif
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -195,21 +159,17 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
|
||||
}
|
||||
|
||||
ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
||||
I2cCookie* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
|
||||
if (i2cCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::readReceivedMessage: Invalid I2C Cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
address_t i2cAddress = i2cCookie->getAddress();
|
||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not "
|
||||
<< "found in i2cDeviceMap" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("readReceivedMessage: I2C address {} of cookie not found in I2C device map\n",
|
||||
i2cAddress);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
*buffer = i2cDeviceMapIter->second.replyBuffer.data();
|
||||
@ -221,16 +181,8 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
||||
ReturnValue_t I2cComIF::openDevice(std::string deviceFile, address_t i2cAddress,
|
||||
int* fileDescriptor) {
|
||||
if (ioctl(*fileDescriptor, I2C_SLAVE, i2cAddress) < 0) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "I2cComIF: Specifying target device failed with error code " << errno << "."
|
||||
<< std::endl;
|
||||
sif::warning << "Error description " << strerror(errno) << std::endl;
|
||||
#else
|
||||
sif::printWarning("I2cComIF: Specifying target device failed with error code %d.\n");
|
||||
sif::printWarning("Error description: %s\n", strerror(errno));
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno,
|
||||
strerror(errno));
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw_hal/linux/UnixFileGuard.h"
|
||||
#include "fsfw_hal/linux/spi/SpiCookie.h"
|
||||
#include "fsfw_hal/linux/utility.h"
|
||||
@ -18,13 +19,7 @@
|
||||
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF)
|
||||
: SystemObject(objectId), gpioComIF(gpioComIF) {
|
||||
if (gpioComIF == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::SpiComIF: GPIO communication interface invalid!" << std::endl;
|
||||
#else
|
||||
sif::printError("SpiComIF::SpiComIF: GPIO communication interface invalid!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGET("{}", "SpiComIF::SpiComIF: GPIO communication interface invalid\n");
|
||||
}
|
||||
|
||||
spiMutex = MutexFactory::instance()->createMutex();
|
||||
@ -32,7 +27,7 @@ SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF)
|
||||
|
||||
ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
||||
int retval = 0;
|
||||
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
auto* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
if (spiCookie == nullptr) {
|
||||
return NULLPOINTER;
|
||||
}
|
||||
@ -45,30 +40,17 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
||||
SpiInstance spiInstance(bufferSize);
|
||||
auto statusPair = spiDeviceMap.emplace(spiAddress, spiInstance);
|
||||
if (not statusPair.second) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::initializeInterface: Failed to insert device with address "
|
||||
<< spiAddress << "to SPI device map" << std::endl;
|
||||
#else
|
||||
sif::printError(
|
||||
"SpiComIF::initializeInterface: Failed to insert device with address "
|
||||
"%lu to SPI device map\n",
|
||||
static_cast<unsigned long>(spiAddress));
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGWT(
|
||||
"SpiComIF::initializeInterface: Failed to insert device with address {} to SPI device "
|
||||
"map\n",
|
||||
spiAddress);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
/* Now we emplaced the read buffer in the map, we still need to assign that location
|
||||
to the SPI driver transfer struct */
|
||||
spiCookie->assignReadBuffer(statusPair.first->second.replyBuffer.data());
|
||||
} else {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::initializeInterface: SPI address already exists!" << std::endl;
|
||||
#else
|
||||
sif::printError("SpiComIF::initializeInterface: SPI address already exists!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGWT("{}", "initializeInterface: SPI address already exists\n");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -133,7 +115,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) {
|
||||
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
auto* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
|
||||
if (spiCookie == nullptr) {
|
||||
@ -141,19 +123,9 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
}
|
||||
|
||||
if (sendLen > spiCookie->getMaxBufferSize()) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "SpiComIF::sendMessage: Too much data sent, send length " << sendLen
|
||||
<< "larger than maximum buffer length " << spiCookie->getMaxBufferSize()
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"SpiComIF::sendMessage: Too much data sent, send length %lu larger "
|
||||
"than maximum buffer length %lu!\n",
|
||||
static_cast<unsigned long>(sendLen),
|
||||
static_cast<unsigned long>(spiCookie->getMaxBufferSize()));
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGW(
|
||||
"sendMessage: Too much data sent, send length {} larger than maximum buffer length {}\n",
|
||||
spiCookie->getMaxBufferSize(), sendLen);
|
||||
return DeviceCommunicationIF::TOO_MUCH_DATA;
|
||||
}
|
||||
|
||||
@ -201,24 +173,12 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
||||
if (gpioId != gpio::NO_GPIO) {
|
||||
result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::sendMessage: Failed to lock mutex" << std::endl;
|
||||
#else
|
||||
sif::printError("SpiComIF::sendMessage: Failed to lock mutex\n");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGET("{}", "sendMessage: Failed to lock mutex\n");
|
||||
return result;
|
||||
}
|
||||
ReturnValue_t result = gpioComIF->pullLow(gpioId);
|
||||
result = gpioComIF->pullLow(gpioId);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "SpiComIF::sendMessage: Pulling low CS pin failed" << std::endl;
|
||||
#else
|
||||
sif::printWarning("SpiComIF::sendMessage: Pulling low CS pin failed");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGW("{}", "sendMessage: Pulling low CS pin failed\n");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -237,13 +197,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
||||
} else {
|
||||
/* We write with a blocking half-duplex transfer here */
|
||||
if (write(fileDescriptor, sendData, sendLen) != static_cast<ssize_t>(sendLen)) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "SpiComIF::sendMessage: Half-Duplex write operation failed!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("SpiComIF::sendMessage: Half-Duplex write operation failed!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGET("{}", "sendMessage: Half-Duplex write operation failed\n");
|
||||
result = HALF_DUPLEX_TRANSFER_FAILED;
|
||||
}
|
||||
}
|
||||
@ -252,9 +206,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
||||
gpioComIF->pullHigh(gpioId);
|
||||
result = spiMutex->unlockMutex();
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::sendMessage: Failed to unlock mutex" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "sendMessage: Failed to unlock mutex\n");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -264,7 +216,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
|
||||
ReturnValue_t SpiComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; }
|
||||
|
||||
ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
|
||||
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
auto* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
if (spiCookie == nullptr) {
|
||||
return NULLPOINTER;
|
||||
}
|
||||
@ -296,22 +248,14 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
|
||||
if (gpioId != gpio::NO_GPIO) {
|
||||
result = spiMutex->lockMutex(timeoutType, timeoutMs);
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::getSendSuccess: Failed to lock mutex" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "getSendSuccess: Failed to lock mutex\n");
|
||||
return result;
|
||||
}
|
||||
gpioComIF->pullLow(gpioId);
|
||||
}
|
||||
|
||||
if (read(fileDescriptor, rxBuf, readSize) != static_cast<ssize_t>(readSize)) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "SpiComIF::sendMessage: Half-Duplex read operation failed!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("SpiComIF::sendMessage: Half-Duplex read operation failed!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGW("{}", "sendMessage: Half-Duplex read operation failed\n");
|
||||
result = HALF_DUPLEX_TRANSFER_FAILED;
|
||||
}
|
||||
|
||||
@ -319,9 +263,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
|
||||
gpioComIF->pullHigh(gpioId);
|
||||
result = spiMutex->unlockMutex();
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SpiComIF::getSendSuccess: Failed to unlock mutex" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "getSendSuccess: Failed to unlock mutex\n");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -330,7 +272,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
||||
SpiCookie* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
auto* spiCookie = dynamic_cast<SpiCookie*>(cookie);
|
||||
if (spiCookie == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
@ -361,16 +303,10 @@ void SpiComIF::performSpiWiretapping(SpiCookie* spiCookie) {
|
||||
return;
|
||||
}
|
||||
size_t dataLen = spiCookie->getTransferStructHandle()->len;
|
||||
uint8_t* dataPtr = reinterpret_cast<uint8_t*>(spiCookie->getTransferStructHandle()->tx_buf);
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Sent SPI data: " << std::endl;
|
||||
auto* dataPtr = reinterpret_cast<uint8_t*>(spiCookie->getTransferStructHandle()->tx_buf);
|
||||
sif::info("Sent SPI data:\n");
|
||||
arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false);
|
||||
sif::info << "Received SPI data: " << std::endl;
|
||||
#else
|
||||
sif::printInfo("Sent SPI data: \n");
|
||||
arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false);
|
||||
sif::printInfo("Received SPI data: \n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
sif::info("Received SPI data:\n");
|
||||
dataPtr = reinterpret_cast<uint8_t*>(spiCookie->getTransferStructHandle()->rx_buf);
|
||||
arrayprinter::print(dataPtr, dataLen, OutputType::HEX, false);
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
#include "UartComIF.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
@ -23,11 +23,9 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "UartComIF::initializeInterface: Invalid UART Cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("{}", "initializeInterface: Invalid UART Cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
@ -42,18 +40,12 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
|
||||
size_t maxReplyLen = uartCookie->getMaxReplyLen();
|
||||
UartElements uartElements = {fileDescriptor, std::vector<uint8_t>(maxReplyLen), 0};
|
||||
auto status = uartDeviceMap.emplace(deviceFile, uartElements);
|
||||
if (status.second == false) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::initializeInterface: Failed to insert device " << deviceFile
|
||||
<< "to UART device map" << std::endl;
|
||||
#endif
|
||||
if (!status.second) {
|
||||
FSFW_LOGW("initializeInterface: Failed to insert device {} to UART device map\n", deviceFile);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::initializeInterface: UART device " << deviceFile
|
||||
<< " already in use" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("initializeInterface: UART device {} already in use\n", deviceFile);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -73,19 +65,14 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
|
||||
int fd = open(deviceFile.c_str(), flags);
|
||||
|
||||
if (fd < 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::configureUartPort: Failed to open uart " << deviceFile
|
||||
<< "with error code " << errno << strerror(errno) << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("configureUartPort: Failed to open UART {} with error code {} | {}\n", deviceFile,
|
||||
errno, strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
|
||||
/* Read in existing settings */
|
||||
if (tcgetattr(fd, &options) != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::configureUartPort: Error " << errno
|
||||
<< "from tcgetattr: " << strerror(errno) << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
|
||||
@ -106,10 +93,8 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
|
||||
|
||||
/* Save option settings */
|
||||
if (tcsetattr(fd, TCSANOW, &options) != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::configureUartPort: Failed to set options with error " << errno
|
||||
<< ": " << strerror(errno);
|
||||
#endif
|
||||
FSFW_LOGW("configureUartPort: Failed to set options with error {} | {}\n", errno,
|
||||
strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
return fd;
|
||||
@ -161,9 +146,8 @@ void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCook
|
||||
options->c_cflag |= CS8;
|
||||
break;
|
||||
default:
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::setDatasizeOptions: Invalid size specified" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("setDatasizeOptions: Invalid size {} specified\n",
|
||||
static_cast<unsigned int>(uartCookie->getBitsPerWord()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -314,11 +298,9 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki
|
||||
cfsetispeed(options, B4000000);
|
||||
cfsetospeed(options, B4000000);
|
||||
break;
|
||||
#endif // ! __APPLE__
|
||||
#endif // ! __APPLE__
|
||||
default:
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::configureBaudrate: Baudrate not supported" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -333,37 +315,27 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData,
|
||||
}
|
||||
|
||||
if (sendData == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::sendMessage: Send data is nullptr" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "sendMessage: Send data is nullptr");
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::sendMessasge: Invalid UART Cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "sendMessage: Invalid UART Cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
deviceFile = uartCookie->getDeviceFile();
|
||||
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "UartComIF::sendMessage: Device file " << deviceFile << "not in UART map"
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "sendMessage: Device file {} not in UART map\n", deviceFile);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
fd = uartDeviceMapIter->second.fileDescriptor;
|
||||
|
||||
if (write(fd, sendData, sendLen) != static_cast<int>(sendLen)) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "UartComIF::sendMessage: Failed to send data with error code " << errno
|
||||
<< ": Error description: " << strerror(errno) << std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno));
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -376,11 +348,9 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
|
||||
std::string deviceFile;
|
||||
UartDeviceMapIter uartDeviceMapIter;
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "UartComIF::requestReceiveMessage: Invalid Uart Cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
@ -393,10 +363,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
|
||||
}
|
||||
|
||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "UartComIF::requestReceiveMessage: Device file " << deviceFile
|
||||
<< " not in uart map" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -414,7 +381,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
uint8_t maxReadCycles = uartCookie.getReadCycles();
|
||||
uint8_t currentReadCycles = 0;
|
||||
int bytesRead = 0;
|
||||
ssize_t bytesRead = 0;
|
||||
size_t currentBytesRead = 0;
|
||||
size_t maxReplySize = uartCookie.getMaxReplyLen();
|
||||
int fd = iter->second.fileDescriptor;
|
||||
@ -425,16 +392,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
||||
if (currentBytesRead >= maxReplySize) {
|
||||
// Overflow risk. Emit warning, trigger event and break. If this happens,
|
||||
// the reception buffer is not large enough or data is not polled often enough.
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::requestReceiveMessage: Next read would cause overflow!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"UartComIF::requestReceiveMessage: "
|
||||
"Next read would cause overflow!");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n");
|
||||
result = UART_RX_BUFFER_TOO_SMALL;
|
||||
break;
|
||||
} else {
|
||||
@ -445,15 +403,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
||||
if (bytesRead < 0) {
|
||||
// EAGAIN: No data available in non-blocking mode
|
||||
if (errno != EAGAIN) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::handleCanonicalRead: read failed with code" << errno << ": "
|
||||
<< strerror(errno) << std::endl;
|
||||
#else
|
||||
sif::printWarning("UartComIF::handleCanonicalRead: read failed with code %d: %s\n", errno,
|
||||
strerror(errno));
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno));
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -473,27 +423,16 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi
|
||||
auto bufferPtr = iter->second.replyBuffer.data();
|
||||
// Size check to prevent buffer overflow
|
||||
if (requestLen > uartCookie.getMaxReplyLen()) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::requestReceiveMessage: Next read would cause overflow!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"UartComIF::requestReceiveMessage: "
|
||||
"Next read would cause overflow!");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGW("{}", "requestReceiveMessage: Next read would cause overflow\n");
|
||||
return UART_RX_BUFFER_TOO_SMALL;
|
||||
}
|
||||
int bytesRead = read(fd, bufferPtr, requestLen);
|
||||
ssize_t bytesRead = read(fd, bufferPtr, requestLen);
|
||||
if (bytesRead < 0) {
|
||||
return RETURN_FAILED;
|
||||
} else if (bytesRead != static_cast<int>(requestLen)) {
|
||||
if (uartCookie.isReplySizeFixed()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::requestReceiveMessage: Only read " << bytesRead << " of "
|
||||
<< requestLen << " bytes" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead,
|
||||
requestLen);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
@ -505,21 +444,16 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
||||
std::string deviceFile;
|
||||
UartDeviceMapIter uartDeviceMapIter;
|
||||
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "UartComIF::readReceivedMessage: Invalid uart cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "readReceivedMessage: Invalid uart cookie");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
deviceFile = uartCookie->getDeviceFile();
|
||||
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "UartComIF::readReceivedMessage: Device file " << deviceFile << " not in uart map"
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -535,11 +469,9 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
||||
ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
|
||||
std::string deviceFile;
|
||||
UartDeviceMapIter uartDeviceMapIter;
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::flushUartRxBuffer: Invalid uart cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
deviceFile = uartCookie->getDeviceFile();
|
||||
@ -555,11 +487,9 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
|
||||
ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
|
||||
std::string deviceFile;
|
||||
UartDeviceMapIter uartDeviceMapIter;
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::flushUartTxBuffer: Invalid uart cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
deviceFile = uartCookie->getDeviceFile();
|
||||
@ -575,11 +505,9 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
|
||||
ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
|
||||
std::string deviceFile;
|
||||
UartDeviceMapIter uartDeviceMapIter;
|
||||
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "UartComIF::flushUartTxAndRxBuf: Invalid uart cookie!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
deviceFile = uartCookie->getDeviceFile();
|
||||
|
@ -90,7 +90,7 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject {
|
||||
* parity settings.
|
||||
*
|
||||
*/
|
||||
void setParityOptions(struct termios* options, UartCookie* uartCookie);
|
||||
static void setParityOptions(struct termios* options, UartCookie* uartCookie);
|
||||
|
||||
void setStopBitOptions(struct termios* options, UartCookie* uartCookie);
|
||||
|
||||
|
@ -12,7 +12,7 @@ enum class StopBits { ONE_STOP_BIT, TWO_STOP_BITS };
|
||||
|
||||
enum class UartModes { CANONICAL, NON_CANONICAL };
|
||||
|
||||
enum class BitsPerWord { BITS_5, BITS_6, BITS_7, BITS_8 };
|
||||
enum class BitsPerWord : unsigned int { BITS_5 = 5, BITS_6 = 6, BITS_7 = 7, BITS_8 = 8 };
|
||||
|
||||
enum class UartBaudRate {
|
||||
RATE_50,
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "fsfw/action.h"
|
||||
#include "fsfw/ipc/MessageQueueSenderIF.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
ActionHelper::ActionHelper(HasActionsIF* setOwner, MessageQueueIF* useThisQueue)
|
||||
: owner(setOwner), queueToUse(useThisQueue) {}
|
||||
@ -28,13 +28,7 @@ ReturnValue_t ActionHelper::initialize(MessageQueueIF* queueToUse_) {
|
||||
}
|
||||
|
||||
if (queueToUse == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ActionHelper::initialize: No queue set" << std::endl;
|
||||
#else
|
||||
sif::printWarning("ActionHelper::initialize: No queue set\n");
|
||||
#endif
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGW("{}", "initialize: No queue set\n");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -96,14 +90,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = ipcStore->getFreeElement(&storeAddress, maxSize, &dataPtr);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ActionHelper::reportData: Getting free element from IPC store failed!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"ActionHelper::reportData: Getting free element from IPC "
|
||||
"store failed!\n");
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "reportData: Getting free element from IPC store failed\n");
|
||||
return result;
|
||||
}
|
||||
result = data->serialize(&dataPtr, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||
@ -138,11 +125,7 @@ ReturnValue_t ActionHelper::reportData(MessageQueueId_t reportTo, ActionId_t rep
|
||||
store_address_t storeAddress;
|
||||
ReturnValue_t result = ipcStore->addData(&storeAddress, data, dataSize);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ActionHelper::reportData: Adding data to IPC store failed!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("ActionHelper::reportData: Adding data to IPC store failed!\n");
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "reportData: Adding data to IPC store failed\n");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "fsfw/ipc/CommandMessage.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw/storagemanager/storeAddress.h"
|
||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||
|
||||
@ -28,13 +29,7 @@ ReturnValue_t CFDPHandler::initialize() {
|
||||
}
|
||||
|
||||
ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "CFDPHandler::handleRequest" << std::endl;
|
||||
#else
|
||||
sif::printDebug("CFDPHandler::handleRequest\n");
|
||||
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif
|
||||
FSFW_LOGDT("{}", "CFDPHandler::handleRequest\n");
|
||||
|
||||
// TODO read out packet from store using storeId
|
||||
|
||||
|
@ -50,17 +50,9 @@ ReturnValue_t EofPduDeserializer::parseData() {
|
||||
if (info.getConditionCode() != cfdp::ConditionCode::NO_ERROR) {
|
||||
EntityIdTlv* tlvPtr = info.getFaultLoc();
|
||||
if (tlvPtr == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "EofPduDeserializer::parseData: Ca not deserialize fault location,"
|
||||
" given TLV pointer invalid"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"EofPduDeserializer::parseData: Ca not deserialize fault location,"
|
||||
" given TLV pointer invalid");
|
||||
#endif
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGW("{}",
|
||||
"parseData: Ca not deserialize fault location,"
|
||||
" given TLV pointer invalid\n");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
result = tlvPtr->deSerialize(&bufPtr, &deserLen, endianness);
|
||||
|
@ -7,13 +7,7 @@
|
||||
cfdp::VarLenField::VarLenField(cfdp::WidthInBytes width, size_t value) : VarLenField() {
|
||||
ReturnValue_t result = this->setValue(width, value);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "cfdp::VarLenField: Setting value failed" << std::endl;
|
||||
#else
|
||||
sif::printWarning("cfdp::VarLenField: Setting value failed\n");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGW("{}", "cfdp::VarLenField: Setting value failed\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
#include <fsfw/cfdp/tlv/Tlv.h>
|
||||
#include <fsfw/cfdp/tlv/TlvIF.h>
|
||||
#include <fsfw/serialize/SerializeIF.h>
|
||||
#include <fsfw/serviceinterface/ServiceInterface.h>
|
||||
#include <fsfw/serviceinterface.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
@ -128,17 +128,7 @@ class FilestoreTlvBase : public TlvIF {
|
||||
}
|
||||
|
||||
void secondFileNameMissing() const {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "FilestoreRequestTlv::deSerialize: Second file name required"
|
||||
" but TLV pointer not set"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"FilestoreRequestTlv::deSerialize: Second file name required"
|
||||
" but TLV pointer not set\n");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "secondFileNameMissing: Second file name required but TLV pointer not set\n");
|
||||
}
|
||||
|
||||
FilestoreActionCode getActionCode() const { return actionCode; }
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/datapool/ReadCommitIFAttorney.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
PoolDataSetBase::PoolDataSetBase(PoolVariableIF** registeredVariablesArray,
|
||||
const size_t maxFillCount)
|
||||
@ -17,27 +17,15 @@ ReturnValue_t PoolDataSetBase::registerVariable(PoolVariableIF* variable) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (state != States::STATE_SET_UNINITIALISED) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "DataSet::registerVariable: Call made in wrong position." << std::endl;
|
||||
#else
|
||||
sif::printError("DataSet::registerVariable: Call made in wrong position.");
|
||||
#endif
|
||||
FSFW_LOGW("{}", "registerVariable: Call made in wrong position\n");
|
||||
return DataSetIF::DATA_SET_UNINITIALISED;
|
||||
}
|
||||
if (variable == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "DataSet::registerVariable: Pool variable is nullptr." << std::endl;
|
||||
#else
|
||||
sif::printError("DataSet::registerVariable: Pool variable is nullptr.\n");
|
||||
#endif
|
||||
FSFW_LOGW("{}", "registerVariable: Pool variable is nullptr\n");
|
||||
return DataSetIF::POOL_VAR_NULL;
|
||||
}
|
||||
if (fillCount >= maxFillCount) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "DataSet::registerVariable: DataSet is full." << std::endl;
|
||||
#else
|
||||
sif::printError("DataSet::registerVariable: DataSet is full.\n");
|
||||
#endif
|
||||
FSFW_LOGW("{}", "registerVariable: DataSet is full\n");
|
||||
return DataSetIF::DATA_SET_FULL;
|
||||
}
|
||||
registeredVariables[fillCount] = variable;
|
||||
@ -59,15 +47,7 @@ ReturnValue_t PoolDataSetBase::read(MutexIF::TimeoutType timeoutType, uint32_t l
|
||||
state = States::STATE_SET_WAS_READ;
|
||||
unlockDataPool();
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "PoolDataSetBase::read: Call made in wrong position. Don't forget to "
|
||||
"commit member datasets!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"PoolDataSetBase::read: Call made in wrong position. Don't forget to "
|
||||
"commit member datasets!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
FSFW_LOGWT("{}", "read: Call made in wrong position. commit call might be missing\n");
|
||||
result = SET_WAS_ALREADY_READ;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
template <typename T>
|
||||
PoolEntry<T>::PoolEntry(std::initializer_list<T> initValue, bool setValid)
|
||||
@ -68,13 +68,7 @@ void PoolEntry<T>::print() {
|
||||
} else {
|
||||
validString = "Invalid";
|
||||
}
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "PoolEntry information." << std::endl;
|
||||
sif::info << "PoolEntry validity: " << validString << std::endl;
|
||||
#else
|
||||
sif::printInfo("PoolEntry information.\n");
|
||||
sif::printInfo("PoolEntry validity: %s\n", validString);
|
||||
#endif
|
||||
FSFW_LOGI("PoolEntry Info. Validity {}\n", validString);
|
||||
arrayprinter::print(reinterpret_cast<uint8_t*>(address), getByteSize());
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
#ifndef FSFW_DATAPOOL_POOLREADHELPER_H_
|
||||
#define FSFW_DATAPOOL_POOLREADHELPER_H_
|
||||
|
||||
#include <FSFWConfig.h>
|
||||
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "ReadCommitIF.h"
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
/**
|
||||
* @brief Helper class to read data sets or pool variables
|
||||
@ -18,13 +17,7 @@ class PoolReadGuard {
|
||||
if (readObject != nullptr) {
|
||||
readResult = readObject->read(timeoutType, mutexTimeout);
|
||||
if (readResult != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL == 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PoolReadHelper: Read failed!" << std::endl;
|
||||
#else
|
||||
sif::printError("PoolReadHelper: Read failed!\n");
|
||||
#endif /* FSFW_PRINT_VERBOSITY_LEVEL == 1 */
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
FSFW_LOGW("{}", "ctor: Read failed\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,15 +166,7 @@ class HasLocalDataPoolIF {
|
||||
* @return
|
||||
*/
|
||||
virtual LocalPoolObjectBase* getPoolObjectHandle(lp_id_t localPoolId) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden. "
|
||||
"Returning nullptr!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"HasLocalDataPoolIF::getPoolObjectHandle: "
|
||||
"Not overriden. Returning nullptr!\n");
|
||||
#endif
|
||||
FSFW_LOGW("{}", "HasLocalDataPoolIF::getPoolObjectHandle: Not overriden. Returning nullptr\n");
|
||||
return nullptr;
|
||||
}
|
||||
};
|
||||
|
@ -695,11 +695,7 @@ void LocalDataPoolManager::performPeriodicHkGeneration(HkReceiver& receiver) {
|
||||
ReturnValue_t result = generateHousekeepingPacket(sid, dataSet, true);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
/* Configuration error */
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalDataPoolManager::performHkOperation: HK generation failed." << std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalDataPoolManager::performHkOperation: HK generation failed.\n");
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "performHkOperation: HK generation failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "fsfw/housekeeping/PeriodicHousekeepingHelper.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serialize/SerializeAdapter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "internal/HasLocalDpIFUserAttorney.h"
|
||||
|
||||
LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t setId,
|
||||
@ -16,14 +16,7 @@ LocalPoolDataSetBase::LocalPoolDataSetBase(HasLocalDataPoolIF *hkOwner, uint32_t
|
||||
: PoolDataSetBase(registeredVariablesArray, maxNumberOfVariables) {
|
||||
if (hkOwner == nullptr) {
|
||||
// Configuration error.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
|
||||
<< "invalid!" << std::endl;
|
||||
#else
|
||||
sif::printError(
|
||||
"LocalPoolDataSetBase::LocalPoolDataSetBase: Owner "
|
||||
"invalid!\n\r");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
FSFW_LOGW("{}", "LocalPoolDataSetBase::LocalPoolDataSetBase: Owner invalid\n");
|
||||
return;
|
||||
}
|
||||
AccessPoolManagerIF *accessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
@ -186,14 +179,7 @@ ReturnValue_t LocalPoolDataSetBase::serializeLocalPoolIds(uint8_t **buffer, size
|
||||
auto result =
|
||||
SerializeAdapter::serialize(¤tPoolId, buffer, size, maxSize, streamEndianness);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolDataSetBase::serializeLocalPoolIds: "
|
||||
<< "Serialization error!" << std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"LocalPoolDataSetBase::serializeLocalPoolIds: "
|
||||
"Serialization error!\n\r");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
FSFW_LOGW("{}", "serializeLocalPoolIds: Serialization error\n");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -4,22 +4,17 @@
|
||||
#include "fsfw/datapoollocal/HasLocalDataPoolIF.h"
|
||||
#include "fsfw/datapoollocal/LocalDataPoolManager.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "internal/HasLocalDpIFUserAttorney.h"
|
||||
|
||||
LocalPoolObjectBase::LocalPoolObjectBase(lp_id_t poolId, HasLocalDataPoolIF* hkOwner,
|
||||
DataSetIF* dataSet, pool_rwm_t setReadWriteMode)
|
||||
: localPoolId(poolId), readWriteMode(setReadWriteMode) {
|
||||
if (poolId == PoolVariableIF::NO_PARAMETER) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
|
||||
<< "which is the NO_PARAMETER value!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n");
|
||||
}
|
||||
if (hkOwner == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPoolVar<T>::LocalPoolVar: The supplied pool "
|
||||
<< "owner is a invalid!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGET("{}", "ctor: Supplied pool owner is a invalid\n");
|
||||
return;
|
||||
}
|
||||
AccessPoolManagerIF* poolManAccessor = HasLocalDpIFUserAttorney::getAccessorHandle(hkOwner);
|
||||
@ -34,28 +29,14 @@ LocalPoolObjectBase::LocalPoolObjectBase(object_id_t poolOwner, lp_id_t poolId,
|
||||
pool_rwm_t setReadWriteMode)
|
||||
: localPoolId(poolId), readWriteMode(setReadWriteMode) {
|
||||
if (poolId == PoolVariableIF::NO_PARAMETER) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
|
||||
"which is the NO_PARAMETER value!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"LocalPoolVar<T>::LocalPoolVar: 0 passed as pool ID, "
|
||||
"which is the NO_PARAMETER value!\n");
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "ctor: Invalid pool ID, has NO_PARAMETER value\n");
|
||||
}
|
||||
HasLocalDataPoolIF* hkOwner = ObjectManager::instance()->get<HasLocalDataPoolIF>(poolOwner);
|
||||
auto* hkOwner = ObjectManager::instance()->get<HasLocalDataPoolIF>(poolOwner);
|
||||
if (hkOwner == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPoolVariable: The supplied pool owner 0x" << std::hex << poolOwner
|
||||
<< std::dec << " did not implement the correct interface "
|
||||
<< "HasLocalDataPoolIF" << std::endl;
|
||||
#else
|
||||
sif::printError(
|
||||
"LocalPoolVariable: The supplied pool owner 0x%08x did not implement the correct "
|
||||
"interface HasLocalDataPoolIF\n",
|
||||
FSFW_LOGWT(
|
||||
"ctor: The supplied pool owner {:#08x} did not implement the correct interface "
|
||||
"HasLocalDataPoolIF\n",
|
||||
poolOwner);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
@ -89,7 +70,6 @@ void LocalPoolObjectBase::setReadWriteMode(pool_rwm_t newReadWriteMode) {
|
||||
|
||||
void LocalPoolObjectBase::reportReadCommitError(const char* variableType, ReturnValue_t error,
|
||||
bool read, object_id_t objectId, lp_id_t lpId) {
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
const char* variablePrintout = variableType;
|
||||
if (variablePrintout == nullptr) {
|
||||
variablePrintout = "Unknown Type";
|
||||
@ -114,13 +94,6 @@ void LocalPoolObjectBase::reportReadCommitError(const char* variableType, Return
|
||||
errMsg = "Unknown error code";
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << variablePrintout << ": " << type << " call | " << errMsg << " | Owner: 0x"
|
||||
<< std::hex << std::setw(8) << std::setfill('0') << objectId << std::dec
|
||||
<< " LPID: " << lpId << std::endl;
|
||||
#else
|
||||
sif::printWarning("%s: %s call | %s | Owner: 0x%08x LPID: %lu\n", variablePrintout, type, errMsg,
|
||||
objectId, lpId);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
||||
FSFW_LOGW("{}: {} call | {} | Owner: {:#08x} | LPID: \n", variablePrintout, type, errMsg,
|
||||
objectId, lpId);
|
||||
}
|
||||
|
@ -98,13 +98,7 @@ inline T& LocalPoolVector<T, vectorSize>::operator [](size_t i) {
|
||||
}
|
||||
// If this happens, I have to set some value. I consider this
|
||||
// a configuration error, but I wont exit here.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
||||
" last value!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalPoolVector: Invalid index. Setting or returning"
|
||||
" last value!\n");
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n");
|
||||
return value[vectorSize - 1];
|
||||
}
|
||||
|
||||
@ -115,13 +109,7 @@ inline const T& LocalPoolVector<T, vectorSize>::operator [](size_t i) const {
|
||||
}
|
||||
// If this happens, I have to set some value. I consider this
|
||||
// a configuration error, but I wont exit here.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "LocalPoolVector: Invalid index. Setting or returning"
|
||||
" last value!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("LocalPoolVector: Invalid index. Setting or returning"
|
||||
" last value!\n");
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "operator[]: Invalid index. Setting or returning last value\n");
|
||||
return value[vectorSize - 1];
|
||||
}
|
||||
|
||||
|
@ -150,22 +150,15 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
}
|
||||
|
||||
if (rawDataReceiverId != objects::NO_OBJECT) {
|
||||
AcceptsDeviceResponsesIF* rawReceiver =
|
||||
ObjectManager::instance()->get<AcceptsDeviceResponsesIF>(rawDataReceiverId);
|
||||
auto* rawReceiver = ObjectManager::instance()->get<AcceptsDeviceResponsesIF>(rawDataReceiverId);
|
||||
|
||||
if (rawReceiver == nullptr) {
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize",
|
||||
ObjectManagerIF::CHILD_INIT_FAILED,
|
||||
"Raw receiver object ID set but no valid object found.");
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Make sure the raw receiver object is set up properly"
|
||||
" and implements AcceptsDeviceResponsesIF"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printError(
|
||||
"Make sure the raw receiver object is set up "
|
||||
"properly and implements AcceptsDeviceResponsesIF\n");
|
||||
#endif
|
||||
FSFW_LOGE("{}",
|
||||
"Make sure the raw receiver object is set up properly "
|
||||
"and implements AcceptsDeviceResponsesIF");
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
defaultRawReceiver = rawReceiver->getDeviceQueue();
|
||||
@ -177,14 +170,9 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR, "initialize",
|
||||
ObjectManagerIF::CHILD_INIT_FAILED,
|
||||
"Power switcher set but no valid object found.");
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Make sure the power switcher object is set up "
|
||||
<< "properly and implements PowerSwitchIF" << std::endl;
|
||||
#else
|
||||
sif::printError(
|
||||
"Make sure the power switcher object is set up "
|
||||
"properly and implements PowerSwitchIF\n");
|
||||
#endif
|
||||
FSFW_LOGE("{}",
|
||||
"Make sure the power switcher object is set up "
|
||||
"properly and implements PowerSwitchIF\n");
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
}
|
||||
@ -767,11 +755,9 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData, size_t receivedD
|
||||
printWarningOrError(sif::OutputTypes::OUT_ERROR, "parseReply",
|
||||
ObjectManagerIF::CHILD_INIT_FAILED,
|
||||
"Power switcher set but no valid object found.");
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!"
|
||||
" Packet parsing will be stuck."
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}",
|
||||
"DeviceHandlerBase::parseReply: foundLen is 0! "
|
||||
"Packet parsing will be stuck\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1476,23 +1462,11 @@ void DeviceHandlerBase::printWarningOrError(sif::OutputTypes errorType, const ch
|
||||
}
|
||||
|
||||
if (errorType == sif::OutputTypes::OUT_WARNING) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "DeviceHandlerBase::" << functionName << ": Object ID 0x" << std::hex
|
||||
<< std::setw(8) << std::setfill('0') << this->getObjectId() << " | " << errorPrint
|
||||
<< std::dec << std::setfill(' ') << std::endl;
|
||||
#else
|
||||
sif::printWarning("DeviceHandlerBase::%s: Object ID 0x%08x | %s\n", functionName,
|
||||
this->getObjectId(), errorPrint);
|
||||
#endif
|
||||
FSFW_LOGWT("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(),
|
||||
errorPrint);
|
||||
} else if (errorType == sif::OutputTypes::OUT_ERROR) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "DeviceHandlerBase::" << functionName << ": Object ID 0x" << std::hex
|
||||
<< std::setw(8) << std::setfill('0') << this->getObjectId() << " | " << errorPrint
|
||||
<< std::dec << std::setfill(' ') << std::endl;
|
||||
#else
|
||||
sif::printError("DeviceHandlerBase::%s: Object ID 0x%08x | %s\n", functionName,
|
||||
this->getObjectId(), errorPrint);
|
||||
#endif
|
||||
FSFW_LOGET("{} | Object ID {:#08x} | {}", functionName, SystemObject::getObjectId(),
|
||||
errorPrint);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1062,7 +1062,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
|
||||
/**
|
||||
* Same as triggerEvent, but for forwarding if object is used as proxy.
|
||||
*/
|
||||
virtual void forwardEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0) const override;
|
||||
virtual void forwardEvent(Event event, uint32_t parameter1 = 0,
|
||||
uint32_t parameter2 = 0) const override;
|
||||
|
||||
/**
|
||||
* Checks if current mode is transitional mode.
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include "fsfw/modes/HasModesIF.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/power/Fuse.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw/thermal/ThermalComponentIF.h"
|
||||
|
||||
object_id_t DeviceHandlerFailureIsolation::powerConfirmationId = objects::NO_OBJECT;
|
||||
@ -163,15 +163,10 @@ void DeviceHandlerFailureIsolation::clearFaultCounters() {
|
||||
ReturnValue_t DeviceHandlerFailureIsolation::initialize() {
|
||||
ReturnValue_t result = FailureIsolationBase::initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "DeviceHandlerFailureIsolation::initialize: Could not"
|
||||
" initialize FailureIsolationBase."
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("{}", "initialize: Could not initialize FailureIsolationBase\n");
|
||||
return result;
|
||||
}
|
||||
ConfirmsFailuresIF* power =
|
||||
ObjectManager::instance()->get<ConfirmsFailuresIF>(powerConfirmationId);
|
||||
auto* power = ObjectManager::instance()->get<ConfirmsFailuresIF>(powerConfirmationId);
|
||||
if (power != nullptr) {
|
||||
powerConfirmation = power->getEventReceptionQueue();
|
||||
}
|
||||
|
@ -4,9 +4,9 @@
|
||||
#include "../ipc/MessageQueueIF.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
#include "../objectmanager/ObjectManager.h"
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "EventMessage.h"
|
||||
#include "eventmatching/eventmatching.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
class EventManagerIF {
|
||||
public:
|
||||
@ -39,19 +39,9 @@ class EventManagerIF {
|
||||
|
||||
static void triggerEvent(EventMessage* message, MessageQueueId_t sentFrom = 0) {
|
||||
if (eventmanagerQueue == MessageQueueIF::NO_QUEUE) {
|
||||
EventManagerIF* eventmanager =
|
||||
ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
auto* eventmanager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
if (eventmanager == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "EventManagerIF::triggerEvent: EventManager invalid or not found!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"EventManagerIF::triggerEvent: "
|
||||
"EventManager invalid or not found!");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGW("{}", "EventManagerIF::triggerEvent: EventManager invalid or not found\n");
|
||||
return;
|
||||
}
|
||||
eventmanagerQueue = eventmanager->getEventReportQueue();
|
||||
|
@ -18,13 +18,9 @@ FailureIsolationBase::~FailureIsolationBase() {
|
||||
}
|
||||
|
||||
ReturnValue_t FailureIsolationBase::initialize() {
|
||||
EventManagerIF* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
auto* manager = ObjectManager::instance()->get<EventManagerIF>(objects::EVENT_MANAGER);
|
||||
if (manager == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "FailureIsolationBase::initialize: Event Manager has not"
|
||||
" been initialized!"
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("{}", "initialize: Event Manager has not been initialized\n");
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
ReturnValue_t result = manager->registerListener(eventQueue->getId());
|
||||
@ -38,27 +34,19 @@ ReturnValue_t FailureIsolationBase::initialize() {
|
||||
}
|
||||
owner = ObjectManager::instance()->get<HasHealthIF>(ownerId);
|
||||
if (owner == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "FailureIsolationBase::intialize: Owner object "
|
||||
"invalid. Make sure it implements HasHealthIF"
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGE(
|
||||
"FailureIsolationBase::intialize: Owner object {:#08x} invalid. "
|
||||
"Does it implement HasHealthIF?\n",
|
||||
ownerId);
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
}
|
||||
if (faultTreeParent != objects::NO_OBJECT) {
|
||||
ConfirmsFailuresIF* parentIF =
|
||||
ObjectManager::instance()->get<ConfirmsFailuresIF>(faultTreeParent);
|
||||
auto* parentIF = ObjectManager::instance()->get<ConfirmsFailuresIF>(faultTreeParent);
|
||||
if (parentIF == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "FailureIsolationBase::intialize: Parent object"
|
||||
<< "invalid." << std::endl;
|
||||
#endif
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Make sure it implements ConfirmsFailuresIF." << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("intialize: Parent object {:#08x} invalid. Does it implement ConfirmsFailuresIF?\n",
|
||||
faultTreeParent);
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
eventQueue->setDefaultDestination(parentIF->getEventReceptionQueue());
|
||||
}
|
||||
|
@ -3,31 +3,16 @@
|
||||
#include <bitset>
|
||||
#include <cmath>
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
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
|
||||
FSFW_LOGI("{}", "Size is zero, nothing to print\n");
|
||||
return;
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
if (printInfo) {
|
||||
sif::info << "Printing data with size " << size << ": " << std::endl;
|
||||
}
|
||||
#else
|
||||
#if FSFW_NO_C99_IO == 1
|
||||
sif::printInfo("Printing data with size %lu: \n", static_cast<unsigned long>(size));
|
||||
#else
|
||||
sif::printInfo("Printing data with size %zu: \n", size);
|
||||
#endif /* FSFW_NO_C99_IO == 1 */
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
|
||||
FSFW_LOGI("Printing data with size {}:\n", size);
|
||||
if (type == OutputType::HEX) {
|
||||
arrayprinter::printHex(data, size, maxCharPerLine);
|
||||
} else if (type == OutputType::DEC) {
|
||||
@ -38,99 +23,99 @@ void arrayprinter::print(const uint8_t *data, size_t size, OutputType type, bool
|
||||
}
|
||||
|
||||
void arrayprinter::printHex(const uint8_t *data, size_t size, size_t maxCharPerLine) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
if (sif::info.crAdditionEnabled()) {
|
||||
std::cout << "\r" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "hex [" << std::setfill('0') << std::hex;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
std::cout << std::setw(2) << static_cast<int>(data[i]);
|
||||
if (i < size - 1) {
|
||||
std::cout << ",";
|
||||
if (i > 0 and (i + 1) % maxCharPerLine == 0) {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << std::dec << std::setfill(' ');
|
||||
std::cout << "]" << std::endl;
|
||||
#else
|
||||
// General format: 0x01, 0x02, 0x03 so it is number of chars times 6
|
||||
// plus line break plus small safety margin.
|
||||
char printBuffer[(size + 1) * 7 + 1] = {};
|
||||
size_t currentPos = 0;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
// To avoid buffer overflows.
|
||||
if (sizeof(printBuffer) - currentPos <= 7) {
|
||||
break;
|
||||
}
|
||||
|
||||
currentPos += snprintf(printBuffer + currentPos, 6, "%02x", data[i]);
|
||||
if (i < size - 1) {
|
||||
currentPos += sprintf(printBuffer + currentPos, ",");
|
||||
if ((i + 1) % maxCharPerLine == 0) {
|
||||
currentPos += sprintf(printBuffer + currentPos, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
printf("hex [%s]\n", printBuffer);
|
||||
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
||||
#endif
|
||||
//#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// if (sif::info.crAdditionEnabled()) {
|
||||
// std::cout << "\r" << std::endl;
|
||||
// }
|
||||
//
|
||||
// std::cout << "hex [" << std::setfill('0') << std::hex;
|
||||
// for (size_t i = 0; i < size; i++) {
|
||||
// std::cout << std::setw(2) << static_cast<int>(data[i]);
|
||||
// if (i < size - 1) {
|
||||
// std::cout << ",";
|
||||
// if (i > 0 and (i + 1) % maxCharPerLine == 0) {
|
||||
// std::cout << std::endl;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// std::cout << std::dec << std::setfill(' ');
|
||||
// std::cout << "]" << std::endl;
|
||||
//#else
|
||||
// // General format: 0x01, 0x02, 0x03 so it is number of chars times 6
|
||||
// // plus line break plus small safety margin.
|
||||
// char printBuffer[(size + 1) * 7 + 1] = {};
|
||||
// size_t currentPos = 0;
|
||||
// for (size_t i = 0; i < size; i++) {
|
||||
// // To avoid buffer overflows.
|
||||
// if (sizeof(printBuffer) - currentPos <= 7) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// currentPos += snprintf(printBuffer + currentPos, 6, "%02x", data[i]);
|
||||
// if (i < size - 1) {
|
||||
// currentPos += sprintf(printBuffer + currentPos, ",");
|
||||
// if ((i + 1) % maxCharPerLine == 0) {
|
||||
// currentPos += sprintf(printBuffer + currentPos, "\n");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//#if FSFW_DISABLE_PRINTOUT == 0
|
||||
// printf("hex [%s]\n", printBuffer);
|
||||
//#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
||||
//#endif
|
||||
}
|
||||
|
||||
void arrayprinter::printDec(const uint8_t *data, size_t size, size_t maxCharPerLine) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
if (sif::info.crAdditionEnabled()) {
|
||||
std::cout << "\r" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "dec [" << std::dec;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
std::cout << static_cast<int>(data[i]);
|
||||
if (i < size - 1) {
|
||||
std::cout << ",";
|
||||
if (i > 0 and (i + 1) % maxCharPerLine == 0) {
|
||||
std::cout << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
std::cout << "]" << std::endl;
|
||||
#else
|
||||
// General format: 32,243,-12 so it is number of chars times 4
|
||||
// plus line break plus small safety margin.
|
||||
uint16_t expectedLines = ceil((double)size / maxCharPerLine);
|
||||
char printBuffer[size * 4 + 1 + expectedLines] = {};
|
||||
size_t currentPos = 0;
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
// To avoid buffer overflows.
|
||||
if (sizeof(printBuffer) - currentPos <= 4) {
|
||||
break;
|
||||
}
|
||||
|
||||
currentPos += snprintf(printBuffer + currentPos, 4, "%d", data[i]);
|
||||
if (i < size - 1) {
|
||||
currentPos += sprintf(printBuffer + currentPos, ",");
|
||||
if ((i + 1) % maxCharPerLine == 0) {
|
||||
currentPos += sprintf(printBuffer + currentPos, "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
#if FSFW_DISABLE_PRINTOUT == 0
|
||||
printf("dec [%s]\n", printBuffer);
|
||||
#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
||||
#endif
|
||||
//#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// if (sif::info.crAdditionEnabled()) {
|
||||
// std::cout << "\r" << std::endl;
|
||||
// }
|
||||
//
|
||||
// std::cout << "dec [" << std::dec;
|
||||
// for (size_t i = 0; i < size; i++) {
|
||||
// std::cout << static_cast<int>(data[i]);
|
||||
// if (i < size - 1) {
|
||||
// std::cout << ",";
|
||||
// if (i > 0 and (i + 1) % maxCharPerLine == 0) {
|
||||
// std::cout << std::endl;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// std::cout << "]" << std::endl;
|
||||
//#else
|
||||
// // General format: 32,243,-12 so it is number of chars times 4
|
||||
// // plus line break plus small safety margin.
|
||||
// uint16_t expectedLines = ceil((double)size / maxCharPerLine);
|
||||
// char printBuffer[size * 4 + 1 + expectedLines] = {};
|
||||
// size_t currentPos = 0;
|
||||
// for (size_t i = 0; i < size; i++) {
|
||||
// // To avoid buffer overflows.
|
||||
// if (sizeof(printBuffer) - currentPos <= 4) {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// currentPos += snprintf(printBuffer + currentPos, 4, "%d", data[i]);
|
||||
// if (i < size - 1) {
|
||||
// currentPos += sprintf(printBuffer + currentPos, ",");
|
||||
// if ((i + 1) % maxCharPerLine == 0) {
|
||||
// currentPos += sprintf(printBuffer + currentPos, "\n");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//#if FSFW_DISABLE_PRINTOUT == 0
|
||||
// printf("dec [%s]\n", printBuffer);
|
||||
//#endif /* FSFW_DISABLE_PRINTOUT == 0 */
|
||||
//#endif
|
||||
}
|
||||
|
||||
void arrayprinter::printBin(const uint8_t *data, size_t size) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
sif::info << "Byte " << i + 1 << ": 0b" << std::bitset<8>(data[i]) << std::endl;
|
||||
}
|
||||
#else
|
||||
for (size_t i = 0; i < size; i++) {
|
||||
sif::printInfo("Byte %d: 0b" BYTE_TO_BINARY_PATTERN "\n", i + 1, BYTE_TO_BINARY(data[i]));
|
||||
}
|
||||
#endif
|
||||
//#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// for (size_t i = 0; i < size; i++) {
|
||||
// sif::info << "Byte " << i + 1 << ": 0b" << std::bitset<8>(data[i]) << std::endl;
|
||||
// }
|
||||
//#else
|
||||
// for (size_t i = 0; i < size; i++) {
|
||||
// sif::printInfo("Byte %d: 0b" BYTE_TO_BINARY_PATTERN "\n", i + 1, BYTE_TO_BINARY(data[i]));
|
||||
// }
|
||||
//#endif
|
||||
}
|
||||
|
@ -35,20 +35,12 @@ ReturnValue_t HealthHelper::initialize() {
|
||||
eventSender = ObjectManager::instance()->get<EventReportingProxyIF>(objectId);
|
||||
|
||||
if (healthTable == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "HealthHelper::initialize: Health table object needs"
|
||||
"to be created in factory."
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("{}", "initialize: Health table object needs to be created in factory\n");
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
if (eventSender == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "HealthHelper::initialize: Owner has to implement "
|
||||
"ReportingProxyIF."
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("{}", "initialize: Owner has to implement ReportingProxyIF\n");
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
@ -77,9 +69,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health,
|
||||
HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO, health, oldHealth);
|
||||
if (MessageQueueSenderIF::sendMessage(parentQueue, &information, owner->getCommandQueue()) !=
|
||||
HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "HealthHelper::informParent: sending health reply failed." << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("informParent: Object ID {:#08x} | Sending health reply failed\n", objectId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,10 +86,7 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) {
|
||||
}
|
||||
if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply, owner->getCommandQueue()) !=
|
||||
HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "HealthHelper::handleHealthCommand: sending health "
|
||||
"reply failed."
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("handleSetHealthCommand: Object ID {:#08x} | Sending health reply failed\n",
|
||||
objectId);
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "fsfw/ipc/MutexFactory.h"
|
||||
#include "fsfw/ipc/MutexGuard.h"
|
||||
#include "fsfw/serialize/SerializeAdapter.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
HealthTable::HealthTable(object_id_t objectid) : SystemObject(objectid) {
|
||||
mutex = MutexFactory::instance()->createMutex();
|
||||
@ -68,13 +69,7 @@ void HealthTable::printAll(uint8_t* pointer, size_t maxSize) {
|
||||
ReturnValue_t result =
|
||||
SerializeAdapter::serialize(&count, &pointer, &size, maxSize, SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "HealthTable::printAll: Serialization of health table failed" << std::endl;
|
||||
#else
|
||||
sif::printWarning("HealthTable::printAll: Serialization of health table failed\n");
|
||||
#endif
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGW("{}", "printAll: Serialization of health table failed\n");
|
||||
return;
|
||||
}
|
||||
for (const auto& health : healthMap) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
MessageQueueMessage::MessageQueueMessage() : messageSize(getMinimumMessageSize()) {
|
||||
memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
|
||||
@ -15,11 +15,7 @@ MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size)
|
||||
memcpy(this->getData(), data, size);
|
||||
this->messageSize = this->HEADER_SIZE + size;
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "MessageQueueMessage: Passed size larger than maximum"
|
||||
"allowed size! Setting content to 0"
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "ctor: Passed size larger than maximum allowed size! Setting content to 0\n");
|
||||
memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
|
||||
this->messageSize = this->HEADER_SIZE;
|
||||
}
|
||||
|
@ -1,8 +1,10 @@
|
||||
#ifndef FRAMEWORK_IPC_MUTEXGUARD_H_
|
||||
#define FRAMEWORK_IPC_MUTEXGUARD_H_
|
||||
|
||||
#include "../serviceinterface/ServiceInterface.h"
|
||||
#include "MutexFactory.h"
|
||||
#include <fmt/core.h>
|
||||
|
||||
#include "fsfw/ipc/MutexIF.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
class MutexGuard {
|
||||
public:
|
||||
@ -10,35 +12,17 @@ class MutexGuard {
|
||||
uint32_t timeoutMs = 0)
|
||||
: internalMutex(mutex) {
|
||||
if (mutex == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MutexGuard: Passed mutex is invalid!" << std::endl;
|
||||
#else
|
||||
sif::printError("MutexGuard: Passed mutex is invalid!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
// It's tricky to use the error functions defined in the service interface
|
||||
// because those functions require the mutex guard themselves
|
||||
fmt::print("ERROR | Passed mutex is invalid\n");
|
||||
return;
|
||||
}
|
||||
result = mutex->lockMutex(timeoutType, timeoutMs);
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
if (result == MutexIF::MUTEX_TIMEOUT) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MutexGuard: Lock of mutex failed with timeout of " << timeoutMs
|
||||
<< " milliseconds!" << std::endl;
|
||||
#else
|
||||
sif::printError("MutexGuard: Lock of mutex failed with timeout of %lu milliseconds\n",
|
||||
timeoutMs);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
|
||||
fmt::print("ERROR | Lock of mutex failed with timeout of {} milliseconds\n", timeoutMs);
|
||||
} else if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MutexGuard: Lock of Mutex failed with code " << result << std::endl;
|
||||
#else
|
||||
sif::printError("MutexGuard: Lock of Mutex failed with code %d\n", result);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
fmt::print("ERROR | Lock of Mutex failed with code {}\n", result);
|
||||
}
|
||||
#else
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
}
|
||||
|
||||
ReturnValue_t getLockResult() const { return result; }
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "fsfw/memory/MemoryMessage.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serialize/EndianConverter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
MemoryHelper::MemoryHelper(HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue)
|
||||
: workOnThis(workOnThis),
|
||||
@ -17,9 +17,7 @@ ReturnValue_t MemoryHelper::handleMemoryCommand(CommandMessage* message) {
|
||||
lastSender = message->getSender();
|
||||
lastCommand = message->getCommand();
|
||||
if (busy) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "MemHelper: Busy!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "MemoryHelper: Busy\n");
|
||||
}
|
||||
switch (lastCommand) {
|
||||
case MemoryMessage::CMD_MEMORY_DUMP:
|
||||
|
@ -81,11 +81,7 @@ class MonitoringReportContent : public SerialLinkedListAdapter<SerializeIF> {
|
||||
if (timeStamper == nullptr) {
|
||||
timeStamper = ObjectManager::instance()->get<TimeStamperIF>(timeStamperId);
|
||||
if (timeStamper == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "MonitoringReportContent::checkAndSetStamper: "
|
||||
"Stamper not found!"
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGET("{}", "checkAndSetStamper: Stamper not found\n");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "ObjectManager.h"
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
#include <iomanip>
|
||||
@ -38,15 +38,8 @@ ReturnValue_t ObjectManager::insert(object_id_t id, SystemObjectIF* object) {
|
||||
#endif
|
||||
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;
|
||||
#else
|
||||
sif::printError("ObjectManager::insert: Object ID 0x%08x is already in use!\n",
|
||||
static_cast<unsigned int>(id));
|
||||
sif::printError("Terminating program");
|
||||
#endif
|
||||
FSFW_LOGET("ObjectManager::insert: Object ID {:#08x} is already in use\nTerminating program\n",
|
||||
static_cast<uint32_t>(id));
|
||||
// This is very severe and difficult to handle in other places.
|
||||
std::exit(INSERTION_FAILED);
|
||||
}
|
||||
@ -61,10 +54,7 @@ ReturnValue_t ObjectManager::remove(object_id_t id) {
|
||||
#endif
|
||||
return RETURN_OK;
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::removeObject: Requested object " << std::hex << (int)id
|
||||
<< std::dec << " not found." << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("removeObject: Requested object {:#08x} not found\n", id);
|
||||
return NOT_FOUND;
|
||||
}
|
||||
}
|
||||
@ -79,64 +69,44 @@ SystemObjectIF* ObjectManager::getSystemObject(object_id_t id) {
|
||||
}
|
||||
|
||||
void ObjectManager::initialize() {
|
||||
if (objectFactoryFunction == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::initialize: Passed produceObjects "
|
||||
"functions is nullptr!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printError("ObjectManager::initialize: Passed produceObjects functions is nullptr!\n");
|
||||
#endif
|
||||
return;
|
||||
if (objectFactoryFunction != nullptr) {
|
||||
objectFactoryFunction(factoryArgs);
|
||||
}
|
||||
objectFactoryFunction(factoryArgs);
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
uint32_t errorCount = 0;
|
||||
for (auto const& it : objectList) {
|
||||
result = it.second->initialize();
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
object_id_t var = it.first;
|
||||
sif::error << "ObjectManager::initialize: Object 0x" << std::hex << std::setw(8)
|
||||
<< std::setfill('0') << var
|
||||
<< " failed to "
|
||||
"initialize with code 0x"
|
||||
<< result << std::dec << std::setfill(' ') << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("initialize: Object {:#08x} failed to initialize with code {:#04x}\n", var,
|
||||
result);
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
if (errorCount > 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::ObjectManager: Counted " << errorCount
|
||||
<< " failed initializations." << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "initialize: Counted failed initializations\n");
|
||||
}
|
||||
// Init was successful. Now check successful interconnections.
|
||||
errorCount = 0;
|
||||
for (auto const& it : objectList) {
|
||||
result = it.second->checkObjectConnections();
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::ObjectManager: Object 0x" << std::hex << (int)it.first
|
||||
<< " connection check failed with code 0x" << result << std::dec << std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("initialize: Object {:#08x} connection check failed with code {:#04x}\n", it.first,
|
||||
result);
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
if (errorCount > 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ObjectManager::ObjectManager: Counted " << errorCount
|
||||
<< " failed connection checks." << std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("{}", "ObjectManager::ObjectManager: Counted {} failed connection checks\n",
|
||||
errorCount);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectManager::printList() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "ObjectManager: Object List contains:" << std::endl;
|
||||
sif::info("ObjectManager: Object List contains:\n");
|
||||
for (auto const& it : objectList) {
|
||||
sif::debug << std::hex << it.first << " | " << it.second << std::endl;
|
||||
sif::info("{:#08x} | {:#08x}\n", it.first, it.second);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -50,7 +50,8 @@ class SystemObject : public SystemObjectIF {
|
||||
virtual ReturnValue_t initialize() override;
|
||||
virtual ReturnValue_t checkObjectConnections() override;
|
||||
|
||||
virtual void forwardEvent(Event event, uint32_t parameter1 = 0, uint32_t parameter2 = 0) const override;
|
||||
virtual void forwardEvent(Event event, uint32_t parameter1 = 0,
|
||||
uint32_t parameter2 = 0) const override;
|
||||
};
|
||||
|
||||
#endif /* FSFW_OBJECTMANAGER_SYSTEMOBJECT_H_ */
|
||||
|
@ -154,7 +154,7 @@ void UdpTcPollingTask::setTimeout(double timeoutSeconds) {
|
||||
#endif
|
||||
}
|
||||
#elif defined(PLATFORM_UNIX)
|
||||
timeval tval {};
|
||||
timeval tval{};
|
||||
tval = timevalOperations::toTimeval(timeoutSeconds);
|
||||
int result = setsockopt(serverSocket, SOL_SOCKET, SO_RCVTIMEO, &tval, sizeof(receptionTimeout));
|
||||
if (result == -1) {
|
||||
|
@ -20,7 +20,7 @@
|
||||
const std::string UdpTmTcBridge::DEFAULT_SERVER_PORT = tcpip::DEFAULT_SERVER_PORT;
|
||||
|
||||
UdpTmTcBridge::UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination,
|
||||
const std::string& udpServerPort_, object_id_t tmStoreId,
|
||||
const std::string &udpServerPort_, object_id_t tmStoreId,
|
||||
object_id_t tcStoreId)
|
||||
: TmTcBridge(objectId, tcDestination, tmStoreId, tcStoreId) {
|
||||
if (udpServerPort_.empty()) {
|
||||
@ -118,7 +118,7 @@ ReturnValue_t UdpTmTcBridge::sendTm(const uint8_t *data, size_t dataLen) {
|
||||
#endif
|
||||
|
||||
ssize_t bytesSent = sendto(serverSocket, reinterpret_cast<const char *>(data), dataLen, flags,
|
||||
&clientAddress, clientAddressLen);
|
||||
&clientAddress, clientAddressLen);
|
||||
if (bytesSent == SOCKET_ERROR) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "TmTcUdpBridge::sendTm: Send operation failed." << std::endl;
|
||||
|
@ -29,8 +29,8 @@ class UdpTmTcBridge : public TmTcBridge, public TcpIpBase {
|
||||
/* The ports chosen here should not be used by any other process. */
|
||||
static const std::string DEFAULT_SERVER_PORT;
|
||||
|
||||
UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination, const std::string& udpServerPort = "",
|
||||
object_id_t tmStoreId = objects::TM_STORE,
|
||||
UdpTmTcBridge(object_id_t objectId, object_id_t tcDestination,
|
||||
const std::string& udpServerPort = "", object_id_t tmStoreId = objects::TM_STORE,
|
||||
object_id_t tcStoreId = objects::TC_STORE);
|
||||
~UdpTmTcBridge() override;
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
#include "fsfw/osal/common/tcpipHelpers.h"
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <cerrno>
|
||||
#include <string>
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw/tasks/TaskFactory.h"
|
||||
|
||||
void tcpip::handleError(Protocol protocol, ErrorSources errorSrc, dur_millis_t sleepDuration) {
|
||||
@ -97,14 +96,13 @@ void tcpip::handleError(Protocol protocol, ErrorSources errorSrc, dur_millis_t s
|
||||
}
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "tcpip::handleError: " << protocolString << " | " << errorSrcString << " | "
|
||||
<< infoString << std::endl;
|
||||
FSFW_LOGWT("tcpip::handleError: {} | {} | {}\n", protocolString, errorSrcString, infoString);
|
||||
#else
|
||||
sif::printWarning("tcpip::handleError: %s | %s | %s\n", protocolString.c_str(),
|
||||
errorSrcString.c_str(), infoString.c_str());
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
|
||||
if (sleepDuration > 0) {
|
||||
TaskFactory::instance()->delayTask(sleepDuration);
|
||||
TaskFactory::delayTask(sleepDuration);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/parameters/ParameterMessage.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
ParameterHelper::ParameterHelper(ReceivesParameterMessagesIF* owner) : owner(owner) {}
|
||||
|
||||
@ -43,10 +44,9 @@ ReturnValue_t ParameterHelper::handleParameterMessage(CommandMessage* message) {
|
||||
ConstStorageAccessor accessor(storeId);
|
||||
result = storage->getData(storeId, accessor);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "ParameterHelper::handleParameterMessage: Getting"
|
||||
<< " store data failed for load command." << std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("{}",
|
||||
"ParameterHelper::handleParameterMessage: Getting store data failed for "
|
||||
"load command\n");
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "fsfw/parameters/ParameterWrapper.h"
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
ParameterWrapper::ParameterWrapper() : pointsToStream(false), type(Type::UNKNOWN_TYPE) {}
|
||||
|
||||
@ -209,47 +209,23 @@ ReturnValue_t ParameterWrapper::set(const uint8_t *stream, size_t streamSize,
|
||||
ReturnValue_t ParameterWrapper::copyFrom(const ParameterWrapper *from,
|
||||
uint16_t startWritingAtIndex) {
|
||||
if (data == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ParameterWrapper::copyFrom: Called on read-only variable!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("ParameterWrapper::copyFrom: Called on read-only variable!\n");
|
||||
#endif
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGWT("{}", "copyFrom: Called on read-only variable\n");
|
||||
return READONLY;
|
||||
}
|
||||
|
||||
if (from->readonlyData == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ParameterWrapper::copyFrom: Source not set!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("ParameterWrapper::copyFrom: Source not set!\n");
|
||||
#endif
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGWT("{}", "copyFrom: Source not set\n");
|
||||
return SOURCE_NOT_SET;
|
||||
}
|
||||
|
||||
if (type != from->type) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ParameterWrapper::copyFrom: Datatype missmatch!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("ParameterWrapper::copyFrom: Datatype missmatch!\n");
|
||||
#endif
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGW("{}", "copyFrom: Datatype missmatch\n");
|
||||
return DATATYPE_MISSMATCH;
|
||||
}
|
||||
|
||||
// The smallest allowed value for rows and columns is one.
|
||||
if (rows == 0 or columns == 0) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "ParameterWrapper::copyFrom: Columns or rows zero!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("ParameterWrapper::copyFrom: Columns or rows zero!\n");
|
||||
#endif
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGW("{}", "ParameterWrapper::copyFrom: Columns or rows zero\n");
|
||||
return COLUMN_OR_ROWS_ZERO;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
template <typename count_t>
|
||||
SerialBufferAdapter<count_t>::SerialBufferAdapter(const uint8_t* buffer, count_t bufferLength,
|
||||
@ -95,11 +95,7 @@ ReturnValue_t SerialBufferAdapter<count_t>::deSerialize(const uint8_t** buffer,
|
||||
template <typename count_t>
|
||||
uint8_t* SerialBufferAdapter<count_t>::getBuffer() {
|
||||
if (buffer == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "Wrong access function for stored type !"
|
||||
" Use getConstBuffer()."
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "getBuffer: Wrong access function for stored type. Use getConstBuffer\n");
|
||||
return nullptr;
|
||||
}
|
||||
return buffer;
|
||||
@ -108,11 +104,7 @@ uint8_t* SerialBufferAdapter<count_t>::getBuffer() {
|
||||
template <typename count_t>
|
||||
const uint8_t* SerialBufferAdapter<count_t>::getConstBuffer() const {
|
||||
if (constBuffer == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "SerialBufferAdapter::getConstBuffer:"
|
||||
" Buffers are unitialized!"
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGE("{}", "getConstBuffer: Buffers are unitialized\n");
|
||||
return nullptr;
|
||||
}
|
||||
return constBuffer;
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef FSFW_SRC_FSFW_SERVICEINTERFACE_H_
|
||||
#define FSFW_SRC_FSFW_SERVICEINTERFACE_H_
|
||||
|
||||
#include "serviceinterface/ServiceInterface.h"
|
||||
#include "serviceinterface/fmtWrapper.h"
|
||||
//#include "serviceinterface/ServiceInterface.h"
|
||||
|
||||
#endif /* FSFW_SRC_FSFW_SERVICEINTERFACE_H_ */
|
||||
|
@ -57,10 +57,10 @@ class ServiceInterfaceStream : public std::ostream {
|
||||
// Forward declaration of interface streams. These should be instantiated in
|
||||
// main. They can then be used like std::cout or std::cerr.
|
||||
namespace sif {
|
||||
extern ServiceInterfaceStream debug;
|
||||
extern ServiceInterfaceStream info;
|
||||
extern ServiceInterfaceStream warning;
|
||||
extern ServiceInterfaceStream error;
|
||||
// extern ServiceInterfaceStream debug;
|
||||
// extern ServiceInterfaceStream info;
|
||||
// extern ServiceInterfaceStream warning;
|
||||
// extern ServiceInterfaceStream error;
|
||||
} // namespace sif
|
||||
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
|
@ -5,11 +5,11 @@
|
||||
std::array<char, 524> sif::PRINT_BUF = {};
|
||||
MutexIF* sif::PRINT_MUTEX = nullptr;
|
||||
|
||||
const char* sif::PREFIX_ARR[4]= {DEBUG_PREFIX, INFO_PREFIX, WARNING_PREFIX, ERROR_PREFIX};
|
||||
const char* sif::PREFIX_ARR[4] = {DEBUG_PREFIX, INFO_PREFIX, WARNING_PREFIX, ERROR_PREFIX};
|
||||
|
||||
ReturnValue_t sif::initialize() {
|
||||
sif::PRINT_MUTEX = MutexFactory::instance()->createMutex();
|
||||
if(sif::PRINT_MUTEX == nullptr) {
|
||||
if (sif::PRINT_MUTEX == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
|
||||
#include "fsfw/ipc/MutexGuard.h"
|
||||
#include "fsfw/ipc/MutexIF.h"
|
||||
#include "fsfw/timemanager/Clock.h"
|
||||
|
||||
@ -44,12 +43,16 @@ size_t writeTypePrefix(LogLevel level);
|
||||
template <typename... T>
|
||||
size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed,
|
||||
fmt::format_string<T...> fmt, T&&... args) noexcept {
|
||||
if(PRINT_MUTEX == nullptr) {
|
||||
if (PRINT_MUTEX == nullptr) {
|
||||
fmt::print("Please call sif::initialize at program startup\n");
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
MutexGuard mg(PRINT_MUTEX);
|
||||
auto fsfwret = PRINT_MUTEX->lockMutex();
|
||||
if (fsfwret != HasReturnvaluesIF::RETURN_OK) {
|
||||
fmt::print("ERROR | {} | Locking print mutex failed", __FILENAME__);
|
||||
return 0;
|
||||
}
|
||||
size_t bufPos = writeTypePrefix(level);
|
||||
auto currentIter = PRINT_BUF.begin() + bufPos;
|
||||
if (timed) {
|
||||
@ -61,27 +64,34 @@ size_t logTraced(LogLevel level, const char* file, unsigned int line, bool timed
|
||||
logTime.usecond / 1000, fmt::format(fmt, args...));
|
||||
bufPos += result.size;
|
||||
} else {
|
||||
const auto result = fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos,
|
||||
" | {}[l.{}] | {}", file, line, fmt::format(fmt, args...));
|
||||
const auto result =
|
||||
fmt::format_to_n(currentIter, PRINT_BUF.size() - 1 - bufPos, " | {}[l.{}] | {}", file,
|
||||
line, fmt::format(fmt, args...));
|
||||
bufPos += result.size;
|
||||
}
|
||||
PRINT_BUF[bufPos] = '\0';
|
||||
fmt::print(fmt::runtime(PRINT_BUF.data()));
|
||||
PRINT_MUTEX->unlockMutex();
|
||||
return bufPos;
|
||||
} catch (const fmt::v8::format_error& e) {
|
||||
fmt::print("Printing failed with error: {}\n", e.what());
|
||||
PRINT_MUTEX->unlockMutex();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
size_t log(LogLevel level, bool timed, fmt::format_string<T...> fmt, T&&... args) noexcept {
|
||||
if(PRINT_MUTEX == nullptr) {
|
||||
if (PRINT_MUTEX == nullptr) {
|
||||
fmt::print("Please call sif::initialize at program startup\n");
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
MutexGuard mg(PRINT_MUTEX);
|
||||
auto fsfwret = PRINT_MUTEX->lockMutex();
|
||||
if (fsfwret != HasReturnvaluesIF::RETURN_OK) {
|
||||
fmt::print("ERROR | {} | Locking print mutex failed", __FILENAME__);
|
||||
return 0;
|
||||
}
|
||||
size_t bufPos = writeTypePrefix(level);
|
||||
auto currentIter = PRINT_BUF.begin() + bufPos;
|
||||
if (timed) {
|
||||
@ -92,73 +102,101 @@ size_t log(LogLevel level, bool timed, fmt::format_string<T...> fmt, T&&... args
|
||||
logTime.minute, logTime.second, logTime.usecond / 1000, fmt::format(fmt, args...));
|
||||
bufPos += result.size;
|
||||
} else {
|
||||
const auto result = fmt::format_to_n(
|
||||
currentIter, PRINT_BUF.size() - bufPos, " | {}", fmt::format(fmt, args...));
|
||||
const auto result = fmt::format_to_n(currentIter, PRINT_BUF.size() - bufPos, " | {}",
|
||||
fmt::format(fmt, args...));
|
||||
bufPos += result.size;
|
||||
}
|
||||
PRINT_BUF[bufPos] = '\0';
|
||||
fmt::print(fmt::runtime(PRINT_BUF.data()));
|
||||
PRINT_MUTEX->unlockMutex();
|
||||
return bufPos;
|
||||
} catch (const fmt::v8::format_error& e) {
|
||||
PRINT_MUTEX->unlockMutex();
|
||||
fmt::print("Printing failed with error: {}\n", e.what());
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void fdebug(const char* file, unsigned int line, fmt::format_string<T...> fmt, T&&... args) noexcept {
|
||||
void debug(const char* file, unsigned int line, fmt::format_string<T...> fmt,
|
||||
T&&... args) noexcept {
|
||||
logTraced(LogLevel::DEBUG, file, line, false, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void fdebug_t(const char* file, unsigned int line, fmt::format_string<T...> fmt, T&&... args) noexcept {
|
||||
void debug_t(const char* file, unsigned int line, fmt::format_string<T...> fmt,
|
||||
T&&... args) noexcept {
|
||||
logTraced(LogLevel::DEBUG, file, line, true, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void finfo_t(fmt::format_string<T...> fmt, T&&... args) {
|
||||
void info_t(fmt::format_string<T...> fmt, T&&... args) {
|
||||
log(LogLevel::INFO, true, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void finfo(fmt::format_string<T...> fmt, T&&... args) {
|
||||
void info(fmt::format_string<T...> fmt, T&&... args) {
|
||||
log(LogLevel::INFO, false, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void fwarning(const char* file, unsigned int line, fmt::format_string<T...> fmt, T&&... args) {
|
||||
void warning(fmt::format_string<T...> fmt, T&&... args) {
|
||||
log(LogLevel::ERROR, false, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void warning_t(fmt::format_string<T...> fmt, T&&... args) {
|
||||
log(LogLevel::ERROR, true, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void warning_f(const char* file, unsigned int line, fmt::format_string<T...> fmt, T&&... args) {
|
||||
logTraced(LogLevel::WARNING, file, line, false, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void fwarning_t(const char* file, unsigned int line, fmt::format_string<T...> fmt, T&&... args) {
|
||||
void warning_ft(const char* file, unsigned int line, fmt::format_string<T...> fmt, T&&... args) {
|
||||
logTraced(LogLevel::WARNING, file, line, true, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void ferror(const char* file, unsigned int line, fmt::format_string<T...> fmt, T&&... args) {
|
||||
void error(fmt::format_string<T...> fmt, T&&... args) {
|
||||
log(LogLevel::ERROR, false, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void error_t(fmt::format_string<T...> fmt, T&&... args) {
|
||||
log(LogLevel::ERROR, true, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void error_f(const char* file, unsigned int line, fmt::format_string<T...> fmt, T&&... args) {
|
||||
logTraced(LogLevel::ERROR, file, line, false, fmt, args...);
|
||||
}
|
||||
|
||||
template <typename... T>
|
||||
void ferror_t(const char* file, unsigned int line, fmt::format_string<T...> fmt, T&&... args) {
|
||||
void error_ft(const char* file, unsigned int line, fmt::format_string<T...> fmt, T&&... args) {
|
||||
logTraced(LogLevel::ERROR, file, line, true, fmt, args...);
|
||||
}
|
||||
|
||||
} // namespace sif
|
||||
|
||||
#define FSFW_LOGI(format, ...) finfo(FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGI(format, ...) sif::info(FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGIT(format, ...) finfo_t(FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGIT(format, ...) sif::info_t(FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGD(format, ...) sif::fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGD(format, ...) sif::debug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGDT(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGDT(format, ...) \
|
||||
sif::debug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGW(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGW(format, ...) \
|
||||
sif::warning_f(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGWT(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGWT(format, ...) \
|
||||
sif::warning_ft(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGE(format, ...) fdebug(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGE(format, ...) sif::error_f(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
||||
#define FSFW_LOGET(format, ...) fdebug_t(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
#define FSFW_LOGET(format, ...) \
|
||||
sif::error_ft(__FILENAME__, __LINE__, FMT_STRING(format), __VA_ARGS__)
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||
|
||||
ConstStorageAccessor::ConstStorageAccessor(store_address_t storeId) : storeId(storeId) {}
|
||||
@ -46,18 +46,14 @@ const uint8_t* ConstStorageAccessor::data() const { return constDataPointer; }
|
||||
|
||||
size_t ConstStorageAccessor::size() const {
|
||||
if (internalState == AccessState::UNINIT) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "StorageAccessor: Not initialized!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "size: Not initialized\n");
|
||||
}
|
||||
return size_;
|
||||
}
|
||||
|
||||
ReturnValue_t ConstStorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) {
|
||||
if (internalState == AccessState::UNINIT) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "StorageAccessor: Not initialized!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "getDataCopy: Not initialized\n");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (size_ > maxSize) {
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig, bool registered,
|
||||
bool spillsToHigherPools)
|
||||
@ -11,10 +12,7 @@ LocalPool::LocalPool(object_id_t setObjectId, const LocalPoolConfig& poolConfig,
|
||||
NUMBER_OF_SUBPOOLS(poolConfig.size()),
|
||||
spillsToHigherPools(spillsToHigherPools) {
|
||||
if (NUMBER_OF_SUBPOOLS == 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPool::LocalPool: Passed pool configuration is "
|
||||
<< " invalid!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "ctor: Passed pool configuration is invalid, 0 subpools\n");
|
||||
}
|
||||
max_subpools_t index = 0;
|
||||
for (const auto& currentPoolConfig : poolConfig) {
|
||||
@ -127,9 +125,8 @@ ReturnValue_t LocalPool::deleteData(store_address_t storeId) {
|
||||
sizeLists[storeId.poolIndex][storeId.packetIndex] = STORAGE_FREE;
|
||||
} else {
|
||||
// pool_index or packet_index is too large
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPool::deleteData: Illegal store ID, no deletion!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("Object ID {} | deleteData: Illegal store ID, no deletion\n",
|
||||
SystemObject::getObjectId());
|
||||
status = ILLEGAL_STORAGE_ID;
|
||||
}
|
||||
return status;
|
||||
@ -178,11 +175,10 @@ ReturnValue_t LocalPool::initialize() {
|
||||
// Check if any pool size is large than the maximum allowed.
|
||||
for (uint8_t count = 0; count < NUMBER_OF_SUBPOOLS; count++) {
|
||||
if (elementSizes[count] >= STORAGE_FREE) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPool::initialize: Pool is too large! "
|
||||
"Max. allowed size is: "
|
||||
<< (STORAGE_FREE - 1) << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW(
|
||||
"LocalPool::initialize: Pool is too large- "
|
||||
"Max. allowed size is: {}\n",
|
||||
STORAGE_FREE - 1);
|
||||
return StorageManagerIF::POOL_TOO_LARGE;
|
||||
}
|
||||
}
|
||||
@ -203,10 +199,7 @@ ReturnValue_t LocalPool::reserveSpace(const size_t size, store_address_t* storeI
|
||||
bool ignoreFault) {
|
||||
ReturnValue_t status = getSubPoolIndex(size, &storeId->poolIndex);
|
||||
if (status != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "LocalPool( " << std::hex << getObjectId() << std::dec
|
||||
<< " )::reserveSpace: Packet too large." << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("ID {:#08x} | reserveSpace: Packet too large\n", SystemObject::getObjectId());
|
||||
return status;
|
||||
}
|
||||
status = findEmpty(storeId->poolIndex, &storeId->packetIndex);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||
|
||||
StorageAccessor::StorageAccessor(store_address_t storeId) : ConstStorageAccessor(storeId) {}
|
||||
@ -23,9 +23,7 @@ StorageAccessor::StorageAccessor(StorageAccessor&& other)
|
||||
|
||||
ReturnValue_t StorageAccessor::getDataCopy(uint8_t* pointer, size_t maxSize) {
|
||||
if (internalState == AccessState::UNINIT) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "StorageAccessor: Not initialized!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "getDataCopy: Not initialized\n");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
if (size_ > maxSize) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw/tasks/FixedTimeslotTaskIF.h"
|
||||
|
||||
FixedSlotSequence::FixedSlotSequence(uint32_t setLengthMs) : lengthMs(setLengthMs) {
|
||||
@ -90,9 +90,7 @@ void FixedSlotSequence::addSlot(object_id_t componentId, uint32_t slotTimeMs, in
|
||||
|
||||
ReturnValue_t FixedSlotSequence::checkSequence() const {
|
||||
if (slotList.empty()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "FixedSlotSequence::checkSequence: Slot list is empty!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("{}", "FixedSlotSequence::checkSequence: Slot list is empty\n");
|
||||
return FixedTimeslotTaskIF::SLOT_LIST_EMPTY;
|
||||
}
|
||||
|
||||
@ -100,10 +98,7 @@ ReturnValue_t FixedSlotSequence::checkSequence() const {
|
||||
ReturnValue_t result = customCheckFunction(slotList);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
// Continue for now but print error output.
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "FixedSlotSequence::checkSequence:"
|
||||
<< " Custom check failed!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGW("FixedSlotSequence::checkSequence: Custom check failed with result {}", result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -113,10 +108,8 @@ ReturnValue_t FixedSlotSequence::checkSequence() const {
|
||||
if (slot.executableObject == nullptr) {
|
||||
errorCount++;
|
||||
} else if (slot.pollingTimeMs < time) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "FixedSlotSequence::checkSequence: Time: " << slot.pollingTimeMs
|
||||
<< " is smaller than previous with " << time << std::endl;
|
||||
#endif
|
||||
FSFW_LOGET("FixedSlotSequence::checkSequence: Time {} is smaller than previous with {}\n",
|
||||
slot.pollingTimeMs, time);
|
||||
errorCount++;
|
||||
} else {
|
||||
// All ok, print slot.
|
||||
@ -151,11 +144,10 @@ ReturnValue_t FixedSlotSequence::intializeSequenceAfterTaskCreation() const {
|
||||
}
|
||||
}
|
||||
if (count > 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "FixedSlotSequence::intializeSequenceAfterTaskCreation:"
|
||||
"Counted "
|
||||
<< count << " failed initializations!" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGE(
|
||||
"FixedSlotSequence::intializeSequenceAfterTaskCreation: Counted {} "
|
||||
"failed initializations\n",
|
||||
count);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "fsfw/tcdistribution/CCSDSDistributor.h"
|
||||
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw/tmtcpacket/SpacePacketBase.h"
|
||||
|
||||
#define CCSDS_DISTRIBUTOR_DEBUGGING 0
|
||||
@ -27,17 +27,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(), &packet, &size);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CCSDSDistributor::selectDestination: Getting data from"
|
||||
" store failed!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printError(
|
||||
"CCSDSDistributor::selectDestination: Getting data from"
|
||||
" store failed!\n");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "selectDestination: Getting data from store failed");
|
||||
}
|
||||
SpacePacketBase currentPacket(packet);
|
||||
|
||||
|
@ -21,13 +21,8 @@ CFDPDistributor::~CFDPDistributor() {}
|
||||
CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
|
||||
#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1
|
||||
store_address_t storeId = this->currentMessage.getStorageId();
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "CFDPDistributor::handlePacket received: " << storeId.poolIndex << ", "
|
||||
FSFW_LOGI("selectDestination: Recie" << storeId.poolIndex << ", "
|
||||
<< storeId.packetIndex << std::endl;
|
||||
#else
|
||||
sif::printDebug("CFDPDistributor::handlePacket received: %d, %d\n", storeId.poolIndex,
|
||||
storeId.packetIndex);
|
||||
#endif
|
||||
#endif
|
||||
TcMqMapIter queueMapIt = this->queueMap.end();
|
||||
if (this->currentPacket == nullptr) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "fsfw/tcdistribution/TcDistributor.h"
|
||||
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw/tmtcservices/TmTcMessage.h"
|
||||
|
||||
TcDistributor::TcDistributor(object_id_t objectId) : SystemObject(objectId) {
|
||||
@ -33,14 +33,10 @@ ReturnValue_t TcDistributor::handlePacket() {
|
||||
}
|
||||
|
||||
void TcDistributor::print() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "Distributor content is: " << std::endl << "ID\t| Message Queue ID" << std::endl;
|
||||
sif::debug << std::setfill('0') << std::setw(8) << std::hex;
|
||||
FSFW_LOGI("{}", "Distributor content is:\nID\t| Message Queue ID");
|
||||
for (const auto& queueMapIter : queueMap) {
|
||||
sif::debug << queueMapIter.first << "\t| 0x" << queueMapIter.second << std::endl;
|
||||
FSFW_LOGI("{} \t| {:#08x}", queueMapIter.first, queueMapIter.second);
|
||||
}
|
||||
sif::debug << std::setfill(' ') << std::dec;
|
||||
#endif
|
||||
}
|
||||
|
||||
ReturnValue_t TcDistributor::callbackAfterSending(ReturnValue_t queueStatus) { return RETURN_OK; }
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "fsfw/timemanager/Stopwatch.h"
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
#include <iomanip>
|
||||
@ -29,22 +29,12 @@ double Stopwatch::stopSeconds() {
|
||||
|
||||
void Stopwatch::display() {
|
||||
if (displayMode == StopwatchDisplayMode::MILLIS) {
|
||||
dur_millis_t timeMillis =
|
||||
auto timeMillis =
|
||||
static_cast<dur_millis_t>(elapsedTime.tv_sec * 1000 + elapsedTime.tv_usec / 1000);
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Stopwatch: Operation took " << timeMillis << " milliseconds" << std::endl;
|
||||
#else
|
||||
sif::printInfo("Stopwatch: Operation took %lu milliseconds\n\r",
|
||||
static_cast<unsigned int>(timeMillis));
|
||||
#endif
|
||||
FSFW_LOGIT("Stopwatch::display: {} ms elapsed\n", timeMillis);
|
||||
} else if (displayMode == StopwatchDisplayMode::SECONDS) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "Stopwatch: Operation took " << std::setprecision(3) << std::fixed
|
||||
<< timevalOperations::toDouble(elapsedTime) << " seconds" << std::endl;
|
||||
#else
|
||||
sif::printInfo("Stopwatch: Operation took %.3f seconds\n\r",
|
||||
static_cast<float>(timevalOperations::toDouble(elapsedTime)));
|
||||
#endif
|
||||
FSFW_LOGIT("Stopwatch::display: {} seconds elapsed\n",
|
||||
static_cast<float>(timevalOperations::toDouble(elapsedTime)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
SpacePacketBase::SpacePacketBase(const uint8_t* setAddress) {
|
||||
this->data = reinterpret_cast<SpacePacketPointer*>(const_cast<uint8_t*>(setAddress));
|
||||
@ -18,13 +18,7 @@ uint8_t SpacePacketBase::getPacketVersionNumber(void) {
|
||||
ReturnValue_t SpacePacketBase::initSpacePacketHeader(bool isTelecommand, bool hasSecondaryHeader,
|
||||
uint16_t apid, uint16_t sequenceCount) {
|
||||
if (data == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "SpacePacketBase::initSpacePacketHeader: Data pointer is invalid" << std::endl;
|
||||
#else
|
||||
sif::printWarning("SpacePacketBase::initSpacePacketHeader: Data pointer is invalid!\n");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGWT("{}", "initSpacePacketHeader: Data pointer is invalid\n");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
// reset header to zero:
|
||||
|
@ -4,17 +4,13 @@
|
||||
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
CFDPPacket::CFDPPacket(const uint8_t* setData) : SpacePacketBase(setData) {}
|
||||
|
||||
CFDPPacket::~CFDPPacket() {}
|
||||
|
||||
void CFDPPacket::print() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "CFDPPacket::print:" << std::endl;
|
||||
#else
|
||||
sif::printInfo("CFDPPacket::print:\n");
|
||||
#endif
|
||||
FSFW_LOGI("{}", "CFDPPacket::print:\n");
|
||||
arrayprinter::print(getWholeData(), getFullSize());
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
#include "fsfw/tcdistribution/PUSDistributorIF.h"
|
||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||
#include "fsfw/tmtcservices/PusVerificationReport.h"
|
||||
@ -22,10 +22,7 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) {
|
||||
handleRequestQueue();
|
||||
ReturnValue_t result = this->performService();
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PusService " << (uint16_t)this->serviceId << ": performService returned with "
|
||||
<< (int16_t)result << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("performOperation: PUS service {} return with error {}\n", serviceId, result);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return RETURN_OK;
|
||||
@ -74,11 +71,8 @@ void PusServiceBase::handleRequestQueue() {
|
||||
// ": no new packet." << std::endl;
|
||||
break;
|
||||
} else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PusServiceBase::performOperation: Service " << this->serviceId
|
||||
<< ": Error receiving packet. Code: " << std::hex << status << std::dec
|
||||
<< std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT("performOperation: Service {}. Error receiving packed, code {}\n", serviceId,
|
||||
status);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,15 +86,13 @@ ReturnValue_t PusServiceBase::initialize() {
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
AcceptsTelemetryIF* destService =
|
||||
ObjectManager::instance()->get<AcceptsTelemetryIF>(packetDestination);
|
||||
PUSDistributorIF* distributor = ObjectManager::instance()->get<PUSDistributorIF>(packetSource);
|
||||
auto* destService = ObjectManager::instance()->get<AcceptsTelemetryIF>(packetDestination);
|
||||
auto* distributor = ObjectManager::instance()->get<PUSDistributorIF>(packetSource);
|
||||
if (destService == nullptr or distributor == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PusServiceBase::PusServiceBase: Service " << this->serviceId
|
||||
<< ": Configuration error. Make sure "
|
||||
<< "packetSource and packetDestination are defined correctly" << std::endl;
|
||||
#endif
|
||||
FSFW_LOGWT(
|
||||
"ctor: Service {} | Make sure static packetSource and packetDestination "
|
||||
"are defined correctly\n",
|
||||
serviceId);
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
this->requestQueue->setDefaultDestination(destService->getReportReceptionQueue());
|
||||
|
Loading…
Reference in New Issue
Block a user