I think your previous idea of adding a a new function to set the currently 'active' endpoint would be simpler. something like:
/*endpoint types*/ #define SANEI_USB_BULK_OUT 0 #define SANEI_USB_BULK_IN 1 ... sanei_usb_set_endpoint(SANE_Int dn, SANE_Int endpoint_type, SANE_Int endpoint_number){ switch/case setting devices[devcount].xxxx } Then you've only got one new function, and no other code changes? allan On Tue, Jan 4, 2011 at 4:01 PM, Reinhold Kainhofer <reinhold at kainhofer.com> wrote: > Am Samstag, 27. November 2010, um 00:10:54 schrieb m. allan noah: >> Reinhold Kainhofer has recently worked up a patch with an alternative >> implementation of your idea- and there was some discussion about yet a >> third mechanism, which relies on a 'setting' function to be called >> prior to transferring the data, much as the existing timeout control >> code works. I think that would be the best choice, not sure if >> Reinhold has gotten a chance to work on it. > > I have now updated my patch to also include a callback function to > sanei_usb_open_extended, which is called before all available endpoints are > listed. > Patch is here: > http://codereview.appspot.com/2823041/ > > The callback function (if given) is called for each combination of > USB_DIR_IN/USB_DIR_OUT and > USB_ENDPOINT_TYPE_CONTROL/USB_ENDPOINT_TYPE_ISOCHRONOUS/USB_ENDPOINT_TYPE_BULK/USB_ENDPOINT_TYPE_INTERRUPT. > If a value >0 is returned, it is used as the default endpoint of that type > (instead of the first encountered endpoint of that type). > > The old functionality of an additional argument to each usb read/write > function to explicitly override the endpoint for a single transaction is still > there, so one can now override the default used for all transfers as well as > the endpoint for a single transfer. > > Any comments? Of course, I would love to get this into the 1.0.22 release, so > other backends that need different endpoints for different communication types > finally have this functionality available. > > Cheers, > Reinhold > -- > ------------------------------------------------------------------ > Reinhold Kainhofer, reinhold at kainhofer.com, http://reinhold.kainhofer.com/ > ?* Financial & Actuarial Math., Vienna Univ. of Technology, Austria > ?* http://www.fam.tuwien.ac.at/, DVR: 0005886 > ?* LilyPond, Music typesetting, http://www.lilypond.org > -- "The truth is an offense, but not a sin"