jwilk / scanhelper

command-line tool for batch scanning
https://jwilk.net/software/scanhelper
GNU General Public License v2.0
3 stars 0 forks source link

lack of --batch-button leads to infinite loop #2

Closed jwilk closed 9 years ago

jwilk commented 9 years ago

Issue reported by @jsbien:

Called without any parameters the program doesn't print help as expected but enters an infinite loop ignoring the lack of pages to scan:

Target directory: 2014-11-24T10:53:00
+ scanimage --device-name fujitsu:fi-6130dj:47352 --format=tiff '--batch=p%04d.png.tmp.scanhelper~' --batch-start=1
| Scanning -1 pages, incrementing by 1, numbering from 1
| Scanning page 1
| scanimage: sane_start: Document feeder out of documents
+ scanimage --device-name fujitsu:fi-6130dj:47352 --format=tiff '--batch=p%04d.png.tmp.scanhelper~' --batch-start=1
| Scanning -1 pages, incrementing by 1, numbering from 1
| Scanning page 1

...

jwilk commented 9 years ago

Comment submitted by @jsbien:

The infinite loop is entered also in a production run, so it is a more serious bug than I thought.

jsbien@debian2050pc1:~/scanhelper$ ./scanhelper -d fujitsu:fi-6130dj:47352 -t test -p -v --xmp --source "ADF Duplex" --mode Color --resolution 600dpi --page-width 166mm --page-height 238mm
+ scanimage --device-name fujitsu:fi-6130dj:47352 --format=tiff '--batch=p%04d.png.tmp.scanhelper~' --batch-start=1 --progress --verbose --source 'ADF Duplex' --mode Color --resolution 600dpi --page-width 166mm --page-height 238mm
| scanimage: rounded value of page-width from 166 to 166.01
| scanimage: rounded value of page-height from 238 to 238.01
| scanimage: rounded value of br-x from 215.872 to 166.01
| scanimage: rounded value of br-y from 279.364 to 238.01
| Scanning -1 pages, incrementing by 1, numbering from 1
| Scanning page 1
| scanimage: scanning image of size 3922x5622 pixels at 24 bits/pixel
| scanimage: acquiring RGB frame
scanimage: min/max graylevel value = 5/255
| scanimage: read 66148452 bytes in total
| Scanned page 1. (scanner status = 5)
| Scanning page 2
Converting p0001.png
| scanimage: scanning image of size 3922x5622 pixels at 24 bits/pixel
| scanimage: acquiring RGB frame
scanimage: min/max graylevel value = 8/255
| scanimage: read 66148452 bytes in total
| Scanned page 2. (scanner status = 5)
| Scanning page 3
Converting p0002.png
| scanimage: sane_start: Document feeder out of documents
+ scanimage --device-name fujitsu:fi-6130dj:47352 --format=tiff '--batch=p%04d.png.tmp.scanhelper~' --batch-start=3 --progress --verbose --source 'ADF Duplex' --mode Color --resolution 600dpi --page-width 166mm --page-height 238mm
| scanimage: rounded value of page-width from 166 to 166.01
| scanimage: rounded value of page-height from 238 to 238.01
| scanimage: rounded value of br-x from 215.872 to 166.01
| scanimage: rounded value of br-y from 279.364 to 238.01
| Scanning -1 pages, incrementing by 1, numbering from 3
| Scanning page 3
| scanimage: sane_start: Document feeder out of documents
+ scanimage --device-name fujitsu:fi-6130dj:47352 --format=tiff '--batch=p%04d.png.tmp.scanhelper~' --batch-start=3 --progress --verbose --source 'ADF Duplex' --mode Color --resolution 600dpi --page-width 166mm --page-height 238mm
| scanimage: rounded value of page-width from 166 to 166.01
| scanimage: rounded value of page-height from 238 to 238.01
| scanimage: rounded value of br-x from 215.872 to 166.01
| scanimage: rounded value of br-y from 279.364 to 238.01
| Scanning -1 pages, incrementing by 1, numbering from 3
| Scanning page 3
| scanimage: sane_start: Document feeder out of documents
...
jwilk commented 9 years ago

If you don't supply --batch-button, scanhelper doesn't wait between scan attempts, which is a dubious design.

I think I'll make --batch-button mandatory.

jwilk commented 9 years ago

Comment submitted by @jsbien:

Another solution is to exit scanhelper when "Document feeder out of documents" and there is no batch-button specified.

Both solutions are OK for me.

jwilk commented 9 years ago

In 1fcce7d2b4c92bae5065c3e2589188649e91c716 I implemented a slightly different solution. If there is no --batch-button, scanhelper will wait for ENTER before starting each batch. I hope this is a satisfactory solution to you.

jwilk commented 9 years ago

Comment submitted by @jsbien:

OK, thanks.

jwilk commented 9 years ago

I've just released scanhelper 0.4, which includes the aforementioned fix.