comments to reading and buffering of HW-version 3
This commit is contained in:
@@ -302,6 +302,7 @@ void HardwareSetup::run() {
|
|||||||
}
|
}
|
||||||
} // end HARDWARE_VERSION 2
|
} // end HARDWARE_VERSION 2
|
||||||
else if (HARDWARE_VERSION == 3) {
|
else if (HARDWARE_VERSION == 3) {
|
||||||
|
|
||||||
fd = open(PORT_PATH, O_RDONLY);
|
fd = open(PORT_PATH, O_RDONLY);
|
||||||
while (this->fd < 0) {
|
while (this->fd < 0) {
|
||||||
// wait 1 second
|
// wait 1 second
|
||||||
@@ -310,25 +311,24 @@ void HardwareSetup::run() {
|
|||||||
fd = open(PORT_PATH, O_RDONLY);
|
fd = open(PORT_PATH, O_RDONLY);
|
||||||
}
|
}
|
||||||
cout << "Port opened" << endl;
|
cout << "Port opened" << endl;
|
||||||
// port opened
|
|
||||||
|
|
||||||
// prepare buffer
|
// prepare buffer
|
||||||
struct TransStruct * received;
|
struct TransStruct * received;
|
||||||
uint8_t uintBuf[4 * 6];
|
uint8_t uintBuf[4 * 6];
|
||||||
void * voidBuf;
|
void * voidBuf;
|
||||||
|
|
||||||
// flush existing data
|
// configure among others non-canonical mode (important)
|
||||||
struct termios config;
|
struct termios config;
|
||||||
tcgetattr(fd, &config);
|
tcgetattr(fd, &config);
|
||||||
config.c_lflag = 0; // standard value is bad choosen
|
config.c_lflag = 0; // standard value is bad choosen
|
||||||
|
|
||||||
tcsetattr(fd, TCSANOW, &config);
|
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);
|
tcflush(fd, TCIFLUSH);
|
||||||
// length = read(fd, uintBuf, 24);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!this->stop) {
|
while (!this->stop) {
|
||||||
|
|||||||
Reference in New Issue
Block a user