[sane-devel] platform independent sanei_usb control messages

Henning Meier-Geinitz henning@meier-geinitz.de
Sun, 30 Jun 2002 18:28:00 +0200


Hi,

On Sun, Jun 30, 2002 at 03:36:35PM +0200, Bertrik Sikken wrote:
> I'm working on a backend for scanners based on the 'niash' chipset, 
> found in scanners like
> the HP3300, HP3400, HP4300, (HP5400?) and the Agfa Snapscan Touch.
> 
> Until now I've used libusb to provide platform independent USB access 
> which works
> mostly fine. I know there's also the sanei_usb functions, but I have 
> some issues using them.

I'm currently working on making sanei_usb more generic. That means,
sanei_usb should also be able to use libusb, not only the
"Linux-kernel-method" (which works with the BSDs, also).
It's not yet finished and there may be problems but I think I will add
a first version to CVS during the next few days.
The idea is that no changes in the backends are necessary.

> When I do a control transfer I need to pass some parameters involving 
> (for example)
> USB_TYPE_VENDOR, USB_RECIP_DEVICE and USB_DIR_IN which
> are defined in linux/usb.h, obviously not platform independent.

Yes, usually it's better to copy the needed constants.

> I see that the canon630u backend solved this by defining those symbols 
> locally.
> 
> I suspect that the symbols mentioned above are really part of the USB 
> specification,

I thinks o, but I will have a closer look when implementing
sanei_usb_control_msg for libusb.

> so they are not platform specific. Maybe it's a good idea to add them to 
> sanei_usb.h?

Yes. Proposals for what to include are welcome :-)

> What is actually the preferred USB access method for SANE?

Depends on who you ask. My personal opinion is: kernel access via
scanner module. Most sane backends currently use sanei_usb or direct
access to /dev/usb/scanner*.

> And for what reasons?

libusb:
  + is portable for different platforms (OS X?)
  + automatic detection of scanners is easier
  - need to be root to access devices
  - no way to scan for scanners in sane-find-scanner
  
kernel module:
  the other way round :-)
  
That's why I try to include libusb access in sanei_usb to get best of
both worlds. Maybe other (proprietary) access methods (e.g. for
Solaris?) can be added too, once the file is more generic.

Bye,
  Henning