[sane-devel] Paper size detection for Fujitsu fi-5110eoxm (sane-fujitsu)?

abel deuring adeuring at gmx.net
Sun Mar 22 15:43:18 UTC 2009

On 22.03.2009 12:58, Adam Richter wrote:
> Hello,
> 	At the outset, let me say thank you to the sane-fujitsu
> authors (according to fujitsu.c, Randolph Bentson, Frederik Ramm,
> Oliver Schirrmeister, and M. Allan Noah) for providing a backend that
> has been working so well with my Fujitsu fi5110eoxm double sided
> sheet fed scanner for almost two years.
> 	I am interested in adding automatic page length detection,
> similar to what the avision driver does I would like some pointers to
> the relevant technical specifications of the protocol used by the
> scanners that sane-fujitsu supports.  I do not see that feature in
> the cvs snapshot of 2009.03.22, but I may have missed something.  I
> am not saying that I am committing to implement this, but I would
> like to get the relevant technical specifications and see how hard
> it would be to try.

I can't claim that I know how page length detection works in the avision
backend, but from quickly grepping through the source code it seems that
some Avsion scanners have some sort of firmware support for this
feature. Some Fujitsu scanners, OTOH, support an "overscan" feature,
meaning that they scan an area larger than the selected papersize.
Additionally, you can select the color of this overscan area to be
either white or black, so that the scan data can include a black margin
around white pages or a white margin for black pages. This allows you to
implement paper size and skew detection in software. Having code that
implements these features would really great -- but the code should IMHO
live outside the Fujitsu backend, just for the case that scanners from
other manufacturers support a similar feature.

Some kind of library would be great, another option would be a
contribution for a program like Jens Gulden's unpaper.

>         If I get really ambitious, perhaps I might also try to
> implement a "bottom margin" option to scan a bit past the end to
> accomodate pages scanned at a slight angle, and perhaps some support
> for the "scan" button also along the line of what avision has.
> 	Just to confirm that I have done some basic sanity checks
> related to this request, I will mention that scanner appears to
> support page length detection, according to these web pages:
> 	"Automatically recognizes document type by paper length"
> 		http://scansnap.fujitsu.com/spec-mac.html
> 	"Automatic de-skew and paper size detection"
> 		http://www.fujitsu.com/us/services/computing/peripherals/scanners/discontinued/fi-5110eoxm.html (click on "Features" tab)
> 	As another sanity check, I should mention that I have done
> some web searches and skimmed the sane-devel mailing list to
> try to see if anyone is already working on this, and have not
> found any hits.
> 	At first, I was hopeful that since the fujitsu backend's help
> text mentioned that it wanted to know the page size in order to do jam
> detection, that perhaps the driver was periodically querying the paper
> detection and scrolling the paper from the host computer, but a quick
> look at the source code seems to indicate that the paper size
> information is simply sent to the scanner, I guess locally controls
> the scrolling of the paper feeder.  So, I think I need more
> documentation about the protocols used by this scanner to figure out
> how to implement support for automatic paper length detection.

AFAICS the Fujitsu scanners use indeed the selected page length to check
if some sensor "sees" paper after a document has been fed for the
selected page length (plus some error margin).

> 	I assume that there is no automatic paper width detection, but
> would be happy to be corrected if I am wrong, especially because the
> images that I receive for the areas left and right of the paper being
> scanned seem to have some noise (that is, they are not columns of
> exactly one solid color), so I will probably have to do some research
> to determine if I can find software that reliably detects the paper's
> left and right edges.

Again, the overscan feature should give you all data you need (erm,
provided that your  5110eox supports it...)

> 	Finally, on a different subject, but one related to protocol
> documentation, I notice that nineteen .c files in
> sane-backends-2009-03-22/backends contain both the terms "USB" and
> "SCSI", so it looks like there are multiple drivers that claim to
> encapsulate some kind of scsi commands over USB.  This makes me wonder
> if there might be some SCSI standards on t10.org and/or USB device
> class specification on www.usb.org that might describe what most of
> these drivers do and perhaps provide an opportunity to factor out some
> common code.  On the other hand, if the fujitsu scanners are basically
> running a custom protocol, then I probably need some documents from
> Fujitsu, which I am sure would be helpful in any case.
> 	Any pointers would be appreciated.  Thanks in advance.

You'll find indeed drafts of the SCSI2 and SCSI3 standards at t10.org.
And they contain ineed a description of scanner commands. The problem is
that the fine details of which bits and bytes you can/must/should set
for commands like SET WINDOW differ considerably from vendor to vendor.
(Just compare the code of a few Sane backends to get an idea of this
mess...) Of course, the options that can be set also depend on features
of specific models: For example, it does not make sense to set some ADF
option for flatbed scanners. Similarly, several vendors provide quite
important details about a given model, like maximum scan size or maximum
resolution, into the vendor-specific part of the data returned for
INQUIRY -- but as "vendor-specific" suggests, the INQUIRY data returned,
for example, by a Fujitsu scanner must be interpreted differently from
that returned by an Avision scanner. In other words: Writing a universal
backend for SCSI scanners would be much harder than writing a driver for
SCSI disks or tape drives.


More information about the sane-devel mailing list