extended uart com if with canonical mode

This commit is contained in:
2021-06-15 13:32:37 +02:00
parent cd0dfc49d5
commit cd9c9647ec
6 changed files with 86 additions and 49 deletions

View File

@ -15,8 +15,13 @@ enum class StopBits {
TWO_STOP_BITS
};
enum class UartModes {
CANONICAL,
NON_CANONICAL
};
/**
* @brief Cookie for the UartComIF. There are many options available to configure the uart driver.
* @brief Cookie for the UartComIF. There are many options available to configure the UART driver.
* The constructor only requests for common options like the baudrate. Other options can
* be set by member functions.
*
@ -27,19 +32,20 @@ public:
/**
* @brief Constructor for the uart cookie.
* @param deviceFile The device file specifying the uart to use. E.g. "/dev/ttyPS1".
* @param deviceFile The device file specifying the uart to use, e.g. "/dev/ttyPS1"
* @param uartMode Specify the UART mode. The canonical mode should be used if the
* messages are separated by a delimited character like '\n'. See the
* termios documentation for more information
* @param baudrate The baudrate to use for input and output. Possible Baudrates are: 50,
* 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, B19200,
* 38400, 57600, 115200, 230400, 460800
* @param maxReplyLen The maximum size an object using this cookie expects.
*
* @details Default configuration: No parity
* 8 databits (number of bits transfered with one uart frame)
* One stop bit
*
*
* @param maxReplyLen The maximum size an object using this cookie expects
* @details
* Default configuration: No parity
* 8 databits (number of bits transfered with one uart frame)
* One stop bit
*/
UartCookie(std::string deviceFile, uint32_t baudrate, size_t maxReplyLen);
UartCookie(std::string deviceFile, UartModes uartMode, uint32_t baudrate, size_t maxReplyLen);
virtual ~UartCookie();
@ -49,6 +55,7 @@ public:
Parity getParity() const;
uint8_t getBitsPerWord() const;
StopBits getStopBits() const;
UartModes getUartMode() const;
/**
* Functions two enable parity checking.
@ -67,10 +74,10 @@ public:
void setTwoStopBits();
void setOneStopBit();
private:
std::string deviceFile;
const UartModes uartMode;
uint32_t baudrate;
size_t maxReplyLen = 0;
Parity parity = Parity::NONE;