rocketraman / sane-scan-pdf

Sane command-line scan-to-pdf script on Linux with OCR and deskew support
MIT License
137 stars 27 forks source link

scanadf: open of device fujitsu failed: Invalid argument #16

Closed timcknowles closed 3 years ago

timcknowles commented 3 years ago

I meant to say the script fails on this. Thanks Tim

rocketraman commented 3 years ago

The script defaults to a fujitsu scanner/device. What is your hardware? You can see the drivers / connected devices by doing this:

scanadf -L

You can then pass --device <device-name> to the script to use the correct one.

See the -L and -d parameters in man scanadf.

timcknowles commented 3 years ago

I'm using a FUJITSU ScanSnap S1300i scanner

pi@raspberrypi:~ $ scanadf -L device `epjitsu:libusb:001:011' is a FUJITSU ScanSnap S1300i scanner

but the script already defaults to DEVICE=fujitsu

Thanks again for your help

timcknowles commented 3 years ago

Update:

I changed the device from DEVICE=fujitsu to DEVICE=epjitsu

pi@raspberrypi:~ $ sudo scanbd -f scanbd: dbus match type='signal',interface='org.freedesktop.Hal.Manager' scanbd: SANE_CONFIG_DIR not set scanbd: Not Primary Owner (-1) scanbd: Name Error (Connection ":1.75" is not allowed to own the service "de.kmux.scanbd.server" due to security policies in the configuration file) scanbd: trigger action for scan for device epjitsu:libusb:001:011 with script scan.sh units: cannot read file '/root/.units'. Permission denied units: cannot read file '/root/.units'. Permission denied Scanning... scanadf: rounded value of page-height from 279.4 to 279.406 scanadf: invalid option -- 'y' Found no scans.

rocketraman commented 3 years ago

You are triggering a scan from scanbd -- honestly I don't know what parameters that script is called with. You'll likely need to create some type of shim script that takes whatever parameters it gets when the button is pressed, and converts them to the parameters needed by the scan script.

For the purposes of debugging here, I'd remove scanbd out of the equation, and just get things working directly with scan. If that doesn't work, then post here your command line, and complete output with the -v (verbose) parameter.

timcknowles commented 3 years ago

That makes complete sense to remove scanbd, I saw that other's had had success and that's how I came to try try it. This is the output:

pi@raspberrypi:~/sane-scan-pdf $ sudo bash scan -v -d -r 300 -v -m Lineart --skip-empty-pages -o /home/pi/scans/scan Scanning... scanadf: rounded value of page-height from 279.4 to 279.406 scanadf: invalid option -- 'y' Found no scans.

Thanks

rocketraman commented 3 years ago

Probably unrelated, but you shouldn't need to use sudo when running this script. Nothing it does should require root access.

The '-y' option is a driver-specific option for page height. Looking at the man page for epjitsu (https://linux.die.net/man/5/sane-epjitsu) it does seem to have some limitations:

These scanners are fairly limited, only supporting a couple of modes and resolutions, and always scanning full width. The backend supports missing modes (binary, grayscale) in software, but makes no effort to offer intermediate resolutions or scan area controls. See KNOWN ISSUES.

and

No scan area options are exposed.

Try removing or commenting these lines from your script and see if it works:

https://github.com/rocketraman/sane-scan-pdf/blob/master/scan#L185-L188

rocketraman commented 3 years ago

Or grab the code from https://github.com/rocketraman/sane-scan-pdf/pull/17 and try to call the scan script with the argument --no-default-size.

rocketraman commented 3 years ago

@timcknowles Once you let me know if the code from #17 is working for this case, I can merge it to master.

timcknowles commented 3 years ago

Hi thanks so much for this. I can confirm that by using code from #17 and calling the script with the argument --no-default-size works for the S1300i.

I did run into one more dependency issue with the scan_perpage script "bc: command not found" - installing the bc package fixed this (apt-get install bc)

I'm going to continue to try and get this work calling it via scanbd so the scan triggered form the scanner button and not just the cmd line.

Thanks Tim

rocketraman commented 3 years ago

Thanks for that confirmation. Code merged to master, README updated with optional bc dependency, and wiki https://github.com/rocketraman/sane-scan-pdf/wiki/Dependencies-Installation updated also.

rocketraman commented 2 years ago

@timcknowles This issue might be relevant to your use case with scanbd: https://github.com/rocketraman/sane-scan-pdf/issues/39.