diff --git a/hardwaresetup.cpp b/hardwaresetup.cpp index 5aaf945..ad2ce93 100644 --- a/hardwaresetup.cpp +++ b/hardwaresetup.cpp @@ -302,6 +302,7 @@ void HardwareSetup::run() { } } // end HARDWARE_VERSION 2 else if (HARDWARE_VERSION == 3) { + fd = open(PORT_PATH, O_RDONLY); while (this->fd < 0) { // wait 1 second @@ -310,25 +311,24 @@ void HardwareSetup::run() { fd = open(PORT_PATH, O_RDONLY); } cout << "Port opened" << endl; - // port opened // prepare buffer struct TransStruct * received; uint8_t uintBuf[4 * 6]; void * voidBuf; - // flush existing data + // configure among others non-canonical mode (important) struct termios config; tcgetattr(fd, &config); config.c_lflag = 0; // standard value is bad choosen - tcsetattr(fd, TCSANOW, &config); - cout << "alles io" << endl; - ssize_t length = read(fd, uintBuf, 24); - if (length < 24) { + // read raw data to buffer + ssize_t length = read(fd, uintBuf, 24); + + // flush existing data + if (length < 24) { tcflush(fd, TCIFLUSH); - // length = read(fd, uintBuf, 24); } while (!this->stop) {