A recurring problem with using saned over the network is an
incomprehensible "I/O error" with a variety of scanners. Using
a fresh install of Ubuntu lucid 10.04 and a freshly compiled
sane-backends 1.0.22, with a new Kodak i1210 scanner, I found
the following:
1. Locally, scanimage -L
detected the scanner correctly.
2. Locally, scanimage --device-name kds:i1210/i1220 --batch=foo%d.pnm
scanned every page correctly into local files.
3. Locally, scanimage --device-name net:localhost:kds:i1210/i1220
--batch=foo%d.pnm
failed with "scanimage: sane_read: Error during device I/O."
4. Over the net, scanimage --device-name net:<ip of server>:kds:i1210/i1220
--batch=foo%d.pnm
failed with "scanimage: sane_read: Error during device I/O."
The following patch fixes the 4th situation (but not the 3rd) imperfectly: the
first
scanned page is lost completely. However, if the length is not set to zero,
the first
two pages are mixed together and only the third and subsequent pages of a batch
are
scanned and transmitted correctly. The patched version of sane is installed
into
/usr/local/sbin/ and the file /etc/xinetd.d/saned is updated accordingly:
# server = /usr/sbin/saned
server = /usr/local/sbin/saned
Thus, this patch allows the scanner to be used over the net using sane at the
cost of
having to place a placeholder sheet before the first page that is to be scanned
(since
the first scanned page is discarded, the placeholder is discarded and the first
"real"
sheet is the second in the batch to be scanned). The questions
now are:
1) why is the status SANE_STATUS_JAMMED returned with loss of part of the
first page?
2) What can be done about it?
I do not think the Kodak i1210 scanner is responsible because it works
flawlessly via
its local usb connection and because the same error has been reported with
other scanners.
Please note that I did not test this patch by actually jamming the scanner to
make sure
it would signal the error.
Thanks
diff -rc sane-backends-1.0.22/frontend/saned.c
sane-backends-1.0.22.new/frontend/saned.c
*** sane-backends-1.0.22/frontend/saned.c 2010-12-01 17:49:58.000000000
-0600
--- sane-backends-1.0.22.new/frontend/saned.c 2011-11-01 21:55:34.000000000
-0500
***************
*** 1753,1758 ****
--- 1753,1772 ----
status = sane_read (be_handle, buf + reader, nbytes, &length);
DBG (DBG_INFO,
"do_scan: read %d bytes from scanner\n", length);
+ /* 2011-11-01 L Widman */
+ // for some reason, the first bufferful comes with status
SANE_STATUS_JAMMED
+ // which is separate from the scanner being empty later, and the
first page
+ // is not read completely.
+ // Setting the initial length to 0 essentially discards the first
page and
+ // allows the remaining pages to be read and transmitted normally.
+ // Note that reader == 4 only during the first iteration unless
it exceeds sizeof(buf)
+ if( (reader == 4) && (status == SANE_STATUS_JAMMED) ){
+ DBG (DBG_INFO,
+ "do_scan: accepting %d bytes from scanner despite status
%s\n", length, sane_strstatus(status));
+ status = SANE_STATUS_GOOD;
+ length = 0;
+ }
+ /* 2011-11-01 L Widman */
reset_watchdog ();