diff --git a/src/C++/Driver/src/main.cpp b/src/C++/Driver/src/main.cpp index 6d2c67e..712deb2 100644 --- a/src/C++/Driver/src/main.cpp +++ b/src/C++/Driver/src/main.cpp @@ -20,7 +20,8 @@ void sendKobukiData(TKobukiData &data); void setup() { unsigned char *null_ptr(0); std::cout << "Attempting to start communication with Kobuki..." << std::endl; - if (!robot.startCommunication("/dev/ttyUSB0", true, null_ptr)) { + robot.startCommunication("/dev/ttyUSB0", true, null_ptr); + if (!robot.isConnected()) { std::cerr << "Failed to start communication with Kobuki." << std::endl; } else { std::cout << "Successfully started communication with Kobuki." << std::endl; @@ -41,9 +42,7 @@ int main() { while (true) { if (!robot.isConnected()) { std::cout << "Kobuki is not connected anymore. Reconnecting..." << std::endl; - if (!robot.startCommunication("/dev/ttyUSB0", true, nullptr)) { - std::cerr << "Failed to reconnect to Kobuki." << std::endl; - } + robot.startCommunication("/dev/ttyUSB0", true, nullptr); while (!robot.isConnected()) { std::cout << "Attempting to reconnect..." << std::endl; std::this_thread::sleep_for(std::chrono::seconds(1));