[sane-devel] Interested in writing a driver for...

m. allan noah anoah at pfeiffer.edu
Tue Apr 13 17:48:33 BST 2004


search the archives of this mailing list. this topic gets discussed quite 
a bit. basically, you install a usb packet sniffer on windows machine, and 
do some string of simple operations in the windows software, like:

1. plug and un-plug device

2. plug device and take the smallest, lowest quality pic you can

3. plug device and change some setting in windows software, and take 
another pic, then another setting, another pic, etc.

then, copy the resulting sniffer log to your linux/unix box, and shred it 
for readability. (if using benoit's usbsnooper, (which i recommend) the 
attached script i wrote works well)

then, stare at the data, and see what patterns you can recognize.

then, write a small c program that uses libusb to send packets to the 
device in linux, one packet at a time, and see what happens.

if you dont burn the device up in the process :) you will end up with 
enough understanding of how it communicates to then look at writing a sane 
backend.

allan

On Mon, 12 Apr 2004, Greg Apessos wrote:

> my Ezonics EZCam USB III webcam.  What got me interested was finding a
> reference to the EZCam USB II not being supported on the sane-project's
> site, http://www.sane-project.org/unsupported/biolux-654.html.  While
> it isn't a scanner, maybe my work could be useful to someone else.  But
> the difficulty is I don't know how to approach the problem.
> 
> >From the little bits that I've gleamed, I monitor the communication with
> the camera on Windows, and get an idea of how messages are sent to it.
> >From that I start to build something useful.
> 
> Are there guides, tutorials, something that could be helpful?  I don't
> necessarily need step-by-step instructions, just an outline like, program
> X will capture the communication with the camera, library Y can be used to
> communicate with the webcam under Linux, etc.
> 
> Any help in the right direction would be great.
> 
> -Greg
> 
> 

-- 
"so don't tell us it can't be done, putting down what you don't know.
money isn't our god, integrity will free our souls" - Max Cavalera
-------------- next part --------------
#! /usr/bin/perl

# simple log reformatter for benoit's sniffusb.exe
# public domain. by anoah at pfeiffer.edu

use strict;

my $count=0;
my $lastUrbLTime=0;
my @buffer;

while (my $line = <STDIN>) {

        if ( $line =~ m/>>>/ ) {
            dumper(@buffer) if $count;
            @buffer = ();
            $count++;
        }
        if ( $line =~ m/UsbSnoop/ ){next;}
        push(@buffer,$line);

}
dumper(@buffer) if $count;

sub dumper {

    my $dir='out';
    my $type='C';
    my $data=();
    my $urb=0;
    my $ep='';
    my $fTime=0;
    my $lTime=0;

    foreach my $line (@_) {

        if($line =~ m/\[(\d+) ms\] .* URB (\d+) going down/){
          $fTime=$1;
          $urb=$2;
          print "\npause " . ($fTime-$lastUrbLTime) . " ms\n\n";
        }
        elsif ( $line =~ m/USBD_TRANSFER_DIRECTION_IN/ ) {
          $dir='in';
          $data=();
        }
        elsif ( $line =~ m/-- URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER/ ) {
          $type='B';
        }
        elsif( $line =~ m/PipeHandle.*endpoint (0x\d+)/){
          $ep=$1;
        }
        elsif ( $line =~ m /  ([0-9a-f]{8}: )([0-9a-f ]*)/ ) {
          push(@{$data}, $1 . $2);
        }

        if ( $line =~ m/\[(\d+) ms\]/ ){
          $lTime=$1;
        }

        $ep=~s/^0x0+//;
    }

    if($dir eq 'in'){
        print "Urb $urb ($type) ep=$ep (read) ";
    }
    else{
        print "Urb $urb ($type) ep=$ep (write) ";
    }
    print $lTime-$fTime . " ms\n";

    foreach my $line (@{$data}) {
            printf(" %s", $line);
            print "\n";
    }

    $lastUrbLTime=$lTime;

}

exit 0;


More information about the sane-devel mailing list