Merge remote-tracking branch 'origin/develop' into mueller/improve-ss-dhb-logic

This commit is contained in:
Robin Müller 2022-10-27 08:30:30 +02:00
commit fa01798ebb
10 changed files with 37 additions and 58 deletions

View File

@ -40,6 +40,7 @@ class HasFileSystemIF {
//! [EXPORT] : P1: Can be file system specific error code //! [EXPORT] : P1: Can be file system specific error code
static constexpr ReturnValue_t GENERIC_FILE_ERROR = MAKE_RETURN_CODE(0); static constexpr ReturnValue_t GENERIC_FILE_ERROR = MAKE_RETURN_CODE(0);
static constexpr ReturnValue_t GENERIC_DIR_ERROR = MAKE_RETURN_CODE(1); static constexpr ReturnValue_t GENERIC_DIR_ERROR = MAKE_RETURN_CODE(1);
static constexpr ReturnValue_t FILESYSTEM_INACTIVE = MAKE_RETURN_CODE(2);
static constexpr ReturnValue_t GENERIC_RENAME_ERROR = MAKE_RETURN_CODE(3); static constexpr ReturnValue_t GENERIC_RENAME_ERROR = MAKE_RETURN_CODE(3);
//! [EXPORT] : File system is currently busy //! [EXPORT] : File system is currently busy

View File

@ -214,7 +214,7 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, struct gpiod
} }
ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) { ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
gpioMapIter = gpioMap.find(gpioId); auto gpioMapIter = gpioMap.find(gpioId);
if (gpioMapIter == gpioMap.end()) { if (gpioMapIter == gpioMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::pullHigh: Unknown GPIO ID " << gpioId << std::endl; sif::warning << "LinuxLibgpioIF::pullHigh: Unknown GPIO ID " << gpioId << std::endl;
@ -244,7 +244,7 @@ ReturnValue_t LinuxLibgpioIF::pullHigh(gpioId_t gpioId) {
} }
ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) { ReturnValue_t LinuxLibgpioIF::pullLow(gpioId_t gpioId) {
gpioMapIter = gpioMap.find(gpioId); auto gpioMapIter = gpioMap.find(gpioId);
if (gpioMapIter == gpioMap.end()) { if (gpioMapIter == gpioMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::pullLow: Unknown GPIO ID " << gpioId << std::endl; sif::warning << "LinuxLibgpioIF::pullLow: Unknown GPIO ID " << gpioId << std::endl;
@ -295,7 +295,7 @@ ReturnValue_t LinuxLibgpioIF::driveGpio(gpioId_t gpioId, GpiodRegularBase& regul
} }
ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, gpio::Levels& gpioState) { ReturnValue_t LinuxLibgpioIF::readGpio(gpioId_t gpioId, gpio::Levels& gpioState) {
gpioMapIter = gpioMap.find(gpioId); auto gpioMapIter = gpioMap.find(gpioId);
if (gpioMapIter == gpioMap.end()) { if (gpioMapIter == gpioMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl; sif::warning << "LinuxLibgpioIF::readGpio: Unknown GPIOD ID " << gpioId << std::endl;
@ -377,7 +377,7 @@ ReturnValue_t LinuxLibgpioIF::checkForConflictsById(gpioId_t gpioIdToCheck,
gpio::GpioTypes expectedType, gpio::GpioTypes expectedType,
GpioMap& mapToAdd) { GpioMap& mapToAdd) {
// Cross check with private map // Cross check with private map
gpioMapIter = gpioMap.find(gpioIdToCheck); auto gpioMapIter = gpioMap.find(gpioIdToCheck);
if (gpioMapIter != gpioMap.end()) { if (gpioMapIter != gpioMap.end()) {
auto& gpioType = gpioMapIter->second->gpioType; auto& gpioType = gpioMapIter->second->gpioType;
bool eraseDuplicateDifferentType = false; bool eraseDuplicateDifferentType = false;

View File

@ -44,7 +44,6 @@ class LinuxLibgpioIF : public GpioIF, public SystemObject {
// Holds the information and configuration of all used GPIOs // Holds the information and configuration of all used GPIOs
GpioUnorderedMap gpioMap; GpioUnorderedMap gpioMap;
GpioUnorderedMapIter gpioMapIter;
/** /**
* @brief This functions drives line of a GPIO specified by the GPIO ID. * @brief This functions drives line of a GPIO specified by the GPIO ID.

View File

@ -41,7 +41,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) {
i2cAddress = i2cCookie->getAddress(); i2cAddress = i2cCookie->getAddress();
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
if (i2cDeviceMapIter == i2cDeviceMap.end()) { if (i2cDeviceMapIter == i2cDeviceMap.end()) {
size_t maxReplyLen = i2cCookie->getMaxReplyLen(); size_t maxReplyLen = i2cCookie->getMaxReplyLen();
I2cInstance i2cInstance = {std::vector<uint8_t>(maxReplyLen), 0}; I2cInstance i2cInstance = {std::vector<uint8_t>(maxReplyLen), 0};
@ -89,7 +89,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
} }
address_t i2cAddress = i2cCookie->getAddress(); address_t i2cAddress = i2cCookie->getAddress();
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
if (i2cDeviceMapIter == i2cDeviceMap.end()) { if (i2cDeviceMapIter == i2cDeviceMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not " sif::error << "I2cComIF::sendMessage: i2cAddress of Cookie not "
@ -140,20 +140,19 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::requestReceiveMessage: Invalid I2C Cookie!" << std::endl; sif::error << "I2cComIF::requestReceiveMessage: Invalid I2C Cookie!" << std::endl;
#endif #endif
i2cDeviceMapIter->second.replyLen = 0;
return NULLPOINTER; return NULLPOINTER;
} }
address_t i2cAddress = i2cCookie->getAddress(); address_t i2cAddress = i2cCookie->getAddress();
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
if (i2cDeviceMapIter == i2cDeviceMap.end()) { if (i2cDeviceMapIter == i2cDeviceMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::requestReceiveMessage: i2cAddress of Cookie not " sif::error << "I2cComIF::requestReceiveMessage: i2cAddress of Cookie not "
<< "registered in i2cDeviceMap" << std::endl; << "registered in i2cDeviceMap" << std::endl;
#endif #endif
i2cDeviceMapIter->second.replyLen = 0;
return returnvalue::FAILED; return returnvalue::FAILED;
} }
i2cDeviceMapIter->second.replyLen = 0;
deviceFile = i2cCookie->getDeviceFile(); deviceFile = i2cCookie->getDeviceFile();
UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage"); UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage");
@ -162,7 +161,6 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
} }
result = openDevice(deviceFile, i2cAddress, &fd); result = openDevice(deviceFile, i2cAddress, &fd);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
i2cDeviceMapIter->second.replyLen = 0;
return result; return result;
} }
@ -183,7 +181,10 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe
#else #else
#endif #endif
#endif #endif
i2cDeviceMapIter->second.replyLen = 0; #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "I2cComIF::requestReceiveMessage: Read " << readLen << " of " << requestLen
<< " bytes" << std::endl;
#endif
return returnvalue::FAILED; return returnvalue::FAILED;
} }
@ -206,7 +207,7 @@ ReturnValue_t I2cComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
} }
address_t i2cAddress = i2cCookie->getAddress(); address_t i2cAddress = i2cCookie->getAddress();
i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress); auto i2cDeviceMapIter = i2cDeviceMap.find(i2cAddress);
if (i2cDeviceMapIter == i2cDeviceMap.end()) { if (i2cDeviceMapIter == i2cDeviceMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not " sif::error << "I2cComIF::readReceivedMessage: i2cAddress of Cookie not "

View File

@ -36,12 +36,10 @@ class I2cComIF : public DeviceCommunicationIF, public SystemObject {
}; };
using I2cDeviceMap = std::unordered_map<address_t, I2cInstance>; using I2cDeviceMap = std::unordered_map<address_t, I2cInstance>;
using I2cDeviceMapIter = I2cDeviceMap::iterator;
/* In this map all i2c devices will be registered with their address and /* In this map all i2c devices will be registered with their address and
* the appropriate file descriptor will be stored */ * the appropriate file descriptor will be stored */
I2cDeviceMap i2cDeviceMap; I2cDeviceMap i2cDeviceMap;
I2cDeviceMapIter i2cDeviceMapIter;
/** /**
* @brief This function opens an I2C device and binds the opened file * @brief This function opens an I2C device and binds the opened file

View File

@ -15,18 +15,8 @@
#include "fsfw_hal/linux/spi/SpiCookie.h" #include "fsfw_hal/linux/spi/SpiCookie.h"
#include "fsfw_hal/linux/utility.h" #include "fsfw_hal/linux/utility.h"
SpiComIF::SpiComIF(object_id_t objectId, std::string devname, GpioIF* gpioComIF) SpiComIF::SpiComIF(object_id_t objectId, std::string devname, GpioIF& gpioComIF)
: SystemObject(objectId), gpioComIF(gpioComIF), dev(std::move(devname)) { : SystemObject(objectId), gpioComIF(gpioComIF), dev(std::move(devname)) {
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 */
}
csMutex = MutexFactory::instance()->createMutex(); csMutex = MutexFactory::instance()->createMutex();
} }
@ -75,7 +65,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF* cookie) {
/* Pull CS high in any case to be sure that device is inactive */ /* Pull CS high in any case to be sure that device is inactive */
gpioId_t gpioId = spiCookie->getChipSelectPin(); gpioId_t gpioId = spiCookie->getChipSelectPin();
if (gpioId != gpio::NO_GPIO) { if (gpioId != gpio::NO_GPIO) {
gpioComIF->pullHigh(gpioId); gpioComIF.pullHigh(gpioId);
} }
uint32_t spiSpeed = 0; uint32_t spiSpeed = 0;
@ -215,7 +205,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
return result; return result;
} }
updateLinePolarity(fileDescriptor); updateLinePolarity(fileDescriptor);
result = gpioComIF->pullLow(gpioId); result = gpioComIF.pullLow(gpioId);
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_VERBOSE_LEVEL >= 1 #if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -256,7 +246,7 @@ ReturnValue_t SpiComIF::performRegularSendOperation(SpiCookie* spiCookie, const
} }
if (gpioId != gpio::NO_GPIO and not csLockManual) { if (gpioId != gpio::NO_GPIO and not csLockManual) {
gpioComIF->pullHigh(gpioId); gpioComIF.pullHigh(gpioId);
result = csMutex->unlockMutex(); result = csMutex->unlockMutex();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -317,7 +307,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
#endif #endif
return result; return result;
} }
gpioComIF->pullLow(gpioId); gpioComIF.pullLow(gpioId);
} }
if (read(fileDescriptor, rxBuf, readSize) != static_cast<ssize_t>(readSize)) { if (read(fileDescriptor, rxBuf, readSize) != static_cast<ssize_t>(readSize)) {
@ -332,7 +322,7 @@ ReturnValue_t SpiComIF::performHalfDuplexReception(SpiCookie* spiCookie) {
} }
if (gpioId != gpio::NO_GPIO and not csLockManual) { if (gpioId != gpio::NO_GPIO and not csLockManual) {
gpioComIF->pullHigh(gpioId); gpioComIF.pullHigh(gpioId);
result = csMutex->unlockMutex(); result = csMutex->unlockMutex();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -397,7 +387,7 @@ ReturnValue_t SpiComIF::getReadBuffer(address_t spiAddress, uint8_t** buffer) {
return returnvalue::OK; return returnvalue::OK;
} }
GpioIF* SpiComIF::getGpioInterface() { return gpioComIF; } GpioIF& SpiComIF::getGpioInterface() { return gpioComIF; }
void SpiComIF::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) { void SpiComIF::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed) {
int retval = ioctl(spiFd, SPI_IOC_WR_MODE, reinterpret_cast<uint8_t*>(&mode)); int retval = ioctl(spiFd, SPI_IOC_WR_MODE, reinterpret_cast<uint8_t*>(&mode));

View File

@ -31,7 +31,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject {
static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED = static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED =
returnvalue::makeCode(spiRetvalId, 2); returnvalue::makeCode(spiRetvalId, 2);
SpiComIF(object_id_t objectId, std::string devname, GpioIF* gpioComIF); SpiComIF(object_id_t objectId, std::string devname, GpioIF& gpioComIF);
ReturnValue_t initializeInterface(CookieIF* cookie) override; ReturnValue_t initializeInterface(CookieIF* cookie) override;
ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override; ReturnValue_t sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) override;
@ -57,7 +57,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject {
ReturnValue_t performRegularSendOperation(SpiCookie* spiCookie, const uint8_t* sendData, ReturnValue_t performRegularSendOperation(SpiCookie* spiCookie, const uint8_t* sendData,
size_t sendLen); size_t sendLen);
GpioIF* getGpioInterface(); GpioIF& getGpioInterface();
void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed); void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed);
void getSpiSpeedAndMode(int spiFd, spi::SpiModes& mode, uint32_t& speed) const; void getSpiSpeedAndMode(int spiFd, spi::SpiModes& mode, uint32_t& speed) const;
@ -83,7 +83,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject {
std::vector<uint8_t> replyBuffer; std::vector<uint8_t> replyBuffer;
}; };
GpioIF* gpioComIF = nullptr; GpioIF& gpioComIF;
std::string dev = ""; std::string dev = "";
/** /**
* Protects the chip select operations. Lock when GPIO is pulled low, unlock after it was * Protects the chip select operations. Lock when GPIO is pulled low, unlock after it was

View File

@ -17,7 +17,6 @@ UartComIF::~UartComIF() {}
ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) { ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
std::string deviceFile; std::string deviceFile;
UartDeviceMapIter uartDeviceMapIter;
if (cookie == nullptr) { if (cookie == nullptr) {
return NULLPOINTER; return NULLPOINTER;
@ -33,7 +32,7 @@ ReturnValue_t UartComIF::initializeInterface(CookieIF* cookie) {
deviceFile = uartCookie->getDeviceFile(); deviceFile = uartCookie->getDeviceFile();
uartDeviceMapIter = uartDeviceMap.find(deviceFile); auto uartDeviceMapIter = uartDeviceMap.find(deviceFile);
if (uartDeviceMapIter == uartDeviceMap.end()) { if (uartDeviceMapIter == uartDeviceMap.end()) {
int fileDescriptor = configureUartPort(uartCookie); int fileDescriptor = configureUartPort(uartCookie);
if (fileDescriptor < 0) { if (fileDescriptor < 0) {
@ -194,7 +193,6 @@ void UartComIF::setFixedOptions(struct termios* options) {
ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) {
int fd = 0; int fd = 0;
std::string deviceFile; std::string deviceFile;
UartDeviceMapIter uartDeviceMapIter;
if (sendLen == 0) { if (sendLen == 0) {
return returnvalue::OK; return returnvalue::OK;
@ -216,7 +214,7 @@ ReturnValue_t UartComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData,
} }
deviceFile = uartCookie->getDeviceFile(); deviceFile = uartCookie->getDeviceFile();
uartDeviceMapIter = uartDeviceMap.find(deviceFile); auto uartDeviceMapIter = uartDeviceMap.find(deviceFile);
if (uartDeviceMapIter == uartDeviceMap.end()) { if (uartDeviceMapIter == uartDeviceMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "UartComIF::sendMessage: Device file " << deviceFile << "not in UART map" sif::debug << "UartComIF::sendMessage: Device file " << deviceFile << "not in UART map"
@ -242,7 +240,6 @@ ReturnValue_t UartComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::
ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
std::string deviceFile; std::string deviceFile;
UartDeviceMapIter uartDeviceMapIter;
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie); UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) { if (uartCookie == nullptr) {
@ -254,7 +251,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
UartModes uartMode = uartCookie->getUartMode(); UartModes uartMode = uartCookie->getUartMode();
deviceFile = uartCookie->getDeviceFile(); deviceFile = uartCookie->getDeviceFile();
uartDeviceMapIter = uartDeviceMap.find(deviceFile); auto uartDeviceMapIter = uartDeviceMap.find(deviceFile);
if (uartMode == UartModes::NON_CANONICAL and requestLen == 0) { if (uartMode == UartModes::NON_CANONICAL and requestLen == 0) {
return returnvalue::OK; return returnvalue::OK;
@ -277,7 +274,7 @@ ReturnValue_t UartComIF::requestReceiveMessage(CookieIF* cookie, size_t requestL
} }
} }
ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter,
size_t requestLen) { size_t requestLen) {
ReturnValue_t result = returnvalue::OK; ReturnValue_t result = returnvalue::OK;
uint8_t maxReadCycles = uartCookie.getReadCycles(); uint8_t maxReadCycles = uartCookie.getReadCycles();
@ -335,7 +332,7 @@ ReturnValue_t UartComIF::handleCanonicalRead(UartCookie& uartCookie, UartDeviceM
return result; return result;
} }
ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter,
size_t requestLen) { size_t requestLen) {
int fd = iter->second.fileDescriptor; int fd = iter->second.fileDescriptor;
auto bufferPtr = iter->second.replyBuffer.data(); auto bufferPtr = iter->second.replyBuffer.data();
@ -371,7 +368,6 @@ ReturnValue_t UartComIF::handleNoncanonicalRead(UartCookie& uartCookie, UartDevi
ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
std::string deviceFile; std::string deviceFile;
UartDeviceMapIter uartDeviceMapIter;
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie); UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) { if (uartCookie == nullptr) {
@ -382,7 +378,7 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
} }
deviceFile = uartCookie->getDeviceFile(); deviceFile = uartCookie->getDeviceFile();
uartDeviceMapIter = uartDeviceMap.find(deviceFile); auto uartDeviceMapIter = uartDeviceMap.find(deviceFile);
if (uartDeviceMapIter == uartDeviceMap.end()) { if (uartDeviceMapIter == uartDeviceMap.end()) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "UartComIF::readReceivedMessage: Device file " << deviceFile << " not in uart map" sif::debug << "UartComIF::readReceivedMessage: Device file " << deviceFile << " not in uart map"
@ -402,7 +398,6 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) { ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
std::string deviceFile; std::string deviceFile;
UartDeviceMapIter uartDeviceMapIter;
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie); UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) { if (uartCookie == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -411,7 +406,7 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
return NULLPOINTER; return NULLPOINTER;
} }
deviceFile = uartCookie->getDeviceFile(); deviceFile = uartCookie->getDeviceFile();
uartDeviceMapIter = uartDeviceMap.find(deviceFile); auto uartDeviceMapIter = uartDeviceMap.find(deviceFile);
if (uartDeviceMapIter != uartDeviceMap.end()) { if (uartDeviceMapIter != uartDeviceMap.end()) {
int fd = uartDeviceMapIter->second.fileDescriptor; int fd = uartDeviceMapIter->second.fileDescriptor;
tcflush(fd, TCIFLUSH); tcflush(fd, TCIFLUSH);
@ -422,7 +417,6 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF* cookie) {
ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) { ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
std::string deviceFile; std::string deviceFile;
UartDeviceMapIter uartDeviceMapIter;
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie); UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) { if (uartCookie == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -431,7 +425,7 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
return NULLPOINTER; return NULLPOINTER;
} }
deviceFile = uartCookie->getDeviceFile(); deviceFile = uartCookie->getDeviceFile();
uartDeviceMapIter = uartDeviceMap.find(deviceFile); auto uartDeviceMapIter = uartDeviceMap.find(deviceFile);
if (uartDeviceMapIter != uartDeviceMap.end()) { if (uartDeviceMapIter != uartDeviceMap.end()) {
int fd = uartDeviceMapIter->second.fileDescriptor; int fd = uartDeviceMapIter->second.fileDescriptor;
tcflush(fd, TCOFLUSH); tcflush(fd, TCOFLUSH);
@ -442,7 +436,6 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF* cookie) {
ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
std::string deviceFile; std::string deviceFile;
UartDeviceMapIter uartDeviceMapIter;
UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie); UartCookie* uartCookie = dynamic_cast<UartCookie*>(cookie);
if (uartCookie == nullptr) { if (uartCookie == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
@ -451,7 +444,7 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) {
return NULLPOINTER; return NULLPOINTER;
} }
deviceFile = uartCookie->getDeviceFile(); deviceFile = uartCookie->getDeviceFile();
uartDeviceMapIter = uartDeviceMap.find(deviceFile); auto uartDeviceMapIter = uartDeviceMap.find(deviceFile);
if (uartDeviceMapIter != uartDeviceMap.end()) { if (uartDeviceMapIter != uartDeviceMap.end()) {
int fd = uartDeviceMapIter->second.fileDescriptor; int fd = uartDeviceMapIter->second.fileDescriptor;
tcflush(fd, TCIOFLUSH); tcflush(fd, TCIOFLUSH);

View File

@ -63,7 +63,6 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject {
}; };
using UartDeviceMap = std::unordered_map<UartDeviceFile_t, UartElements>; using UartDeviceMap = std::unordered_map<UartDeviceFile_t, UartElements>;
using UartDeviceMapIter = UartDeviceMap::iterator;
/** /**
* The uart devie map stores informations of initialized uart ports. * The uart devie map stores informations of initialized uart ports.
@ -102,9 +101,9 @@ class UartComIF : public DeviceCommunicationIF, public SystemObject {
*/ */
void setDatasizeOptions(struct termios* options, UartCookie* uartCookie); void setDatasizeOptions(struct termios* options, UartCookie* uartCookie);
ReturnValue_t handleCanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, ReturnValue_t handleCanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter,
size_t requestLen); size_t requestLen);
ReturnValue_t handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMapIter& iter, ReturnValue_t handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter,
size_t requestLen); size_t requestLen);
}; };

View File

@ -72,16 +72,14 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) {
cfsetospeed(&options, B19200); cfsetospeed(&options, B19200);
break; break;
case UartBaudRate::RATE_38400: case UartBaudRate::RATE_38400:
cfsetispeed(&options, B38400); cfsetspeed(&options, B38400);
cfsetospeed(&options, B38400);
break; break;
case UartBaudRate::RATE_57600: case UartBaudRate::RATE_57600:
cfsetispeed(&options, B57600); cfsetispeed(&options, B57600);
cfsetospeed(&options, B57600); cfsetospeed(&options, B57600);
break; break;
case UartBaudRate::RATE_115200: case UartBaudRate::RATE_115200:
cfsetispeed(&options, B115200); cfsetspeed(&options, B115200);
cfsetospeed(&options, B115200);
break; break;
case UartBaudRate::RATE_230400: case UartBaudRate::RATE_230400:
cfsetispeed(&options, B230400); cfsetispeed(&options, B230400);