fsfw/src/fsfw_hal/linux/serial/SerialCookie.cpp

52 lines
1.7 KiB
C++
Raw Normal View History

2022-11-11 11:34:58 +01:00
#include "SerialCookie.h"
#include <fsfw/serviceinterface.h>
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
SerialCookie::SerialCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate,
2022-11-21 14:56:08 +01:00
size_t maxReplyLen, UartModes uartMode)
2022-02-02 10:29:30 +01:00
: handlerId(handlerId),
deviceFile(deviceFile),
uartMode(uartMode),
baudrate(baudrate),
maxReplyLen(maxReplyLen) {}
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
SerialCookie::~SerialCookie() {}
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
UartBaudRate SerialCookie::getBaudrate() const { return baudrate; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
size_t SerialCookie::getMaxReplyLen() const { return maxReplyLen; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
std::string SerialCookie::getDeviceFile() const { return deviceFile; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
void SerialCookie::setParityOdd() { parity = Parity::ODD; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
void SerialCookie::setParityEven() { parity = Parity::EVEN; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
Parity SerialCookie::getParity() const { return parity; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
void SerialCookie::setBitsPerWord(BitsPerWord bitsPerWord_) { bitsPerWord = bitsPerWord_; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
BitsPerWord SerialCookie::getBitsPerWord() const { return bitsPerWord; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
StopBits SerialCookie::getStopBits() const { return stopBits; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
void SerialCookie::setTwoStopBits() { stopBits = StopBits::TWO_STOP_BITS; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
void SerialCookie::setOneStopBit() { stopBits = StopBits::ONE_STOP_BIT; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
UartModes SerialCookie::getUartMode() const { return uartMode; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
void SerialCookie::setReadCycles(uint8_t readCycles) { this->readCycles = readCycles; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
void SerialCookie::setToFlushInput(bool enable) { this->flushInput = enable; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
uint8_t SerialCookie::getReadCycles() const { return readCycles; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
bool SerialCookie::getInputShouldBeFlushed() { return this->flushInput; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
object_id_t SerialCookie::getHandlerId() const { return this->handlerId; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
void SerialCookie::setNoFixedSizeReply() { replySizeFixed = false; }
2021-07-13 19:19:25 +02:00
2022-11-11 11:33:35 +01:00
bool SerialCookie::isReplySizeFixed() { return replySizeFixed; }