[kismac] [binaervarianz] r167 - in trunk/Sources: Core Driver/USBIntersilJack

  • From: svn@xxxxxxxxxxxxxxxx
  • To: kismac@xxxxxxxxxxxxx
  • Date: Wed, 23 Aug 2006 04:18:06 +0200

Author: gkruse
Date: 2006-08-23 04:18:02 +0200 (Wed, 23 Aug 2006)
New Revision: 167

Modified:
   trunk/Sources/Core/WaveNet.mm
   trunk/Sources/Driver/USBIntersilJack/USBIntersil.h
   trunk/Sources/Driver/USBIntersilJack/USBIntersil.mm
Log:
Clear the pipe as we should if IOKit reports it is stalled.  Maybe we should 
pay attention to what IOKit is telling us instead of just failing miserably.  
In my tests, this keeps km from hanging about 50% of the time when a stall 
occurs vs 100% previously.  Not much of an improvement but it is one.

Modified: trunk/Sources/Core/WaveNet.mm
===================================================================
--- trunk/Sources/Core/WaveNet.mm       2006-08-22 13:53:32 UTC (rev 166)
+++ trunk/Sources/Core/WaveNet.mm       2006-08-23 02:18:02 UTC (rev 167)
@@ -932,7 +932,7 @@
                                                        
NSAssert(_ivData[body[3]], @"unable to allocate weak container");
                                                }
                         @synchronized (_ivData[body[3]]) {
-                            [_ivData[body[3]] setBytes:&body[4] 
forIV:&body[0]];
+                            [_ivData[body[3]] setBytes:&body[4] 
forIV:&body[0]];//look here!
                         }
                     }
                 }

Modified: trunk/Sources/Driver/USBIntersilJack/USBIntersil.h
===================================================================
--- trunk/Sources/Driver/USBIntersilJack/USBIntersil.h  2006-08-22 13:53:32 UTC 
(rev 166)
+++ trunk/Sources/Driver/USBIntersilJack/USBIntersil.h  2006-08-23 02:18:02 UTC 
(rev 167)
@@ -101,7 +101,7 @@
     CFRunLoopSourceRef         _runLoopSource;
     io_iterator_t              _deviceAddedIter;
     io_iterator_t              _deviceRemovedIter;
-    IOUSBInterfaceInterface**   _interface;
+    IOUSBInterfaceInterface192**   _interface;
     union _usbout               _outputBuffer;
     union _usbin                _inputBuffer;
     union _usbin                _recieveBuffer;

Modified: trunk/Sources/Driver/USBIntersilJack/USBIntersil.mm
===================================================================
--- trunk/Sources/Driver/USBIntersilJack/USBIntersil.mm 2006-08-22 13:53:32 UTC 
(rev 166)
+++ trunk/Sources/Driver/USBIntersilJack/USBIntersil.mm 2006-08-23 02:18:02 UTC 
(rev 167)
@@ -599,7 +599,7 @@
         kr = (*_interface)->WritePipe(_interface, kOutPipe, &_outputBuffer, 
size);
         if (kr != kIOReturnSuccess) {
             if (kr==wlcDeviceGone) _devicePresent = false;
-            else NSLog(@"USBIntersilJack::unable to write to USB 
Device(%08x)\n", kr);
+            NSLog(@"USBIntersilJack::unable to write to USB Device(%08x)\n", 
kr);
             return kr;
         }
 
@@ -629,7 +629,13 @@
             pthread_mutex_unlock(&me->_recv_mutex);
             return;
         } else {
-            NSLog(@"error from async interruptRecieved (%08x)\n", result);
+            if (result == kIOReturnOverrun) {  //for some reason we overran 
the device buffer
+                NSLog(@"USBIntersilJack::Data overrun, attempting to clear the 
pipe stall");
+                result = 
(*me->_interface)->ClearPipeStallBothEnds(me->_interface, kInPipe);  //3 
appears to be the interrupt pipe
+            }
+            else {
+                 NSLog(@"USBIntersilJack::Unhandled error from async interrupt 
recieved, please report on http://trac.kismac.de (%08x)\n", result);
+            }
             if (me->_devicePresent) goto readon;
         }
     }
@@ -707,13 +713,21 @@
     bzero(&me->_recieveBuffer, sizeof(me->_recieveBuffer));
     kr = (*me->_interface)->ReadPipeAsync((me->_interface), kInPipe, 
&me->_recieveBuffer, sizeof(me->_recieveBuffer), 
(IOAsyncCallback1)_interruptRecieved, refCon);
     if (kIOReturnSuccess != kr) {
-        NSLog(@"unable to do async interrupt read (%08x). this means the card 
is stopped!\n", kr);
+        NSLog(@"USBIntersilJack::Unable to do async interrupt read (%08x). The 
card is stopped!\n", kr);
+        if (kr == kIOReturnNoDevice) {
+            NSLog(@"USBIntersilJack::There is no connection to an IOService,");
+            _devicePresent = false;
+        }
+        if (kr == kIOReturnNotOpen) {
+            NSLog(@"USBIntersilJack::Pipe not open for exclusive access.");
+            _devicePresent = false;
+        }
+        //we should never get here because some devices don't like to be 
inited more than once, however this might do something good 
                // I haven't been able to reproduce the error that caused it to 
hit this point in the code again since adding the following lines
                // however, when it hit this point previously, the only 
solution was to kill and relaunch KisMAC, so at least this won't make anything 
worse
                NSLog(@"Attempting to re-initialise adapter...");
                if (me->_init() != kIOReturnSuccess) 
NSLog(@"USBIntersilJack::_interruptReceived: _init() failed\n");
     }
-        
 }
 
 #pragma mark -
@@ -748,7 +762,7 @@
     io_iterator_t              iterator;
     io_service_t               usbInterface;
     IOCFPlugInInterface        **plugInInterface = NULL;
-    IOUSBInterfaceInterface    **intf = NULL;
+    IOUSBInterfaceInterface192         **intf = NULL;
     HRESULT                    res;
     SInt32                     score;
     UInt8                      intfClass;


Other related posts:

  • » [kismac] [binaervarianz] r167 - in trunk/Sources: Core Driver/USBIntersilJack