diff --git a/CMakeLists.txt b/CMakeLists.txt index ae2cd52..ca722b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,10 +48,10 @@ set(CMAKE_PREFIX_PATH usr) find_library(LIBUSB_LIBRARY NAMES + "libusb-1.0.so" "usb" "libusb" "libusb-1.0" - "libusb-1.0.so" PATH_SUFFIXES "lib" "lib32" diff --git a/hardwaresetup.cpp b/hardwaresetup.cpp index f7d6a07..123f1c9 100644 --- a/hardwaresetup.cpp +++ b/hardwaresetup.cpp @@ -285,6 +285,8 @@ void HardwareSetup::run() { usleep(50000); // 150ms if (received->begin == '#' && received->end == '!') { + // flash data + tcflush(fd, TCIFLUSH); for (int i = 0; i < 6; i++) { cout << "i: " << i << " time: " << static_cast(received->data[i].time) @@ -341,6 +343,11 @@ void HardwareSetup::run() { else { // dataframe not ok tcflush(fd, TCIFLUSH); + cout << "reconnect controller" << endl; + this->connectSTM32(); + } + if (fd < 0) { + // connection lost this->connectSTM32(); }