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?



Hi Tomas,

>>What I haven't figured out is, how do you pass function pointers
>>in the driver out to an application?
>
>Mac OS 9 drivers are CFM Fragments. Apps use USBGetNextDeviceByClass
>(USB.h) to find the proper device and get USBDeviceRef and your code
>fragment connection id. They then use FindSymbol API
>(CodeFragments.h) to get TheUSBDriverDescription (you're required to
>export this symbol) and TheUSBClassDriverPluginDispatchTable (you're
>required to export this as well).
>

Thanks!  I put my own dispatch table in the driver, added its name to
the USBClassDriver.exp file in the project, and USBGetNextDeviceByClass()
and FindSymbol() enabled me to call a driver function from an application.
There were a few glitches,
1)  The examples in the DDK documentation incorrectly had only four
     arguments supplied to USBGetNextDeviceByClass(), and
2)  I had to use the wildcards kUSBAnyClass and kUSBAnySubClass
     (a.k.a FFFF) to get my device to appear, the vendor-specific selectors
     wouldn't work.

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
_______________________________________________
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: Tomas Zahradnicky <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.