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: USB driver for a simple device?



The extra argument in USBGetNextDeviceByClass() is a pointer to the
USBDeviceRef, which correctly gets filled in when my device gets plugged in.
This got me thinking, why can't I just pass this out and call
USBDeviceRequest() from the application?  This would save a reboot
cycle every time the code gets changed.  There's probably some trouble
I can get into, I'll find out soon enough, but I'd appreciate any advice.

rob

Rob,
technically, you can do what you've proposed however, however, it's a bad idea. Things might work initially, but as things get more complex, debugging the application and driver would be much more difficult.


For example, the hot disconnect case would be problematic. Normally, the driver is informed of the device going away, and has a chance to abort all current device requests, as well as other housekeeping before the driver disappears. If your application makes the device request (which is async) and the device goes away, the driver will not know of the active request from the application. It will only clean up what calls it is aware of and when it returns to the system, the system may dispose of the driver. This would crash your system when the application's request completes a bit later. It's best to keep the usage of the deviceRef within the driver.

The only reason for a reboot is if a shim is involved. Shims can only be loaded at system start. If you don't have a shim involved, or the shim code doesn't get modified, you should be able to unplug the device, install an updated driver, then reconnect the device and the new driver code will be used. If you cannot replace the driver, then it means that the driver is trying to clean up after itself, but cannot do so for some reason.
--
Sincerely,
Rich Kubota
email@hidden
(408) 974-6212
_______________________________________________
usb mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/usb
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: USB driver for a simple device? (From: rob shaw <email@hidden>)
 >Re: USB driver for a simple device? (From: "Daniel R. Killoran,Ph.D." <email@hidden>)
 >Re: USB driver for a simple device? (From: Barry Twycross <email@hidden>)
 >USB driver for a simple device? (From: rob shaw <email@hidden>)
 >Re: USB driver for a simple device? (From: rob shaw <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.