|
|
|
@ -3,7 +3,7 @@
|
|
|
|
|
|
|
|
|
|
#include "fsfw/serviceinterface.h"
|
|
|
|
|
|
|
|
|
|
void uart::setMode(struct termios& options, UartModes mode) {
|
|
|
|
|
void serial::setMode(struct termios& options, UartModes mode) {
|
|
|
|
|
if (mode == UartModes::NON_CANONICAL) {
|
|
|
|
|
/* Disable canonical mode */
|
|
|
|
|
options.c_lflag &= ~ICANON;
|
|
|
|
@ -12,7 +12,7 @@ void uart::setMode(struct termios& options, UartModes mode) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void uart::setBaudrate(struct termios& options, UartBaudRate baud) {
|
|
|
|
|
void serial::setBaudrate(struct termios& options, UartBaudRate baud) {
|
|
|
|
|
switch (baud) {
|
|
|
|
|
case UartBaudRate::RATE_50:
|
|
|
|
|
cfsetspeed(&options, B50);
|
|
|
|
@ -114,7 +114,7 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void uart::setBitsPerWord(struct termios& options, BitsPerWord bits) {
|
|
|
|
|
void serial::setBitsPerWord(struct termios& options, BitsPerWord bits) {
|
|
|
|
|
options.c_cflag &= ~CSIZE; // Clear all the size bits
|
|
|
|
|
if (bits == BitsPerWord::BITS_5) {
|
|
|
|
|
options.c_cflag |= CS5;
|
|
|
|
@ -127,11 +127,11 @@ void uart::setBitsPerWord(struct termios& options, BitsPerWord bits) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void uart::enableRead(struct termios& options) { options.c_cflag |= CREAD; }
|
|
|
|
|
void serial::enableRead(struct termios& options) { options.c_cflag |= CREAD; }
|
|
|
|
|
|
|
|
|
|
void uart::ignoreCtrlLines(struct termios& options) { options.c_cflag |= CLOCAL; }
|
|
|
|
|
void serial::ignoreCtrlLines(struct termios& options) { options.c_cflag |= CLOCAL; }
|
|
|
|
|
|
|
|
|
|
void uart::setParity(struct termios& options, Parity parity) {
|
|
|
|
|
void serial::setParity(struct termios& options, Parity parity) {
|
|
|
|
|
/* Clear parity bit */
|
|
|
|
|
options.c_cflag &= ~PARENB;
|
|
|
|
|
switch (parity) {
|
|
|
|
@ -148,11 +148,11 @@ void uart::setParity(struct termios& options, Parity parity) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int uart::readCountersAndErrors(int serialPort, serial_icounter_struct& icounter) {
|
|
|
|
|
int serial::readCountersAndErrors(int serialPort, serial_icounter_struct& icounter) {
|
|
|
|
|
return ioctl(serialPort, TIOCGICOUNT, &icounter);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void uart::setStopbits(struct termios& options, StopBits bits) {
|
|
|
|
|
void serial::setStopbits(struct termios& options, StopBits bits) {
|
|
|
|
|
if (bits == StopBits::TWO_STOP_BITS) {
|
|
|
|
|
// Use two stop bits
|
|
|
|
|
options.c_cflag |= CSTOPB;
|
|
|
|
@ -162,6 +162,6 @@ void uart::setStopbits(struct termios& options, StopBits bits) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void uart::flushRxBuf(int fd) { tcflush(fd, TCIFLUSH); }
|
|
|
|
|
void serial::flushRxBuf(int fd) { tcflush(fd, TCIFLUSH); }
|
|
|
|
|
|
|
|
|
|
void uart::flushTxRxBuf(int fd) { tcflush(fd, TCIOFLUSH); }
|
|
|
|
|
void serial::flushTxRxBuf(int fd) { tcflush(fd, TCIOFLUSH); }
|
|
|
|
|