untested: fix reconnect stm32 if connection is lost
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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<int>(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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user