]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/arducontrol.cpp
Terminate the control thread if ArduControl device is not found
[r2c2.git] / source / libr2c2 / arducontrol.cpp
index 47584f44bb8b145496a0b6d9a52c118f4c68fcd9..921526341b1c320de0928c847a88cbb7ff154343 100644 (file)
@@ -940,6 +940,12 @@ void ArduControl::ControlThread::init_baud_rate()
                }
        }
 
+       if(!rate)
+       {
+               done = true;
+               return;
+       }
+
        if(control.debug>=1)
                IO::print("ArduControl detected at %d bits/s\n", rate);
 
@@ -953,9 +959,9 @@ void ArduControl::ControlThread::init_baud_rate()
                if(do_command(cmd)==COMMAND_OK)
                {
                        control.serial.set_baud_rate(rates[0]);
+                       Time::sleep(Time::sec);
                        if(do_command(cmd)==COMMAND_OK)
                        {
-                               Time::sleep(Time::sec);
                                if(control.debug>=1)
                                        IO::print("Rate changed to %d bits/s\n", rates[0]);
                        }