From dae039e563a656f51b79c614ce197c5cf7ce822d Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 11 Apr 2020 13:20:10 +0200 Subject: [PATCH] add FORWARD_RAW_TTY define to use raw output as option to forward data to a serial connection with same params as a usual bus interface --- src/lib/utils/rotatefile.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/lib/utils/rotatefile.cpp b/src/lib/utils/rotatefile.cpp index 8cf4cc68..19849a68 100755 --- a/src/lib/utils/rotatefile.cpp +++ b/src/lib/utils/rotatefile.cpp @@ -50,6 +50,22 @@ bool RotateFile::setEnabled(bool enabled) { if (enabled) { m_stream = fopen(m_fileName.c_str(), m_textMode ? "w" : "wb"); m_fileSize = 0; +#ifdef FORWARD_RAW_TTY + if (!m_textMode && isatty(fileno(m_stream)) == 1) { + int fd = fileno(m_stream); + struct termios newSettings; + memset(&newSettings, 0, sizeof(newSettings)); + + cfsetspeed(&newSettings, B2400); + newSettings.c_cflag |= (CS8 | CLOCAL); + newSettings.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); // non-canonical mode + newSettings.c_iflag |= IGNPAR; // ignore parity errors + newSettings.c_oflag &= ~OPOST; + + // activate new settings of serial device + tcsetattr(fd, TCSANOW, &newSettings); + } +#endif } return true; }