Revision: 6446
          http://playerstage.svn.sourceforge.net/playerstage/?rev=6446&view=rev
Author:   thjc
Date:     2008-05-17 17:50:10 -0700 (Sat, 17 May 2008)

Log Message:
-----------
changed the way the nav200 driver checks for orphaned data on its incoming queue

Modified Paths:
--------------
    
code/player/branches/release-2-1-patches/server/drivers/position/nav200/nav200.cc

Modified: 
code/player/branches/release-2-1-patches/server/drivers/position/nav200/nav200.cc
===================================================================
--- 
code/player/branches/release-2-1-patches/server/drivers/position/nav200/nav200.cc
   2008-05-16 14:49:50 UTC (rev 6445)
+++ 
code/player/branches/release-2-1-patches/server/drivers/position/nav200/nav200.cc
   2008-05-18 00:50:10 UTC (rev 6446)
@@ -586,13 +586,26 @@
   player_opaque_data_t mData;
   mData.data_count = length;
   mData.data = buffer;
+
+  // before we send a command to the NAV200, flush and data coming in from the 
remote file
+  sn200->InQueue->SetFilter(opaque_id.host, opaque_id.robot, opaque_id.interf, 
opaque_id.index, PLAYER_MSGTYPE_DATA, PLAYER_OPAQUE_DATA_STATE);
   
+  //puts("waiting for data");
+  sn200->ProcessMessages();
+  
   // before we send a command to the NAV200, flush and data coming in from the 
remote file
-  if (!sn200->InQueue->Empty())
+  if (bytesReceived)
   {
-    PLAYER_WARN("Queue was not empty on NAV200, flushing");
-    while (sn200->InQueue->Pop());
+
+    do
+    {
+        PLAYER_WARN1("Buffer was not empty on NAV200 (%d), 
flushing",bytesReceived);
+        bytesReceived = 0;
+       usleep(100000);
+       sn200->ProcessMessages();
+    } while (bytesReceived != 0);
   }
+  sn200->InQueue->ClearFilter();
   
   opaque->PutMsg(sn200->InQueue, PLAYER_MSGTYPE_CMD, PLAYER_OPAQUE_CMD_DATA, 
reinterpret_cast<void*>(&mData), 0, NULL);
   
@@ -729,6 +742,7 @@
     if ((now.tv_sec - start.tv_sec) * 1e6 + now.tv_usec - start.tv_usec > 
timeout_usec)
     {
       fprintf(stderr,"Timed out waiting for packet %d uSecs 
passed\n",static_cast<int>((now.tv_sec - start.tv_sec) * 1e6 + now.tv_usec - 
start.tv_usec));
+      sn200->InQueue->ClearFilter();
       return -1;
     }
     usleep(1000);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to