[sane-devel] Re: fb630u success

nathan rutman nathan@gordian.com
Mon, 29 Oct 2001 10:09:30 -0800


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Content-Type: text/plain; charset=us-ascii


> On Fri, 26 Oct 2001, nathan rutman wrote:
> > Got my first image out of the Canoscan FB630U.
> > The image and source code are at
> > http://www.gordian.com/~nathan/linux.html
> 
> Could you please give me more details of just how you got hold of the
> protocol? I've been using USB Snoopy, which is at the very least, a poor
> packet sniffer, but I'll investigate the patched thing when I get chance.

Well, it was pretty slow going.  The first thing I did was get the USB
Control Packet communication going with the scanner.  This was similar to
the HP4200 and others.  I took some debugging printfs in scanner.c and 
usb.c to figure out what was going on, but I got it going with some new 
ioctls based on the HP4200 mods. 
I captured what I could from Win2k's driver with USB Snoopy multiple
times under various conditions.  Yes, it dropped packets, which was a
pain in the ass, but only after the big bulk transfers began, which
turned out to be pretty far along the road. Anyhow, I started by
converting every USB packet to an ioctl call (using an awk script on the
log.)  Looking at the results, I noticed that there seemed to be pairs of
ioctls, which looked like "address" and "write value" or "read value".
So I just wrapped the pairs with functions "read" and "write" and then
rewrote the log script again using them, and it looked like it still made
sense - there would be a series of writes to sequential addresses, and
verification or polling reads (where it would keep "read"ing the same
address until the returned value changed in some way.) So by this point I
was pretty convinced I had read and write down. 
The bulk read and bulk write all had a particular control packet going
down before them also, but it was a pretty straightforward 8 bytes, 1
controlling direction and 2 with the transfer size, which I determined 
after looking at a bunch of them.
Then I started stepping though the captures, trying to determine what 
each address controlled.  Bertrik Sikken's work on the HP3300C was a 
useful reference for what some of the registers did, although the 
register numbers were different.  I finally took a look at the 
datasheet for the scanner chip that you had identified and voila, the 
register set listed there matched what I had discovered so far on my own. 
So now I can communicate, read, write, and know what those registers 
mean, and have the logs of what Win2k does for calibration and scanning, 
so I can duplicate that and understand what the Win2k driver does.  The 
only thing left figuring out what format the resulting scan data was in, 
which I did by playing around with the "read raw" command in Adobe 
Photoshop until the image was clear.

> Anyway, well done for getting an image scanned in - and let me know how I
> can help. Would you like to have use of my SourceForge FB630U project
> facilities?

Please take whatever you want out of my wimpy web page and add it to 
yours.  CVS'ing the code would be great.

Code TBD:
1. Use variables to control scan size and depth (hard-coded now) and 
output a real image format for a usable user-space utility.
2. Do a real calibration (hard-coded now.)  
3. Migrate to a SANE backend.


- --
nathan@gordian.com


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: Exmh version 2.3.1 01/18/2001 (debian 2.3.1-1)

iD8DBQE73ZtaA46mJx3/7XURAjLCAJ9STo8UVs9tMhk4k9gl+nD9wTvB7wCdFlOP
wImJazUkYrqVxJN6dpRYiYM=
=4OnE
-----END PGP SIGNATURE-----