it compiles again
This commit is contained in:
@ -1,30 +1,19 @@
|
||||
#include "fsfw_hal/common/gpio/GpioCookie.h"
|
||||
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
GpioCookie::GpioCookie() {}
|
||||
GpioCookie::GpioCookie() = default;
|
||||
|
||||
ReturnValue_t GpioCookie::addGpio(gpioId_t gpioId, GpioBase* gpioConfig) {
|
||||
if (gpioConfig == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "GpioCookie::addGpio: gpioConfig is nullpointer" << std::endl;
|
||||
#else
|
||||
sif::printWarning("GpioCookie::addGpio: gpioConfig is nullpointer\n");
|
||||
#endif
|
||||
FSFW_LOGW("addGpio: gpioConfig is nullpointer\n");
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
auto gpioMapIter = gpioMap.find(gpioId);
|
||||
if (gpioMapIter == gpioMap.end()) {
|
||||
auto statusPair = gpioMap.emplace(gpioId, gpioConfig);
|
||||
if (statusPair.second == false) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "GpioCookie::addGpio: Failed to add GPIO " << gpioId << " to GPIO map"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning("GpioCookie::addGpio: Failed to add GPIO %d to GPIO map\n", gpioId);
|
||||
#endif
|
||||
#endif
|
||||
if (!statusPair.second) {
|
||||
FSFW_LOGW("addGpio: Failed to add GPIO {} to GPIO map\n", gpioId);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
@ -60,16 +60,8 @@ ReturnValue_t GyroHandlerL3GD20H::buildTransitionDeviceCommand(DeviceCommandId_t
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
default:
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
/* Might be a configuration error. */
|
||||
sif::warning << "GyroL3GD20Handler::buildTransitionDeviceCommand: "
|
||||
"Unknown internal state!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printDebug(
|
||||
"GyroL3GD20Handler::buildTransitionDeviceCommand: "
|
||||
"Unknown internal state!\n");
|
||||
#endif
|
||||
FSFW_LOGW("buildTransitionDeviceCommand: Unknown internal state\n");
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
@ -192,17 +184,8 @@ ReturnValue_t GyroHandlerL3GD20H::interpretDeviceReply(DeviceCommandId_t id,
|
||||
if (periodicPrintout) {
|
||||
if (debugDivider.checkAndIncrement()) {
|
||||
/* Set terminal to utf-8 if there is an issue with micro printout. */
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "GyroHandlerL3GD20H: Angular velocities (deg/s):" << std::endl;
|
||||
sif::info << "X: " << angVelocX << std::endl;
|
||||
sif::info << "Y: " << angVelocY << std::endl;
|
||||
sif::info << "Z: " << angVelocZ << std::endl;
|
||||
#else
|
||||
sif::printInfo("GyroHandlerL3GD20H: Angular velocities (deg/s):\n");
|
||||
sif::printInfo("X: %f\n", angVelocX);
|
||||
sif::printInfo("Y: %f\n", angVelocY);
|
||||
sif::printInfo("Z: %f\n", angVelocZ);
|
||||
#endif
|
||||
FSFW_LOGI("GyroHandlerL3GD20H: Angular velocities (deg/s):\nX {} | Y {} | Z {}\n",
|
||||
angVelocX, angVelocY, angVelocZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -76,21 +76,16 @@ ReturnValue_t MgmLIS3MDLHandler::buildTransitionDeviceCommand(DeviceCommandId_t
|
||||
}
|
||||
default: {
|
||||
/* might be a configuration error. */
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "GyroHandler::buildTransitionDeviceCommand: Unknown internal state!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning("GyroHandler::buildTransitionDeviceCommand: Unknown internal state!\n");
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
FSFW_LOGW("buildTransitionDeviceCommand: Unknown internal state\n");
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
}
|
||||
return buildCommandFromCommand(*id, NULL, 0);
|
||||
return buildCommandFromCommand(*id, nullptr, 0);
|
||||
}
|
||||
|
||||
uint8_t MgmLIS3MDLHandler::readCommand(uint8_t command, bool continuousCom) {
|
||||
command |= (1 << MGMLIS3MDL::RW_BIT);
|
||||
if (continuousCom == true) {
|
||||
if (continuousCom) {
|
||||
command |= (1 << MGMLIS3MDL::MS_BIT);
|
||||
}
|
||||
return command;
|
||||
@ -98,7 +93,7 @@ uint8_t MgmLIS3MDLHandler::readCommand(uint8_t command, bool continuousCom) {
|
||||
|
||||
uint8_t MgmLIS3MDLHandler::writeCommand(uint8_t command, bool continuousCom) {
|
||||
command &= ~(1 << MGMLIS3MDL::RW_BIT);
|
||||
if (continuousCom == true) {
|
||||
if (continuousCom) {
|
||||
command |= (1 << MGMLIS3MDL::MS_BIT);
|
||||
}
|
||||
return command;
|
||||
@ -186,13 +181,7 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len,
|
||||
// Check validity by checking config registers
|
||||
if (start[1] != registers[0] or start[2] != registers[1] or start[3] != registers[2] or
|
||||
start[4] != registers[3] or start[5] != registers[4]) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "MGMHandlerLIS3MDL::scanForReply: Invalid registers!" << std::endl;
|
||||
#else
|
||||
sif::printWarning("MGMHandlerLIS3MDL::scanForReply: Invalid registers!\n");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGW("scanForReply: Invalid registers\n");
|
||||
return DeviceHandlerIF::INVALID_DATA;
|
||||
}
|
||||
if (mode == _MODE_START_UP) {
|
||||
@ -210,17 +199,9 @@ ReturnValue_t MgmLIS3MDLHandler::scanForReply(const uint8_t *start, size_t len,
|
||||
*foundId = getPendingCommand();
|
||||
if (*foundId == MGMLIS3MDL::IDENTIFY_DEVICE) {
|
||||
if (start[1] != MGMLIS3MDL::DEVICE_ID) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "MGMHandlerLIS3MDL::scanForReply: "
|
||||
"Device identification failed!"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"MGMHandlerLIS3MDL::scanForReply: "
|
||||
"Device identification failed!\n");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_FLOGW(
|
||||
"scanForReply: Device identification failed, found ID {} not equal to expected {}\n",
|
||||
start[1], MGMLIS3MDL::DEVICE_ID);
|
||||
return DeviceHandlerIF::INVALID_DATA;
|
||||
}
|
||||
|
||||
@ -268,19 +249,10 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
|
||||
if (periodicPrintout) {
|
||||
if (debugDivider.checkAndIncrement()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "MGMHandlerLIS3: Magnetic field strength in"
|
||||
" microtesla:"
|
||||
<< std::endl;
|
||||
sif::info << "X: " << mgmX << " uT" << std::endl;
|
||||
sif::info << "Y: " << mgmY << " uT" << std::endl;
|
||||
sif::info << "Z: " << mgmZ << " uT" << std::endl;
|
||||
#else
|
||||
sif::printInfo("MGMHandlerLIS3: Magnetic field strength in microtesla:\n");
|
||||
sif::printInfo("X: %f uT\n", mgmX);
|
||||
sif::printInfo("Y: %f uT\n", mgmY);
|
||||
sif::printInfo("Z: %f uT\n", mgmZ);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 0 */
|
||||
FSFW_LOGI(
|
||||
"MGMHandlerLIS3: Magnetic field strength in"
|
||||
" microtesla (uT):\nX {} | Y {} | Z {}\n",
|
||||
mgmX, mgmY, mgmZ);
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,15 +283,11 @@ ReturnValue_t MgmLIS3MDLHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
}
|
||||
|
||||
case MGMLIS3MDL::READ_TEMPERATURE: {
|
||||
int16_t tempValueRaw = packet[2] << 8 | packet[1];
|
||||
auto tempValueRaw = static_cast<int16_t>((packet[2] << 8) | packet[1]);
|
||||
float tempValue = 25.0 + ((static_cast<float>(tempValueRaw)) / 8.0);
|
||||
if (periodicPrintout) {
|
||||
if (debugDivider.check()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "MGMHandlerLIS3: Temperature: " << tempValue << " C" << std::endl;
|
||||
#else
|
||||
sif::printInfo("MGMHandlerLIS3: Temperature: %f C\n");
|
||||
#endif
|
||||
FSFW_LOGI("MGMHandlerLIS3: Temperature: {} C\n", tempValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,18 +81,8 @@ ReturnValue_t MgmRM3100Handler::buildTransitionDeviceCommand(DeviceCommandId_t *
|
||||
break;
|
||||
}
|
||||
default:
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// Might be a configuration error
|
||||
sif::warning << "MgmRM3100Handler::buildTransitionDeviceCommand: "
|
||||
"Unknown internal state"
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning(
|
||||
"MgmRM3100Handler::buildTransitionDeviceCommand: "
|
||||
"Unknown internal state\n");
|
||||
#endif
|
||||
#endif
|
||||
FSFW_LOGW("buildTransitionDeviceCommand: Unknown internal state\n");
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
@ -335,19 +325,10 @@ ReturnValue_t MgmRM3100Handler::handleDataReadout(const uint8_t *packet) {
|
||||
|
||||
if (periodicPrintout) {
|
||||
if (debugDivider.checkAndIncrement()) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "MgmRM3100Handler: Magnetic field strength in"
|
||||
" microtesla:"
|
||||
<< std::endl;
|
||||
sif::info << "X: " << fieldStrengthX << " uT" << std::endl;
|
||||
sif::info << "Y: " << fieldStrengthY << " uT" << std::endl;
|
||||
sif::info << "Z: " << fieldStrengthZ << " uT" << std::endl;
|
||||
#else
|
||||
sif::printInfo("MgmRM3100Handler: Magnetic field strength in microtesla:\n");
|
||||
sif::printInfo("X: %f uT\n", fieldStrengthX);
|
||||
sif::printInfo("Y: %f uT\n", fieldStrengthY);
|
||||
sif::printInfo("Z: %f uT\n", fieldStrengthZ);
|
||||
#endif
|
||||
FSFW_LOGI(
|
||||
"MgmRM3100Handler: Magnetic field strength in"
|
||||
" microtesla(uT)\nX {} | Y {} | Z {}\n",
|
||||
fieldStrengthX, fieldStrengthY, fieldStrengthZ);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,22 +59,16 @@ ReturnValue_t CommandExecutor::close() {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
void CommandExecutor::printLastError(std::string funcName) const {
|
||||
void CommandExecutor::printLastError(const std::string& funcName) const {
|
||||
if (lastError != 0) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << funcName << " pclose failed with code " << lastError << ": "
|
||||
<< strerror(lastError) << std::endl;
|
||||
#else
|
||||
sif::printError("%s pclose failed with code %d: %s\n", funcName, lastError,
|
||||
strerror(lastError));
|
||||
#endif
|
||||
FSFW_FLOGW("{} | pclose failed with code {} | {}\n", funcName, lastError, strerror(lastError));
|
||||
}
|
||||
}
|
||||
|
||||
void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer,
|
||||
DynamicFIFO<uint16_t>* sizesFifo) {
|
||||
this->ringBuffer = ringBuffer;
|
||||
this->sizesFifo = sizesFifo;
|
||||
void CommandExecutor::setRingBuffer(SimpleRingBuffer* ringBuffer_,
|
||||
DynamicFIFO<uint16_t>* sizesFifo_) {
|
||||
this->ringBuffer = ringBuffer_;
|
||||
this->sizesFifo = sizesFifo_;
|
||||
}
|
||||
|
||||
ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
||||
@ -102,23 +96,13 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
||||
ssize_t readBytes = read(currentFd, readVec.data(), readVec.size());
|
||||
if (readBytes == 0) {
|
||||
// Should not happen
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "CommandExecutor::check: No bytes read "
|
||||
"after poll event.."
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning("CommandExecutor::check: No bytes read after poll event..\n");
|
||||
#endif
|
||||
FSFW_LOGWT("CommandExecutor::check: No bytes read after poll event\n");
|
||||
break;
|
||||
} else if (readBytes > 0) {
|
||||
replyReceived = true;
|
||||
if (printOutput) {
|
||||
// It is assumed the command output is line terminated
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << currentCmd << " | " << readVec.data();
|
||||
#else
|
||||
sif::printInfo("%s | %s", currentCmd, readVec.data());
|
||||
#endif
|
||||
FSFW_LOGIT("{} | {}", currentCmd, readVec.data());
|
||||
}
|
||||
if (ringBuffer != nullptr) {
|
||||
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(readVec.data()), readBytes);
|
||||
@ -130,20 +114,11 @@ ReturnValue_t CommandExecutor::check(bool& replyReceived) {
|
||||
}
|
||||
} else {
|
||||
// Should also not happen
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "CommandExecutor::check: Error " << errno << ": " << strerror(errno)
|
||||
<< std::endl;
|
||||
#else
|
||||
sif::printWarning("CommandExecutor::check: Error %d: %s\n", errno, strerror(errno));
|
||||
#endif
|
||||
FSFW_LOGW("check: Error {} | {}\n", errno, strerror(errno));
|
||||
}
|
||||
}
|
||||
if (waiter.revents & POLLERR) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "CommandExecuter::check: Poll error" << std::endl;
|
||||
#else
|
||||
sif::printWarning("CommandExecuter::check: Poll error\n");
|
||||
#endif
|
||||
FSFW_LOGW("check: Poll error\n");
|
||||
return COMMAND_ERROR;
|
||||
}
|
||||
if (waiter.revents & POLLHUP) {
|
||||
@ -183,11 +158,7 @@ ReturnValue_t CommandExecutor::executeBlocking() {
|
||||
while (fgets(readVec.data(), readVec.size(), currentCmdFile) != nullptr) {
|
||||
std::string output(readVec.data());
|
||||
if (printOutput) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << currentCmd << " | " << output;
|
||||
#else
|
||||
sif::printInfo("%s | %s", currentCmd, output);
|
||||
#endif
|
||||
FSFW_LOGI("{} | {}", currentCmd, output);
|
||||
}
|
||||
if (ringBuffer != nullptr) {
|
||||
ringBuffer->writeData(reinterpret_cast<const uint8_t*>(output.data()), output.size());
|
||||
|
@ -93,7 +93,7 @@ class CommandExecutor {
|
||||
|
||||
States getCurrentState() const;
|
||||
int getLastError() const;
|
||||
void printLastError(std::string funcName) const;
|
||||
void printLastError(const std::string& funcName) const;
|
||||
|
||||
/**
|
||||
* Assign a ring buffer and a FIFO which will be filled by the executor with the output
|
||||
|
@ -14,15 +14,8 @@ UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags,
|
||||
}
|
||||
*fileDescriptor = open(device.c_str(), flags);
|
||||
if (*fileDescriptor < 0) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << diagnosticPrefix << ": Opening device failed with error code " << errno << ": "
|
||||
<< strerror(errno) << std::endl;
|
||||
#else
|
||||
sif::printWarning("%s: Opening device failed with error code %d: %s\n", diagnosticPrefix, errno,
|
||||
strerror(errno));
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGW("{} | Opening device failed with error code {} | {}\n", diagnosticPrefix, errno,
|
||||
strerror(errno));
|
||||
openStatus = OPEN_FILE_FAILED;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
|
||||
std::string deviceFile;
|
||||
|
||||
if (cookie == nullptr) {
|
||||
FSFW_LOGE("{}", "initializeInterface: Invalid cookie\n");
|
||||
FSFW_FLOGE("{}", "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_LOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n",
|
||||
i2cAddress);
|
||||
FSFW_FLOGW("initializeInterface: Failed to insert device with address {} to I2C device map\n",
|
||||
i2cAddress);
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
FSFW_LOGE("initializeInterface: Device with address {} already in use\n", i2cAddress);
|
||||
FSFW_FLOGE("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_LOGW("{}", "sendMessage: Send Data is nullptr\n");
|
||||
FSFW_FLOGW("{}", "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_LOGWT("{}", "sendMessage: Invalid I2C Cookie\n");
|
||||
FSFW_FLOGWT("{}", "sendMessage: Invalid I2C Cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
address_t i2cAddress = i2cCookie->getAddress();
|
||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||
FSFW_LOGWT("{}", "sendMessage: I2C address of cookie not registered in I2C device map\n");
|
||||
FSFW_FLOGWT("{}", "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_LOGE("sendMessage: Failed to send data to I2C device with error code {} | {}\n", errno,
|
||||
strerror(errno));
|
||||
FSFW_FLOGE("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_LOGWT("{}", "requestReceiveMessage: Invalid I2C Cookie\n");
|
||||
FSFW_FLOGWT("{}", "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_LOGW("requestReceiveMessage: I2C address {} of Cookie not registered in i2cDeviceMap",
|
||||
i2cAddress);
|
||||
FSFW_FLOGW("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_LOGWT(
|
||||
FSFW_FLOGWT(
|
||||
"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_LOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n");
|
||||
FSFW_FLOGW("{}", "readReceivedMessage: Invalid I2C Cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
address_t i2cAddress = i2cCookie->getAddress();
|
||||
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
|
||||
if (i2cDeviceMapIter == i2cDeviceMap.end()) {
|
||||
FSFW_LOGE("readReceivedMessage: I2C address {} of cookie not found in I2C device map\n",
|
||||
i2cAddress);
|
||||
FSFW_FLOGE("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_LOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno,
|
||||
strerror(errno));
|
||||
FSFW_FLOGWT("openDevice: Specifying target device failed with error code {} | {}\n", errno,
|
||||
strerror(errno));
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
|
@ -19,7 +19,7 @@
|
||||
SpiComIF::SpiComIF(object_id_t objectId, GpioIF* gpioComIF)
|
||||
: SystemObject(objectId), gpioComIF(gpioComIF) {
|
||||
if (gpioComIF == nullptr) {
|
||||
FSFW_LOGET("{}", "SpiComIF::SpiComIF: GPIO communication interface invalid\n");
|
||||
FSFW_FLOGET("{}", "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_LOGWT(
|
||||
FSFW_FLOGWT(
|
||||
"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_LOGWT("{}", "initializeInterface: SPI address already exists\n");
|
||||
FSFW_FLOGWT("{}", "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_LOGW(
|
||||
FSFW_FLOGW(
|
||||
"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_LOGET("{}", "sendMessage: Failed to lock mutex\n");
|
||||
FSFW_FLOGET("{}", "sendMessage: Failed to lock mutex\n");
|
||||
return result;
|
||||
}
|
||||
result = gpioComIF->pullLow(gpioId);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
FSFW_LOGW("{}", "sendMessage: Pulling low CS pin failed\n");
|
||||
FSFW_FLOGW("{}", "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_LOGET("{}", "sendMessage: Half-Duplex write operation failed\n");
|
||||
FSFW_FLOGET("{}", "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_LOGWT("{}", "sendMessage: Failed to unlock mutex\n");
|
||||
FSFW_FLOGWT("{}", "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_LOGW("{}", "getSendSuccess: Failed to lock mutex\n");
|
||||
FSFW_FLOGW("{}", "getSendSuccess: Failed to lock mutex\n");
|
||||
return result;
|
||||
}
|
||||
gpioComIF->pullLow(gpioId);
|
||||
}
|
||||
|
||||
if (read(fileDescriptor, rxBuf, readSize) != static_cast<ssize_t>(readSize)) {
|
||||
FSFW_LOGW("{}", "sendMessage: Half-Duplex read operation failed\n");
|
||||
FSFW_FLOGW("{}", "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_LOGW("{}", "getSendSuccess: Failed to unlock mutex\n");
|
||||
FSFW_FLOGW("{}", "getSendSuccess: Failed to unlock mutex\n");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
|
||||
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
FSFW_LOGE("{}", "initializeInterface: Invalid UART Cookie\n");
|
||||
FSFW_FLOGE("{}", "initializeInterface: Invalid UART Cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
@ -41,11 +41,12 @@ 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_LOGW("initializeInterface: Failed to insert device {} to UART device map\n", deviceFile);
|
||||
FSFW_FLOGW("initializeInterface: Failed to insert device {} to UART device map\n",
|
||||
deviceFile);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
} else {
|
||||
FSFW_LOGW("initializeInterface: UART device {} already in use\n", deviceFile);
|
||||
FSFW_FLOGW("initializeInterface: UART device {} already in use\n", deviceFile);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -65,14 +66,14 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
|
||||
int fd = open(deviceFile.c_str(), flags);
|
||||
|
||||
if (fd < 0) {
|
||||
FSFW_LOGW("configureUartPort: Failed to open UART {} with error code {} | {}\n", deviceFile,
|
||||
errno, strerror(errno));
|
||||
FSFW_FLOGW("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_LOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno));
|
||||
FSFW_FLOGW("configureUartPort: Error {} from tcgetattr: {}\n", errno, strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
|
||||
@ -93,8 +94,8 @@ int UartComIF::configureUartPort(UartCookie* uartCookie) {
|
||||
|
||||
/* Save option settings */
|
||||
if (tcsetattr(fd, TCSANOW, &options) != 0) {
|
||||
FSFW_LOGW("configureUartPort: Failed to set options with error {} | {}\n", errno,
|
||||
strerror(errno));
|
||||
FSFW_FLOGW("configureUartPort: Failed to set options with error {} | {}\n", errno,
|
||||
strerror(errno));
|
||||
return fd;
|
||||
}
|
||||
return fd;
|
||||
@ -146,8 +147,8 @@ void UartComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCook
|
||||
options->c_cflag |= CS8;
|
||||
break;
|
||||
default:
|
||||
FSFW_LOGW("setDatasizeOptions: Invalid size {} specified\n",
|
||||
static_cast<unsigned int>(uartCookie->getBitsPerWord()));
|
||||
FSFW_FLOGW("setDatasizeOptions: Invalid size {} specified\n",
|
||||
static_cast<unsigned int>(uartCookie->getBitsPerWord()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -300,7 +301,7 @@ void UartComIF::configureBaudrate(struct termios* options, UartCookie* uartCooki
|
||||
break;
|
||||
#endif // ! __APPLE__
|
||||
default:
|
||||
FSFW_LOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n");
|
||||
FSFW_FLOGW("{}", "UartComIF::configureBaudrate: Baudrate not supported\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -315,27 +316,27 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData,
|
||||
}
|
||||
|
||||
if (sendData == nullptr) {
|
||||
FSFW_LOGWT("{}", "sendMessage: Send data is nullptr");
|
||||
FSFW_FLOGWT("{}", "sendMessage: Send data is nullptr");
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
FSFW_LOGWT("{}", "sendMessage: Invalid UART Cookie\n");
|
||||
FSFW_FLOGWT("{}", "sendMessage: Invalid UART Cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
deviceFile = uartCookie->getDeviceFile();
|
||||
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||
FSFW_LOGWT("{}", "sendMessage: Device file {} not in UART map\n", deviceFile);
|
||||
FSFW_FLOGWT("{}", "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_LOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno));
|
||||
FSFW_FLOGE("sendMessage: Failed to send data with error code {} | {}", errno, strerror(errno));
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -350,7 +351,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
|
||||
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
FSFW_LOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n");
|
||||
FSFW_FLOGWT("{}", "requestReceiveMessage: Invalid UART Cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
@ -363,7 +364,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
|
||||
}
|
||||
|
||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||
FSFW_LOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile);
|
||||
FSFW_FLOGW("requestReceiveMessage: Device file {} not in UART map\n", deviceFile);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -392,7 +393,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_LOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n");
|
||||
FSFW_FLOGWT("{}", "requestReceiveMessage: Next read would cause overflow\n");
|
||||
result = UART_RX_BUFFER_TOO_SMALL;
|
||||
break;
|
||||
} else {
|
||||
@ -403,7 +404,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
|
||||
if (bytesRead < 0) {
|
||||
// EAGAIN: No data available in non-blocking mode
|
||||
if (errno != EAGAIN) {
|
||||
FSFW_LOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno));
|
||||
FSFW_FLOGWT("handleCanonicalRead: read failed with code {} | {}\n", errno, strerror(errno));
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -423,7 +424,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_LOGW("{}", "requestReceiveMessage: Next read would cause overflow\n");
|
||||
FSFW_FLOGW("{}", "requestReceiveMessage: Next read would cause overflow\n");
|
||||
return UART_RX_BUFFER_TOO_SMALL;
|
||||
}
|
||||
ssize_t bytesRead = read(fd, bufferPtr, requestLen);
|
||||
@ -431,8 +432,8 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi
|
||||
return RETURN_FAILED;
|
||||
} else if (bytesRead != static_cast<int>(requestLen)) {
|
||||
if (uartCookie.isReplySizeFixed()) {
|
||||
FSFW_LOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead,
|
||||
requestLen);
|
||||
FSFW_FLOGWT("UartComIF::requestReceiveMessage: Only read {} of {} bytes\n", bytesRead,
|
||||
requestLen);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
}
|
||||
@ -446,14 +447,14 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
||||
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
FSFW_LOGWT("{}", "readReceivedMessage: Invalid uart cookie");
|
||||
FSFW_FLOGWT("{}", "readReceivedMessage: Invalid uart cookie");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
|
||||
deviceFile = uartCookie->getDeviceFile();
|
||||
uartDeviceMapIter = uartDeviceMap.find(deviceFile);
|
||||
if (uartDeviceMapIter == uartDeviceMap.end()) {
|
||||
FSFW_LOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile);
|
||||
FSFW_FLOGW("UartComIF::readReceivedMessage: Device file {} not in UART map\n", deviceFile);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
|
||||
@ -471,7 +472,7 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
|
||||
UartDeviceMapIter uartDeviceMapIter;
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
FSFW_LOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n");
|
||||
FSFW_FLOGWT("{}", "flushUartRxBuffer: Invalid UART cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
deviceFile = uartCookie->getDeviceFile();
|
||||
@ -489,7 +490,7 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
|
||||
UartDeviceMapIter uartDeviceMapIter;
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
FSFW_LOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n");
|
||||
FSFW_FLOGWT("{}", "flushUartTxBuffer: Invalid uart cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
deviceFile = uartCookie->getDeviceFile();
|
||||
@ -507,7 +508,7 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
|
||||
UartDeviceMapIter uartDeviceMapIter;
|
||||
auto* uartCookie = dynamic_cast<UartCookie*>(cookie);
|
||||
if (uartCookie == nullptr) {
|
||||
FSFW_LOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n");
|
||||
FSFW_FLOGWT("{}", "flushUartTxAndRxBuf: Invalid UART cookie\n");
|
||||
return NULLPOINTER;
|
||||
}
|
||||
deviceFile = uartCookie->getDeviceFile();
|
||||
|
@ -3,21 +3,11 @@
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/serviceinterface.h"
|
||||
|
||||
void utility::handleIoctlError(const char* const customPrintout) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
if (customPrintout != nullptr) {
|
||||
sif::warning << customPrintout << std::endl;
|
||||
FSFW_LOGW(customPrintout);
|
||||
}
|
||||
sif::warning << "handleIoctlError: Error code " << errno << ", " << strerror(errno) << std::endl;
|
||||
#else
|
||||
if (customPrintout != nullptr) {
|
||||
sif::printWarning("%s\n", customPrintout);
|
||||
}
|
||||
sif::printWarning("handleIoctlError: Error code %d, %s\n", errno, strerror(errno));
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
FSFW_LOGW("Error code {} | {}\n", errno, strerror(errno));
|
||||
}
|
||||
|
Reference in New Issue
Block a user