I'm no longer active in developing SANE drivers. Please send any comments or support requests to the sane-devel mailing list.


As Mustek didn't provide any programming documentation for their SCSI scanners I had to use different methods more then once. Maybe other developers can take advantage of them. Don't hesitate to to email me if you have additional information. Most information on this page is rather old, so updates are really appreciated.

The problem

You have a Scanner supplied with a MS Windows driver and want to support it by a SANE backend. You need to know the SCSI commands and buffers the driver sends to the scanner (and the scanner's response). The same goes for USB and parallel port scanners.

Possible solutions

WINE: Some Windows drivers for SCSI scanners can be used with WINE. I had success with a Mustek ScanExpress 12000SP. This works if the scanner driver is able to connect to a SCSI adapter using ASPI (Adaptec's "standard" for talking directly to SCSI devices; similar to sg driver for Linux). If the Windows driver can only use the SCSI adapter supplied by the manufacturer we are out of luck. Otherwise the WINE ASPI libs can be used. There is some information about this in the documentation directory of WINE. Be sure WINE's ASPI libs are used (wine.conf). Debugging can be enabled by wine --debugmsg aspi progname. If this is not sufficient more debug output can be added in WINE or the kernel driver (e.g. drivers/scsi/sg.c for Linux).

I haven't tried this but there is support for similar tricks for parallel port devices: read documentation/ioport-trace-hints.

I haven't found anything about USB in WINE but as my Windows 95 doesn't have any USB support I didn't try hard.

VMWARE: VMware now supports generic SCSI and USB devices. At least USB logging is reported to work by adding debug statements to the USB driver.

BOCHS has been used to determine the protocol of parport scanners.

Windows spy programs: There is a program called USB Snoopy (also USB Snoopy Pro and sniffusb) that'll dump the USB transactions made by Windows drivers. John Fremlin wrote a program (usb-robot) to let spit these transactions back at the device under linux (or other transactions of your choice). The usbsnoop2libusb.pl script generates c code using libusb that compiles and executes the same USB commands that were captured in from the snoop.

On the cdrlabs page there is an article about ASPI Spy, a SCSI logger on win32. It uses a wrapper dll like the one mentioned below.

I have written a small wrapper dll (Delphi sourcecode) which wraps the Windows winaspi.dll and sends all the SCSI commands and the beginnings of the buffers to a text file. This was pretty helpful for supporting the Mustek Paragon 1200 A3 Pro. It only works if the scanner driver can connect to ASPI complient SCSI adapters and doesn't insist on their own adapter. The wrapper dll is written in Delphi 1 and is for the 16 bit winaspi.dll only (not wnaspi32.dll). You need to rename the original winaspi.dll (in windows\system\) to winaspio.dll. Then copy the wrapper DLL winaspi.dll to windows\system\. Debug output goes to /temp/aspi.txt.

There is also a spy program for SCSI in the ASPI SDK ("aspispy.exe"). This program connects to the ASPI layer and records any ASPI commands sent to a device. That's nice, but it doesn't seem to be able to print the buffers sent by drivers. Maybe there are commercial solutions but I couldn't find information about this type of program.

Jungo provides a commercial multi-platform package of driver development tools . There is also a hardware debugger included. I haven't tested these tools but as there are evaluation versions, they may be worth a try. I'm interested in reports about these tools.

For parallel (and serial) port devices, portmon may help.

Disassembling the Windows driver: I have never done this, but I think it's a lot of work as the output tends to be very long. Programs like BIEW and IDA Pro might help.

Hardware solutions: USB analyzers/loggers can be used to log the traffic between the host and the scanner. Personally, I use the Beagle USB Protocol Analyzer which is also useful to find timing issues in SANE backends.

There are also SCSI and parport hardware debuggers but they seem to be pretty expensive.

How to get the log file and to interpret it

The actual way how to get the log of the communication between the computer and the scanner depends on the software and hardware used. There are some generic hints however:

More links

Last modified: 2008-03-02 16:38:20 CET by Henning Geinitz

Back to the general SANE page
Back to my homepage (in German)
Impressum (in German)