replace FLOG with LOG variants

This commit is contained in:
2022-05-09 00:25:48 +02:00
parent 83a2882f9d
commit b45b6b3758
58 changed files with 200 additions and 220 deletions

View File

@ -199,7 +199,7 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len,
*foundId = getPendingCommand();
if (*foundId == MGMLIS3MDL::IDENTIFY_DEVICE) {
if (start[1] != MGMLIS3MDL::DEVICE_ID) {
FSFW_FLOGW(
FSFW_LOGW(
"scanForReply: Device identification failed, found ID {} not equal to expected {}\n",
start[1], MGMLIS3MDL::DEVICE_ID);
return DeviceHandlerIF::INVALID_DATA;

View File

@ -61,7 +61,7 @@ ReturnValue_t CommandExecutor::close() {
void CommandExecutor::printLastError(const std::string& funcName) const {
if (lastError != 0) {
FSFW_FLOGW("{} | pclose failed with code {} | {}\n", funcName, lastError, strerror(lastError));
FSFW_LOGW("{} | pclose failed with code {} | {}\n", funcName, lastError, strerror(lastError));
}
}

View File

@ -26,7 +26,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
std::string deviceFile;
if (cookie == nullptr) {
FSFW_FLOGE("{}", "initializeInterface: Invalid cookie\n");
FSFW_LOGE("{}", "initializeInterface: Invalid cookie\n");
return NULLPOINTER;
}
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
@ -38,14 +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) {
FSFW_FLOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n",
i2cAddress);
FSFW_LOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n",
i2cAddress);
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;
}
FSFW_FLOGE("initializeInterface: Device with address {} already in use\n", i2cAddress);
FSFW_LOGE("initializeInterface: Device with address {} already in use\n", i2cAddress);
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -55,7 +55,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
std::string deviceFile;
if (sendData == nullptr) {
FSFW_FLOGW("{}", "sendMessage: Send Data is nullptr\n");
FSFW_LOGW("{}", "sendMessage: Send Data is nullptr\n");
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -65,14 +65,14 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
if (i2cCookie == nullptr) {
FSFW_FLOGWT("{}", "sendMessage: Invalid I2C Cookie\n");
FSFW_LOGWT("{}", "sendMessage: Invalid I2C Cookie\n");
return NULLPOINTER;
}
address_t i2cAddress = i2cCookie->getAddress();
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
FSFW_FLOGWT("{}", "sendMessage: I2C address of cookie not registered in I2C device map\n");
FSFW_LOGWT("{}", "sendMessage: I2C address of cookie not registered in I2C device map\n");
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -87,8 +87,8 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
}
if (write(fd, sendData, sendLen) != static_cast<int>(sendLen)) {
FSFW_FLOGE("sendMessage: Failed to send data to I2C device with error code {} | {}\n", errno,
strerror(errno));
FSFW_LOGE("sendMessage: Failed to send data to I2C device with error code {} | {}\n", errno,
strerror(errno));
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -112,7 +112,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
if (i2cCookie == nullptr) {
FSFW_FLOGWT("{}", "requestReceiveMessage: Invalid I2C Cookie\n");
FSFW_LOGWT("{}", "requestReceiveMessage: Invalid I2C Cookie\n");
i2cDeviceMapIter->second.replyLen = 0;
return NULLPOINTER;
}
@ -120,8 +120,8 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
address_t i2cAddress = i2cCookie->getAddress();
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
FSFW_FLOGW("requestReceiveMessage: I2C address {} of Cookie not registered in i2cDeviceMap",
i2cAddress);
FSFW_LOGW("requestReceiveMessage: I2C address {} of Cookie not registered in i2cDeviceMap",
i2cAddress);
i2cDeviceMapIter->second.replyLen = 0;
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -141,7 +141,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
ssize_t readLen = read(fd, replyBuffer, requestLen);
if (readLen != static_cast<int>(requestLen)) {
FSFW_FLOGWT(
FSFW_LOGWT(
"requestReceiveMessage: Reading from I2C device failed with error code "
"{} | {}\nRead only {} from {} bytes\n",
errno, strerror(errno), readLen, requestLen);
@ -161,15 +161,15 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
auto* i2cCookie = dynamic_cast<I2cCookie*>(cookie);
if (i2cCookie == nullptr) {
FSFW_FLOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n");
FSFW_LOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n");
return NULLPOINTER;
}
address_t i2cAddress = i2cCookie->getAddress();
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
FSFW_FLOGE("readReceivedMessage: I2C address {} of cookie not found in I2C device map\n",
i2cAddress);
FSFW_LOGE("readReceivedMessage: I2C address {} of cookie not found in I2C device map\n",
i2cAddress);
return HasReturnvaluesIF::RETURN_FAILED;
}
*buffer = i2cDeviceMapIter->second.replyBuffer.data();
@ -181,8 +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) {
FSFW_FLOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno,
strerror(errno));
FSFW_LOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno,
strerror(errno));
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;

View File

@ -19,7 +19,7 @@
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF)
: SystemObject(objectId), gpioComIF(gpioComIF) {
if (gpioComIF == nullptr) {
FSFW_FLOGET("{}", "SpiComIF::SpiComIF: GPIO communication interface invalid\n");
FSFW_LOGET("{}", "SpiComIF::SpiComIF: GPIO communication interface invalid\n");
}
spiMutex = MutexFactory::instance()->createMutex();
@ -40,7 +40,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
SpiInstance spiInstance(bufferSize);
auto statusPair = spiDeviceMap.emplace(spiAddress, spiInstance);
if (not statusPair.second) {
FSFW_FLOGWT(
FSFW_LOGWT(
"SpiComIF::initializeInterface: Failed to insert device with address {} to SPI device "
"map\n",
spiAddress);
@ -50,7 +50,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
to the SPI driver transfer struct */
spiCookie->assignReadBuffer(statusPair.first->second.replyBuffer.data());
} else {
FSFW_FLOGWT("{}", "initializeInterface: SPI address already exists\n");
FSFW_LOGWT("{}", "initializeInterface: SPI address already exists\n");
return HasReturnvaluesIF::RETURN_FAILED;
}
@ -123,7 +123,7 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
}
if (sendLen > spiCookie->getMaxBufferSize()) {
FSFW_FLOGW(
FSFW_LOGW(
"sendMessage: Too much data sent, send length {} larger than maximum buffer length {}\n",
spiCookie->getMaxBufferSize(), sendLen);
return DeviceCommunicationIF::TOO_MUCH_DATA;
@ -173,12 +173,12 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
if (gpioId != gpio::NO_GPIO) {
result = spiMutex->lockMutex(timeoutType, timeoutMs);
if (result != RETURN_OK) {
FSFW_FLOGET("{}", "sendMessage: Failed to lock mutex\n");
FSFW_LOGET("{}", "sendMessage: Failed to lock mutex\n");
return result;
}
result = gpioComIF->pullLow(gpioId);
if (result != HasReturnvaluesIF::RETURN_OK) {
FSFW_FLOGW("{}", "sendMessage: Pulling low CS pin failed\n");
FSFW_LOGW("{}", "sendMessage: Pulling low CS pin failed\n");
return result;
}
}
@ -197,7 +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)) {
FSFW_FLOGET("{}", "sendMessage: Half-Duplex write operation failed\n");
FSFW_LOGET("{}", "sendMessage: Half-Duplex write operation failed\n");
result = HALF_DUPLEX_TRANSFER_FAILED;
}
}
@ -206,7 +206,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
gpioComIF->pullHigh(gpioId);
result = spiMutex->unlockMutex();
if (result != RETURN_OK) {
FSFW_FLOGWT("{}", "sendMessage: Failed to unlock mutex\n");
FSFW_LOGWT("{}", "sendMessage: Failed to unlock mutex\n");
return result;
}
}
@ -248,14 +248,14 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
if (gpioId != gpio::NO_GPIO) {
result = spiMutex->lockMutex(timeoutType, timeoutMs);
if (result != RETURN_OK) {
FSFW_FLOGW("{}", "getSendSuccess: Failed to lock mutex\n");
FSFW_LOGW("{}", "getSendSuccess: Failed to lock mutex\n");
return result;
}
gpioComIF->pullLow(gpioId);
}
if (read(fileDescriptor, rxBuf, readSize) != static_cast<ssize_t>(readSize)) {
FSFW_FLOGW("{}", "sendMessage: Half-Duplex read operation failed\n");
FSFW_LOGW("{}", "sendMessage: Half-Duplex read operation failed\n");
result = HALF_DUPLEX_TRANSFER_FAILED;
}
@ -263,7 +263,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
gpioComIF->pullHigh(gpioId);
result = spiMutex->unlockMutex();
if (result != RETURN_OK) {
FSFW_FLOGW("{}", "getSendSuccess: Failed to unlock mutex\n");
FSFW_LOGW("{}", "getSendSuccess: Failed to unlock mutex\n");
return result;
}
}

View File

@ -25,7 +25,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) {
FSFW_FLOGE("{}", "initializeInterface: Invalid UART Cookie\n");
FSFW_LOGE("{}", "initializeInterface: Invalid UART Cookie\n");
return NULLPOINTER;
}
@ -41,12 +41,11 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
UartElements uartElements = {fileDescriptor, std::vector<uint8_t>(maxReplyLen), 0};
auto status = uartDeviceMap.emplace(deviceFile, uartElements);
if (!status.second) {
FSFW_FLOGW("initializeInterface: Failed to insert device {} to UART device map\n",
deviceFile);
FSFW_LOGW("initializeInterface: Failed to insert device {} to UART device map\n", deviceFile);
return RETURN_FAILED;
}
} else {
FSFW_FLOGW("initializeInterface: UART device {} already in use\n", deviceFile);
FSFW_LOGW("initializeInterface: UART device {} already in use\n", deviceFile);
return RETURN_FAILED;
}
@ -66,14 +65,14 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
int fd = open(deviceFile.c_str(), flags);
if (fd < 0) {
FSFW_FLOGW("configureUartPort: Failed to open UART {} with error code {} | {}\n", deviceFile,
errno, strerror(errno));
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) {
FSFW_FLOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno));
FSFW_LOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno));
return fd;
}
@ -94,8 +93,8 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
/* Save option settings */
if (tcsetattr(fd, TCSANOW, &options) != 0) {
FSFW_FLOGW("configureUartPort: Failed to set options with error {} | {}\n", errno,
strerror(errno));
FSFW_LOGW("configureUartPort: Failed to set options with error {} | {}\n", errno,
strerror(errno));
return fd;
}
return fd;
@ -147,8 +146,8 @@ void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCook
options->c_cflag |= CS8;
break;
default:
FSFW_FLOGW("setDatasizeOptions: Invalid size {} specified\n",
static_cast<unsigned int>(uartCookie->getBitsPerWord()));
FSFW_LOGW("setDatasizeOptions: Invalid size {} specified\n",
static_cast<unsigned int>(uartCookie->getBitsPerWord()));
break;
}
}
@ -301,7 +300,7 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki
break;
#endif // ! __APPLE__
default:
FSFW_FLOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n");
FSFW_LOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n");
break;
}
}
@ -316,27 +315,27 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData,
}
if (sendData == nullptr) {
FSFW_FLOGWT("{}", "sendMessage: Send data is nullptr");
FSFW_LOGWT("{}", "sendMessage: Send data is nullptr");
return RETURN_FAILED;
}
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) {
FSFW_FLOGWT("{}", "sendMessage: Invalid UART Cookie\n");
FSFW_LOGWT("{}", "sendMessage: Invalid UART Cookie\n");
return NULLPOINTER;
}
deviceFile = uartCookie->getDeviceFile();
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
if (uartDeviceMapIter == uartDeviceMap.end()) {
FSFW_FLOGWT("{}", "sendMessage: Device file {} not in UART map\n", deviceFile);
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)) {
FSFW_FLOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno));
FSFW_LOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno));
return RETURN_FAILED;
}
@ -351,7 +350,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) {
FSFW_FLOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n");
FSFW_LOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n");
return NULLPOINTER;
}
@ -364,7 +363,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
}
if (uartDeviceMapIter == uartDeviceMap.end()) {
FSFW_FLOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile);
FSFW_LOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile);
return RETURN_FAILED;
}
@ -393,7 +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.
FSFW_FLOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n");
FSFW_LOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n");
result = UART_RX_BUFFER_TOO_SMALL;
break;
} else {
@ -404,7 +403,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
if (bytesRead < 0) {
// EAGAIN: No data available in non-blocking mode
if (errno != EAGAIN) {
FSFW_FLOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno));
FSFW_LOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno));
return RETURN_FAILED;
}
@ -424,7 +423,7 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi
auto bufferPtr = iter->second.replyBuffer.data();
// Size check to prevent buffer overflow
if (requestLen > uartCookie.getMaxReplyLen()) {
FSFW_FLOGW("{}", "requestReceiveMessage: Next read would cause overflow\n");
FSFW_LOGW("{}", "requestReceiveMessage: Next read would cause overflow\n");
return UART_RX_BUFFER_TOO_SMALL;
}
ssize_t bytesRead = read(fd, bufferPtr, requestLen);
@ -432,8 +431,8 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi
return RETURN_FAILED;
} else if (bytesRead != static_cast<int>(requestLen)) {
if (uartCookie.isReplySizeFixed()) {
FSFW_FLOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead,
requestLen);
FSFW_LOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead,
requestLen);
return RETURN_FAILED;
}
}
@ -447,14 +446,14 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) {
FSFW_FLOGWT("{}", "readReceivedMessage: Invalid uart cookie");
FSFW_LOGWT("{}", "readReceivedMessage: Invalid uart cookie");
return NULLPOINTER;
}
deviceFile = uartCookie->getDeviceFile();
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
if (uartDeviceMapIter == uartDeviceMap.end()) {
FSFW_FLOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile);
FSFW_LOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile);
return RETURN_FAILED;
}
@ -472,7 +471,7 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
UartDeviceMapIter uartDeviceMapIter;
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) {
FSFW_FLOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n");
FSFW_LOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n");
return NULLPOINTER;
}
deviceFile = uartCookie->getDeviceFile();
@ -490,7 +489,7 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
UartDeviceMapIter uartDeviceMapIter;
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) {
FSFW_FLOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n");
FSFW_LOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n");
return NULLPOINTER;
}
deviceFile = uartCookie->getDeviceFile();
@ -508,7 +507,7 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
UartDeviceMapIter uartDeviceMapIter;
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) {
FSFW_FLOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n");
FSFW_LOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n");
return NULLPOINTER;
}
deviceFile = uartCookie->getDeviceFile();