Compare commits

...

2 Commits

Author SHA1 Message Date
3b0ee7ca31 i forgot to push.. 2024-04-17 10:07:09 +02:00
f307a86d9a improve linux interface 2024-04-11 13:11:51 +02:00
2 changed files with 9 additions and 4 deletions

View File

@@ -1,6 +1,8 @@
#include <fsfw_hal/linux/serial/helper.h>
#include <sys/ioctl.h>
#include <termios.h>
#include "FSFWConfig.h"
#include "fsfw/serviceinterface.h"
void serial::setMode(struct termios& options, UartModes mode) {
@@ -108,7 +110,7 @@ void serial::setBaudrate(struct termios& options, UartBaudRate baud) {
#endif // ! __APPLE__
default:
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "UartComIF::configureBaudrate: Baudrate not supported" << std::endl;
sif::warning << "serial::configureBaudrate: Baudrate not supported" << std::endl;
#endif
break;
}
@@ -153,15 +155,17 @@ int serial::readCountersAndErrors(int serialPort, serial_icounter_struct& icount
}
void serial::setStopbits(struct termios& options, StopBits bits) {
// Regular case: One stop bit.
options.c_cflag &= ~CSTOPB;
if (bits == StopBits::TWO_STOP_BITS) {
// Use two stop bits
options.c_cflag |= CSTOPB;
} else {
// Clear stop field, only one stop bit used in communication
options.c_cflag &= ~CSTOPB;
}
}
void serial::flushRxBuf(int fd) { tcflush(fd, TCIFLUSH); }
void serial::flushTxBuf(int fd) { tcflush(fd, TCOFLUSH); }
void serial::flushTxRxBuf(int fd) { tcflush(fd, TCIOFLUSH); }

View File

@@ -65,6 +65,7 @@ void setParity(struct termios& options, Parity parity);
void ignoreCtrlLines(struct termios& options);
void flushRxBuf(int fd);
void flushTxBuf(int fd);
void flushTxRxBuf(int fd);
int readCountersAndErrors(int serialPort, serial_icounter_struct& icounter);