|
From: <bo...@us...> - 2008-03-06 07:13:23
|
Revision: 98
http://gearbox.svn.sourceforge.net/gearbox/?rev=98&view=rev
Author: borax00
Date: 2008-03-05 23:13:26 -0800 (Wed, 05 Mar 2008)
Log Message:
-----------
tried to make connection while continuous mode is on more reliable.
Modified Paths:
--------------
gearbox/trunk/submitted/gbxsickacfr/driver.cpp
Modified: gearbox/trunk/submitted/gbxsickacfr/driver.cpp
===================================================================
--- gearbox/trunk/submitted/gbxsickacfr/driver.cpp 2008-03-06 07:03:36 UTC (rev 97)
+++ gearbox/trunk/submitted/gbxsickacfr/driver.cpp 2008-03-06 07:13:26 UTC (rev 98)
@@ -408,8 +408,26 @@
// Turn continuous mode off
//
tracer_.debug("Driver: Turning continuous mode off");
- constructRequestMeasuredOnRequestMode( commandAndData_ );
- sendAndExpectResponse( commandAndData_ );
+ // For some reason this isn't always reliable, not too sure why.
+ // Perhaps there's some crap left in the buffer after the thing
+ // was previously in continuous mode?
+ const int MAX_TRIES=3;
+ for ( uint i=0; i < MAX_TRIES; i++ )
+ {
+ try {
+ constructRequestMeasuredOnRequestMode( commandAndData_ );
+ sendAndExpectResponse( commandAndData_ );
+ break;
+ }
+ catch ( NoResponseException &e )
+ {
+ if ( i == MAX_TRIES-1 )
+ {
+ // Give up
+ throw;
+ }
+ }
+ }
//
// Set Desired BaudRate
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|