untested: fix reconnect stm32 if connection is lost

This commit is contained in:
2018-12-30 22:41:10 +01:00
parent 2ae9c45216
commit bc27278ffb
2 changed files with 8 additions and 1 deletions

View File

@@ -48,10 +48,10 @@ set(CMAKE_PREFIX_PATH usr)
find_library(LIBUSB_LIBRARY find_library(LIBUSB_LIBRARY
NAMES NAMES
"libusb-1.0.so"
"usb" "usb"
"libusb" "libusb"
"libusb-1.0" "libusb-1.0"
"libusb-1.0.so"
PATH_SUFFIXES PATH_SUFFIXES
"lib" "lib"
"lib32" "lib32"

View File

@@ -285,6 +285,8 @@ void HardwareSetup::run() {
usleep(50000); // 150ms usleep(50000); // 150ms
if (received->begin == '#' && received->end == '!') { if (received->begin == '#' && received->end == '!') {
// flash data
tcflush(fd, TCIFLUSH);
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
cout << "i: " << i << " time: " cout << "i: " << i << " time: "
<< static_cast<int>(received->data[i].time) << static_cast<int>(received->data[i].time)
@@ -341,6 +343,11 @@ void HardwareSetup::run() {
else { else {
// dataframe not ok // dataframe not ok
tcflush(fd, TCIFLUSH); tcflush(fd, TCIFLUSH);
cout << "reconnect controller" << endl;
this->connectSTM32();
}
if (fd < 0) {
// connection lost
this->connectSTM32(); this->connectSTM32();
} }