Update of /cvsroot/playerstage/code/player/server/drivers/opaque
In directory 
sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32449/server/drivers/opaque

Modified Files:
        tcpstream.cc 
Log Message:
patch to support reconnection to hardware
adds a fetch mode to upload reflectors from a vectormap
fixes to speed calculations (may not be perfect yet)

Index: tcpstream.cc
===================================================================
RCS file: /cvsroot/playerstage/code/player/server/drivers/opaque/tcpstream.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** tcpstream.cc        18 Dec 2007 05:05:08 -0000      1.1
--- tcpstream.cc        19 Feb 2008 19:06:27 -0000      1.2
***************
*** 183,186 ****
--- 183,188 ----
      IntProperty port;
      
+     bool connected;
+     
      // This is the data we store and send
      player_opaque_data_t mData;
***************
*** 225,228 ****
--- 227,232 ----
        assert(rx_buffer);
        
+       connected = false;
+       
        return;
  }
***************
*** 241,247 ****
        // Open the terminal
        if (OpenTerm())
!           return -1;
! 
!       PLAYER_MSG0(2, "TCP Opaque Driver ready");
  
    // Start the device thread; spawns a new thread and executes
--- 245,251 ----
        // Open the terminal
        if (OpenTerm())
!           PLAYER_ERROR("Failed to connect to socket");
!       else
!               PLAYER_MSG0(2, "TCP Opaque Driver ready");
  
    // Start the device thread; spawns a new thread and executes
***************
*** 275,278 ****
--- 279,288 ----
        // return -1, and a NACK will be sent for you, if a response is 
required.
        
+       if (!connected)
+       {
+               PLAYER_MSG0(2, "TCP reconnecting");
+               OpenTerm();
+       }
+       
        if (Message::MatchMessage (hdr, PLAYER_MSGTYPE_CMD, 
PLAYER_OPAQUE_CMD_DATA, this->device_addr))
        {
***************
*** 287,291 ****
--- 297,305 ----
                } while (result < 0 && errno == EAGAIN);
                if (result < (int)recv->data_count)
+               {
                        PLAYER_ERROR2("Error sending data (%d, %s)", errno, 
strerror(errno));
+                       // Attempt to reconnect.
+                       CloseTerm();
+               }
            }
            
***************
*** 312,317 ****
      ProcessMessages();
  
!     // Reads the data from the serial port and then publishes it
!     ReadData();
  
      // Sleep (you might, for example, block on a read() instead)
--- 326,339 ----
      ProcessMessages();
  
!     if (connected)
!     {
!       // Reads the data from the serial port and then publishes it
!       ReadData();
!     }
!     else
!     {
!       PLAYER_MSG0(2, "TCP reconnecting");
!       OpenTerm();
!     }
  
      // Sleep (you might, for example, block on a read() instead)
***************
*** 343,346 ****
--- 365,370 ----
        PLAYER_MSG0(2, "TCP Opaque Driver connected");
    
+       connected = true;
+       
    return 0;
  }
***************
*** 353,356 ****
--- 377,381 ----
  {
    close(sock);
+   connected = false;
    return 0;
  }
***************
*** 364,368 ****
    //
    int len = recv(sock, rx_buffer, buffer_size, 0);
!   if (len == 0 || (len < 0 && errno == EAGAIN))
    {
       // PLAYER_MSG0(2, "empty packet");
--- 389,393 ----
    //
    int len = recv(sock, rx_buffer, buffer_size, 0);
!   if (len < 0 && errno == EAGAIN)
    {
       // PLAYER_MSG0(2, "empty packet");
***************
*** 370,376 ****
    }
  
!   if (len < 0)
    {
      PLAYER_ERROR2("error reading from socket: %d %s", errno, strerror(errno));
      return;
    }
--- 395,402 ----
    }
  
!   if (len <= 0)
    {
      PLAYER_ERROR2("error reading from socket: %d %s", errno, strerror(errno));
+     CloseTerm();
      return;
    }


-------------------------------------------------------------------------
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