[sane-devel] Setting up a Control message

gmurray at cloudnet.com gmurray at cloudnet.com
Wed Feb 14 07:45:56 CET 2007

Quoting René Kjellerup <webmaster at keenan.dk>:

> I've found out that the communication to the CanoScan 4200F scanner
> most likely happens through control messages. And I've tried to set up

The scanner is a USB-2.0 device.  In the genesys backend, Lide35 scanner made
extensive use of bulk urbs, with much less done in control messages.
I would expect the 4200F to be rather similar.

> my program to emulate this, but with my limited knowledge of how USB
> communication works. 
> I'd like to how to set up a control msg. But what are requestType / 
> request / index / value parameters to usb_control_msg() used for?

The fields are shown in libusb package, header usb.h
Some of the fields are also defined in sane-backends sanei/sanei_usb.h

see struct usb_ctrl_setup in usb.h
bRequestType is a bitfield:
bit 7 : direction of the request, 0: host to device 1: device to host
  a device receiving the 1 bit is expected to get the information and
  return a usb request to the host.
bit 6..5 class code: USB_TYPE_STANDARD USB_TYPE_CLASS see usb.h
bit 4..0 recipient of the usb request. (only 4 values are assigned:
  0: device, 1:interface 2:endpoint 3:other (all others reserved)

bRequest field has meanings assigned by the usb standard when that
is USB_TYPE_STANDARD bRequestType.  These are defined in usb.h as well as
sanei_usb.h  "Standard requests"

Some canon scanners use USB_TYPE_VENDOR class, and Canon defines the
meaning of the fields, bRequest, wValue, wIndex.

> And where in a usbsniffer.log would they likely be noted?

The fields are obvious in a usbsnoop.log.  This is taken from usbsnoop.log:

[347 ms]  >>>  URB 9 going down  >>>
  TransferFlags          = 00000000 (USBD_TRANSFER_DIRECTION_OUT,
  TransferBufferLength = 00000008
  TransferBuffer       = 85727830
  TransferBufferMDL    = 00000000
    00000000: 01 11 00 00 96 00 00 00
  UrbLink                 = 00000000
  RequestTypeReservedBits = 00000040
  Request                 = 00000004
  Value                   = 00000082
  Index                   = 00000000
[350 ms] UsbSnoop - MyInternalIOCTLCompletion(f7b2cdb0) : fido=00000000,
Irp=84fe46c0, Context=851848a8, IRQL=2
[350 ms]  <<<  URB 9 coming back  <<<

See RequestTypeReservedBits = 0x40 or USB_TYPE_VENDOR

I  took a quick look at Canon-4200f.html on the sane site, and it was not clear
to me what controller chip is being used.  It apparently is not genesys, or
would have been noted.   Does anyone know which it is?

There is a lot of work ahead.  Good luck.

best regards,

> High hopes
> René Kjellerup
> -- 

More information about the sane-devel mailing list