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 Rob,

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).


You can, however, export other symbols, but it's annoying to call FindSymbol 10 times and make function pointer for everything. The better approach would be to make your own version of the DispatchTable which is "longer" than the required one and has more callbacks or do everything through device control function (from the look of the app). In the former case you export some kind of global variable (a structure pointer). Application gets this structure pointer (dispatch_table) and then uses dispatch_table->functionpointer(parameters); That's they way it calls into your driver.

 I'd like to have a function like
Move(pan,tilt) in the driver, that I can call from an application, once
the driver has done the initialization work.  As was mentioned, the DDK
documentation was written for someone who knows what he's doing,
that's not me, yet.

I've had the same felling about the docs.

 The example I've most studied, the USBKeypad
example, hangs around in an interrupt loop, talking to internal ADB
structures, and doesn't talk to outside applications.  Do I have to call
USBGetNextDeviceByClass() etc. from the application?

Sure. That's how app finds your device. The better would be to look at HIDReader. You'll find out how it works.



-Tomas -- Ing. Tomas Zahradnicky, Jr. Production Manager, 24U Software Associate Member, Filemaker Solutions Alliance mailto:email@hidden http://www.24uSoftware.com _______________________________________________ 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: "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.