X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Farducontrol.cpp;h=86b3666b2ff13a478ed8a391fe3c2d916b04188d;hb=df99c7e41d87084fe7f71729f3df33d7effc59cc;hp=7f95b631aa119bd77e7698d48c52b94fedd7bb23;hpb=b4beace6f1d3e018dbe1495430d32f828d406229;p=r2c2.git diff --git a/source/libr2c2/arducontrol.cpp b/source/libr2c2/arducontrol.cpp index 7f95b63..86b3666 100644 --- a/source/libr2c2/arducontrol.cpp +++ b/source/libr2c2/arducontrol.cpp @@ -1025,10 +1025,41 @@ void ArduControl::ControlThread::main() if(get_work(cmd)) { bool success = true; + bool resync = false; for(unsigned i=0; (success && i=1) + IO::print("Synchronization with ArduControl lost, attempting to recover\n"); + for(unsigned i=0; (resync && i<16); ++i) + { + control.serial.put('\xFF'); + while(IO::poll(control.serial, IO::P_INPUT, control.command_timeout)) + resync = (control.serial.get()!=0xFF); + } + if(resync) + { + if(control.debug>=1) + IO::print("Resynchronization failed, giving up\n"); + done = true; + } + else + { + if(control.debug>=1) + IO::print("Resynchronization successful\n"); + if(cmd.tag) + control.command_queue.push(cmd); + } + } } else Time::sleep(10*Time::msec);