Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Spontaneous death/resurrection of USB ports?



Hello,


Am 23.06.2006 um 15:09 schrieb Dan Smith:

The applications code calls IOKit at application level; no kernel code is used.
(...)
About once or twice a week, the USB port I am using will appear to die. The IORegistryExplorer no longer "sees" our device, and it no longer "sees" other devices plugged into that port. Powering down everything, waiting a few minutes, and powering everything up appears to restore normal operation.
(...)
Has anyone experienced anything like this? Does anyone know of softwares sins (or USB protocol sins) that would cause OS X to decide to quit paying attention to a USB port, or something like that?

I was able to verify that my Macs' USB port stops working when running Apple's USB SimpleExample sample code in a loop. So I second your guess that it is a software issue.


You might want to verify using attached slightly modified USBSimpleExample's main() function with a bulk USB device of your choice connected to your Mac.
Just adjust vendorID/productID appropriately, then call the tool from the command line and let it do its device arbitrition work a couple of thousand times. On my PB G4 17" 1.67 GHz (Mac OS X 10.4.6) it took ~10k loops to make the USB port my bulk device is connected to stop working (also, the USBSimpleExample application cannot be killed and hangs around until reboot).


Some months ago (running Panther iirc), I verified this behaviour on a Dual-G4 867 MHz, an iBook G3 600 MHz and a PM G5 1.6GHz.


Best regards, Dirk Stegemann

P.S.: Or just download the modified test project:

<http://www.macinsight.de/Downloads/The_Jinx/USBSimple_Example_ (modified).zip>



-----snip-----

int main (int argc, const char * argv[])
{
int i, loopCount = (argc > 1) ? atoi(argv[1]) : 10000; / *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
}

IOObjectRelease(iterator);
iterator = 0;

mach_port_deallocate(mach_task_self(), masterPort);
} /*MODIFICATION*/
return 0;
}



-----snip-----

_______________________________________________
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

This email sent to email@hidden
References: 
 >Spontaneous death/resurrection of USB ports? (From: "Dan Smith" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.