Author: remi
Date: 2008-06-26 11:02:41 +0200 (Thu, 26 Jun 2008)
New Revision: 1269

Modified:
   software_suite_v2/middleware/tuxdriver/trunk/src/tux_hid_unix.c
   software_suite_v2/middleware/tuxdriver/trunk/src/tux_usb.c
Log:
* updated the usb hid connection in order to intercept the disconnections of 
the dongle.

Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_hid_unix.c
===================================================================
--- software_suite_v2/middleware/tuxdriver/trunk/src/tux_hid_unix.c     
2008-06-25 14:51:57 UTC (rev 1268)
+++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_hid_unix.c     
2008-06-26 09:02:41 UTC (rev 1269)
@@ -86,7 +86,31 @@
 
     return false;
 }
+
+static bool
+check_device_still_plugged(void)
+{
+    FILE *fp;
     
+    if (tux_device_hdl == -1)
+    {
+        return false;
+    }
+    else
+    {
+        fp = fopen(tux_device_path, "r");
+        if (fp)
+        {
+            fclose(fp);
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+}
+    
 bool LIBLOCAL
 tux_hid_capture(int vendor_id, int product_id)
 {
@@ -122,6 +146,11 @@
     int i;
     int err;
     
+    if (!check_device_still_plugged())
+    {
+        return false;
+    }
+    
     rinfo_out.report_type = HID_REPORT_TYPE_OUTPUT;
     rinfo_out.report_id = HID_REPORT_ID_FIRST;
     
@@ -160,6 +189,11 @@
     int i;
     int err;
     
+    if (!check_device_still_plugged())
+    {
+        return false;
+    }
+    
     rinfo_out.report_type = HID_REPORT_TYPE_INPUT;
     rinfo_out.report_id = HID_REPORT_ID_FIRST;
     

Modified: software_suite_v2/middleware/tuxdriver/trunk/src/tux_usb.c
===================================================================
--- software_suite_v2/middleware/tuxdriver/trunk/src/tux_usb.c  2008-06-25 
14:51:57 UTC (rev 1268)
+++ software_suite_v2/middleware/tuxdriver/trunk/src/tux_usb.c  2008-06-26 
09:02:41 UTC (rev 1269)
@@ -328,7 +328,7 @@
     if ((packet_count == 0) && (rf_state == 1))
     {
         read_error_counter++;
-        log_warning("Read errors count : %d\n", read_error_counter);
+        log_warning("Read errors count : %d", read_error_counter);
         if (read_error_counter >= TUX_USB_ERROR_LIMIT)
         {
             /* Reset of the RF */
@@ -479,6 +479,8 @@
     
     set_read_loop_started(true);
     
+    log_info("Start the statuses read loop");
+    
     while (tux_usb_connected())
     {
         current_timeout += TUX_READ_LOOP_INTERVAL;
@@ -502,6 +504,8 @@
     }
     
     set_read_loop_started(false);
+    
+    log_info("Statuses read loop stopped");
 }
 
 /**


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to