diff --git a/src/fsfw_hal/linux/serial/SerialComIF.cpp b/src/fsfw_hal/linux/serial/SerialComIF.cpp index 0fd293a0..a421326b 100644 --- a/src/fsfw_hal/linux/serial/SerialComIF.cpp +++ b/src/fsfw_hal/linux/serial/SerialComIF.cpp @@ -21,7 +21,7 @@ ReturnValue_t SerialComIF::initializeInterface(CookieIF* cookie) { return NULLPOINTER; } - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "UartComIF::initializeInterface: Invalid UART Cookie!" << std::endl; @@ -58,7 +58,7 @@ ReturnValue_t SerialComIF::initializeInterface(CookieIF* cookie) { return returnvalue::OK; } -int SerialComIF::configureUartPort(UartCookie* uartCookie) { +int SerialComIF::configureUartPort(SerialCookie* uartCookie) { struct termios options = {}; std::string deviceFile = uartCookie->getDeviceFile(); @@ -113,7 +113,7 @@ int SerialComIF::configureUartPort(UartCookie* uartCookie) { return fd; } -void SerialComIF::setStopBitOptions(struct termios* options, UartCookie* uartCookie) { +void SerialComIF::setStopBitOptions(struct termios* options, SerialCookie* uartCookie) { /* Clear stop field. Sets stop bit to one bit */ options->c_cflag &= ~CSTOPB; switch (uartCookie->getStopBits()) { @@ -125,7 +125,7 @@ void SerialComIF::setStopBitOptions(struct termios* options, UartCookie* uartCoo } } -void SerialComIF::setDatasizeOptions(struct termios* options, UartCookie* uartCookie) { +void SerialComIF::setDatasizeOptions(struct termios* options, SerialCookie* uartCookie) { /* Clear size bits */ options->c_cflag &= ~CSIZE; switch (uartCookie->getBitsPerWord()) { @@ -187,7 +187,7 @@ ReturnValue_t SerialComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData return returnvalue::FAILED; } - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::sendMessasge: Invalid UART Cookie!" << std::endl; @@ -223,7 +223,7 @@ ReturnValue_t SerialComIF::getSendSuccess(CookieIF* cookie) { return returnvalue ReturnValue_t SerialComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { std::string deviceFile; - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "UartComIF::requestReceiveMessage: Invalid Uart Cookie!" << std::endl; @@ -256,7 +256,7 @@ ReturnValue_t SerialComIF::requestReceiveMessage(CookieIF* cookie, size_t reques } } -ReturnValue_t SerialComIF::handleCanonicalRead(UartCookie& uartCookie, +ReturnValue_t SerialComIF::handleCanonicalRead(SerialCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen) { ReturnValue_t result = returnvalue::OK; uint8_t maxReadCycles = uartCookie.getReadCycles(); @@ -314,7 +314,7 @@ ReturnValue_t SerialComIF::handleCanonicalRead(UartCookie& uartCookie, return result; } -ReturnValue_t SerialComIF::handleNoncanonicalRead(UartCookie& uartCookie, +ReturnValue_t SerialComIF::handleNoncanonicalRead(SerialCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen) { int fd = iter->second.fileDescriptor; @@ -352,7 +352,7 @@ ReturnValue_t SerialComIF::handleNoncanonicalRead(UartCookie& uartCookie, ReturnValue_t SerialComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) { std::string deviceFile; - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::debug << "UartComIF::readReceivedMessage: Invalid uart cookie!" << std::endl; @@ -381,7 +381,7 @@ ReturnValue_t SerialComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffe ReturnValue_t SerialComIF::flushUartRxBuffer(CookieIF* cookie) { std::string deviceFile; - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::flushUartRxBuffer: Invalid uart cookie!" << std::endl; @@ -400,7 +400,7 @@ ReturnValue_t SerialComIF::flushUartRxBuffer(CookieIF* cookie) { ReturnValue_t SerialComIF::flushUartTxBuffer(CookieIF* cookie) { std::string deviceFile; - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::flushUartTxBuffer: Invalid uart cookie!" << std::endl; @@ -419,7 +419,7 @@ ReturnValue_t SerialComIF::flushUartTxBuffer(CookieIF* cookie) { ReturnValue_t SerialComIF::flushUartTxAndRxBuf(CookieIF* cookie) { std::string deviceFile; - UartCookie* uartCookie = dynamic_cast(cookie); + SerialCookie* uartCookie = dynamic_cast(cookie); if (uartCookie == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::warning << "UartComIF::flushUartTxAndRxBuf: Invalid uart cookie!" << std::endl; diff --git a/src/fsfw_hal/linux/serial/SerialComIF.h b/src/fsfw_hal/linux/serial/SerialComIF.h index 4953884a..907da7e0 100644 --- a/src/fsfw_hal/linux/serial/SerialComIF.h +++ b/src/fsfw_hal/linux/serial/SerialComIF.h @@ -75,9 +75,9 @@ class SerialComIF : public DeviceCommunicationIF, public SystemObject { * uart device file, baudrate, parity, stopbits etc. * @return The file descriptor of the configured uart. */ - int configureUartPort(UartCookie* uartCookie); + int configureUartPort(SerialCookie* uartCookie); - void setStopBitOptions(struct termios* options, UartCookie* uartCookie); + void setStopBitOptions(struct termios* options, SerialCookie* uartCookie); /** * @brief This function sets options which are not configurable by the uartCookie. @@ -87,11 +87,11 @@ class SerialComIF : public DeviceCommunicationIF, public SystemObject { /** * @brief With this function the datasize settings are added to the termios options struct. */ - void setDatasizeOptions(struct termios* options, UartCookie* uartCookie); + void setDatasizeOptions(struct termios* options, SerialCookie* uartCookie); - ReturnValue_t handleCanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, + ReturnValue_t handleCanonicalRead(SerialCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen); - ReturnValue_t handleNoncanonicalRead(UartCookie& uartCookie, UartDeviceMap::iterator& iter, + ReturnValue_t handleNoncanonicalRead(SerialCookie& uartCookie, UartDeviceMap::iterator& iter, size_t requestLen); }; diff --git a/src/fsfw_hal/linux/serial/SerialCookie.cpp b/src/fsfw_hal/linux/serial/SerialCookie.cpp index 733d84a5..0e2260a5 100644 --- a/src/fsfw_hal/linux/serial/SerialCookie.cpp +++ b/src/fsfw_hal/linux/serial/SerialCookie.cpp @@ -1,7 +1,7 @@ #include #include -UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, +SerialCookie::SerialCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, size_t maxReplyLen, UartModes uartMode) : handlerId(handlerId), deviceFile(deviceFile), @@ -9,42 +9,42 @@ UartCookie::UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRa baudrate(baudrate), maxReplyLen(maxReplyLen) {} -UartCookie::~UartCookie() {} +SerialCookie::~SerialCookie() {} -UartBaudRate UartCookie::getBaudrate() const { return baudrate; } +UartBaudRate SerialCookie::getBaudrate() const { return baudrate; } -size_t UartCookie::getMaxReplyLen() const { return maxReplyLen; } +size_t SerialCookie::getMaxReplyLen() const { return maxReplyLen; } -std::string UartCookie::getDeviceFile() const { return deviceFile; } +std::string SerialCookie::getDeviceFile() const { return deviceFile; } -void UartCookie::setParityOdd() { parity = Parity::ODD; } +void SerialCookie::setParityOdd() { parity = Parity::ODD; } -void UartCookie::setParityEven() { parity = Parity::EVEN; } +void SerialCookie::setParityEven() { parity = Parity::EVEN; } -Parity UartCookie::getParity() const { return parity; } +Parity SerialCookie::getParity() const { return parity; } -void UartCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; } +void SerialCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; } -BitsPerWord UartCookie::getBitsPerWord() const { return bitsPerWord; } +BitsPerWord SerialCookie::getBitsPerWord() const { return bitsPerWord; } -StopBits UartCookie::getStopBits() const { return stopBits; } +StopBits SerialCookie::getStopBits() const { return stopBits; } -void UartCookie::setTwoStopBits() { stopBits = StopBits::TWO_STOP_BITS; } +void SerialCookie::setTwoStopBits() { stopBits = StopBits::TWO_STOP_BITS; } -void UartCookie::setOneStopBit() { stopBits = StopBits::ONE_STOP_BIT; } +void SerialCookie::setOneStopBit() { stopBits = StopBits::ONE_STOP_BIT; } -UartModes UartCookie::getUartMode() const { return uartMode; } +UartModes SerialCookie::getUartMode() const { return uartMode; } -void UartCookie::setReadCycles(uint8_t readCycles) { this->readCycles = readCycles; } +void SerialCookie::setReadCycles(uint8_t readCycles) { this->readCycles = readCycles; } -void UartCookie::setToFlushInput(bool enable) { this->flushInput = enable; } +void SerialCookie::setToFlushInput(bool enable) { this->flushInput = enable; } -uint8_t UartCookie::getReadCycles() const { return readCycles; } +uint8_t SerialCookie::getReadCycles() const { return readCycles; } -bool UartCookie::getInputShouldBeFlushed() { return this->flushInput; } +bool SerialCookie::getInputShouldBeFlushed() { return this->flushInput; } -object_id_t UartCookie::getHandlerId() const { return this->handlerId; } +object_id_t SerialCookie::getHandlerId() const { return this->handlerId; } -void UartCookie::setNoFixedSizeReply() { replySizeFixed = false; } +void SerialCookie::setNoFixedSizeReply() { replySizeFixed = false; } -bool UartCookie::isReplySizeFixed() { return replySizeFixed; } +bool SerialCookie::isReplySizeFixed() { return replySizeFixed; } diff --git a/src/fsfw_hal/linux/serial/SerialCookie.h b/src/fsfw_hal/linux/serial/SerialCookie.h index 8d0f5fb4..3916e4ca 100644 --- a/src/fsfw_hal/linux/serial/SerialCookie.h +++ b/src/fsfw_hal/linux/serial/SerialCookie.h @@ -14,7 +14,7 @@ * * @author J. Meier */ -class UartCookie : public CookieIF { +class SerialCookie : public CookieIF { public: /** * @brief Constructor for the uart cookie. @@ -29,10 +29,10 @@ class UartCookie : public CookieIF { * 8 databits (number of bits transfered with one uart frame) * One stop bit */ - UartCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, + SerialCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, size_t maxReplyLen, UartModes uartMode = UartModes::NON_CANONICAL); - virtual ~UartCookie(); + virtual ~SerialCookie(); UartBaudRate getBaudrate() const; size_t getMaxReplyLen() const;