[sane-devel] Tips on migrating an existing driver to use libusb?

Henning Meier-Geinitz henning@meier-geinitz.de
Thu, 26 Jun 2003 23:56:39 +0200


Hi,

On Thu, Jun 26, 2003 at 02:10:26PM -0700, Steven Ellis wrote:
> Are there any useful tips or an FAQ on migrating a
> scanner driver over to use libusb. It would be nice to
> get the viceo (http://viceo.orcon.net.nz) driver to
> work without using a special patch for scanner.c/h and
> a recompile of the modules.

I don't have a howto but the sanei_usb API is pretty simple and
explained here: http://sanei.meier-geinitz.de/sanei__usb_8h.html

The assumptions are: 

- not more than one endpoint of each type: bulk-in, bulk-out, interrupt
- interrupt endpoint access works only with libusb

1) sanei_usb_init
2a) call sanei_usb_attach_matching_devices with the "usb" lined from
   your config file or
2b) call sanei_usb_find_devices for any of the scanners you support
3) sanei_usb_open the device that was selected by the user
4) call sanei_usb_read_bulk, write_bulk or control_msg as you need
5) sanei_usb_close

Bye,
  Henning