I am writing USB bulk device driver using IOKit framework.
(...)
My user application communicates with my framework which in turns
communicates with the device and returns back the required data.
The framework works fine most of the time, but "HANGS unexpectedly"
at times when I communicates very frequently with my USB device.
Your problem might be related to the one I encountered already 4
years ago.
I wrote to the list on 02.02.2002 / 20:50 and 23.11.2002 / 18:34 (see
posting below, with a description to reproduce the problem).
I didn't verify right now, but the last time I did (must have been
around Panther) surprisingly this was still valid :-/
I admit I never filed a bug report, I thought this issue to be so
serious it must've been on Apple's task list already.
But I'll verify and report back whether I can still reproduce it on
my systems.
Best regards,
Dirk Stegemann
-----snip-----
I'm seeing a serious problem when querying the USB-system
repeatedly to get information about a vendor-specific bulk-device:
suddenly, the bus the queried device belongs to seems to be dead,
no changes in the device's bus topology gets recognized, the
accessing program hangs, I've got to restart the computer to get
back to a normally working behavior.
I'm running Mac OS X 10.2.2 (although I first encountered this
problem with 10.1, see my original post from 2/2/2002) on a
G4-2x500 and on a recently bought iBook-800; on the iBook the
symptoms are even more drastic, there I got a kernel panic.
These issue seems to be independent from the device in question; I
encountered it with the vendor-specific device I wrote a userland-
driver for, but also with a Canon S400 I'm using at home (I'll try
to test with more bulk-devices, if I can get some).
Though, I'm not really wondering about that, because no data (only
the configuration requests) is to be transferred to the device.
So I write to the list to ask if you can verify these behaviour for
other machines/OS-versions/devices, and to know if this is a known
issue and/or somebody (maybe from Apple?) can tell more about it.
I'm using Apple's "USBSimpleExample", adding a few lines of code to
the "main" function (see below) to make the recognizing/accessing
process run in a loop.
You've got to change the vendorID/productID; running the tool from
the commandline, you can specify an argument which will be taken as
loopCount. Sometimes it takes several hundreds of iterations to
break down the USB-System, sometimes it takes less than 20 loops to
crash the system, and the results are more difficult to reproduce
when "running" directly from ProjectBuilder.
I guess it's kind of timing-issue; when adding a "sleep(1)"
somewhere into the loop it generally takes more iterations to bring
down the USB...
The origianl code can be found on your drive:
<file:///Developer/Examples/IOKit/usb/USBSimple Example/
USBSimpleExample.pbproj>
The modified main() function looks like this:
int main (int argc, const char * argv[])
{
int i, loopCount = (argc > 1) ? atoi(argv[1]) : 1; /
*MODIFICATION*/
for (i = 1; i <= loopCount; i++){ /*MODIFICATION*/
kern_return_t err;
CFMutableDictionaryRef matchingDictionary = 0; // requires
<IOKit/IOKitLib.h>
SInt32 idVendor = 0x04A9; // Canon /*MODIFICATION*/
SInt32 idProduct = 0x105C; // S400 /*MODIFICATION*/
CFNumberRef numberRef;
io_iterator_t iterator = 0;
io_service_t usbDeviceRef;
printf("\nLOOP # %d of %d\n", i, loopCount); /*MODIFICATION*/
err = IOMasterPort(MACH_PORT_NULL, &masterPort);
if (err)
{
printf("USBSimpleExample: could not create master port, err = %
08x\n", err);
return err;
}
matchingDictionary = IOServiceMatching(kIOUSBDeviceClassName); //
requires <IOKit/usb/IOUSBLib.h>
if (!matchingDictionary)
{
printf("USBSimpleExample: could not create matching dictionary\n");
return -1;
}
numberRef = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type, &idVendor);
if (!numberRef)
{
printf("USBSimpleExample: could not create CFNumberRef for vendor
\n");
return -1;
}
CFDictionaryAddValue(matchingDictionary, CFSTR(kUSBVendorID),
numberRef);
CFRelease(numberRef);
numberRef = 0;
numberRef = CFNumberCreate(kCFAllocatorDefault,
kCFNumberSInt32Type, &idProduct);
if (!numberRef)
{
printf("USBSimpleExample: could not create CFNumberRef for
product\n");
return -1;
}
CFDictionaryAddValue(matchingDictionary, CFSTR(kUSBProductID),
numberRef);
CFRelease(numberRef);
numberRef = 0;
err = IOServiceGetMatchingServices(masterPort,
matchingDictionary, &iterator);
matchingDictionary = 0; // this was consumed by the above call
while ( (usbDeviceRef = IOIteratorNext(iterator)) )
{
printf("Found device %p\n", (void*)usbDeviceRef);
dealWithDevice(usbDeviceRef);
IOObjectRelease(usbDeviceRef); // no longer need this reference
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden