[sane-devel] USB speed

Henning Meier-Geinitz henning at meier-geinitz.de
Tue May 9 16:59:44 UTC 2006


Hi,

On 2006-05-06 18:50, Pierre Willenbrock wrote:
> i am trying to make the scanning speed of my scanner depend on the usb
> speed available. I first attempted to use the detection from the cs3200f
> backend, but found that it only detects if the device is high speed
> capable, not if it is currently communicating with high speed.

Wouldn't it be better to actually measure speed? E.g. by scanning some
data at maximum scanner speed without moving the motor? Obviously this
may not be possible with all scanner chipsets.

> On further investigation i found that there are two ways to determine
> the used speed on linux:
> * The first one involves an ioctl, which needs an file descriptor of the
> device. I cannot see any way to get the fd from libusb.

IIRC it is possible but ugly and may break with newer libusb versions.
SOmething like declaring an internal libusb structure in your own code
and using that to access internal variables.

> * The second one is looking at /proc/bus/usb/devices, parsing the
> T-lines. This only needs the device number and the bus number, which can
> be obtained from libusb.
> 
> The attached patch adds a function to sanei_usb which adds a function
> determining the usb speed. Currently, it only reports speeds when using
> libusb on Linux. I tested this on Linux 2.6.16.
>
> Any objections to this approach?

I'm not sure if the format libusb device names/numbers are guaranteed
to remain unchanged. E.g. it's different for other operating systems.

You seem to imply that there will be a solution within libusb? If this
is true, I'd prefer to use that one, once it's available.

Is the determination of USB speed also needed/useful for other backends?

Bye,
  Henning



More information about the sane-devel mailing list