SimulPiscator / AirSane

Publish SANE scanners to MacOS, Android, and Windows via Apple AirScan.
GNU General Public License v3.0
243 stars 26 forks source link

Scanner detected by scanimage but not Airsane #83

Closed Kyshman closed 2 years ago

Kyshman commented 2 years ago

Server: OS: Ubuntu 18.04.6 LTS i686 Kernel: 4.15.0-159-generic

Scanimage: scanimage -L device hp5590:libusb:001:002 is a HP 5590 Workgroup scanner device hpaio:/par/HP_LaserJet_1100?device=/dev/parport0' is a Hewlett-Packard HP_LaserJet_1100 all-in-one

Airsane CLI launch sudo /usr/local/bin/airsaned --interface=\* --listen-port=8090 --access-log=- \ --hotplug=true --mdns-announce=true --announce-secure=false \ --unix-socket= --web-interface=true --random-paths=false \ --local-scanners-only=true --disclose-version=true \ --reset-option=true --options-file=/etc/airsane/options.conf --ignore-list=/etc/airsane/ignore.conf --debug=true

Relevant CLI Output

found: hp5590:libusb:001:002 (HP 5590) stable unique name: hp5590:HP 5590:1 uuid: 975bc2fa-6a5e-5a13-923b-020331495a17 sane_init(nullptr, nullptr) sane_open(hp5590:libusb:001:002) -> SANE_Status Invalid argument sane_exit()

The webpage on port 8090 says no scanners available. When airsane is running scanimage output is

scanimage -L

device `hpaio:/par/HP_LaserJet_1100?device=/dev/parport0' is a Hewlett-Packard HP_LaserJet_1100 all-in-one

Once airsane is stopped the output of scanimage goes back to normal

scanimage -L

device hp5590:libusb:001:002' is a HP 5590 Workgroup scanner devicehpaio:/par/HP_LaserJet_1100?device=/dev/parport0' is a Hewlett-Packard HP_LaserJet_1100 all-in-one

I cant figure out why airsane can't open the scanner yet it seems to make it unavailable to scanimage.

SimulPiscator commented 2 years ago

I agree that it's strange that sane_open fails with an error code but still keeps some lock on the device so scanimage -L can't find it. I tend to see this as a bug in the hpaio backend.

Independently of that: does actual scanning work through scanimage?

Kyshman commented 2 years ago

The reason I am installing Airsane is that for some reason am unable to install sane-frontends via Macports on a clean install of macos (Big Sur). I had it working previously on Catalina where I was running scanimage on the macos.

scanimage -d 'net:sahara:hp5590:libusb:001:005' --mode Gray --resolution 600 | convert -density 100 -define pdf:fit-page=A4 - Old1.pdf

My current workflow is scanimage (On the Linux box) ----> Output (jpg or tiff) -----> scp (To macos). This was before I installed Airsane on the macos.

Haven't tried it yet directly on the linux box after installing Airsane but will try a little bit later this evening.

SimulPiscator commented 2 years ago

I was actually wondering whether it works on the Ubuntu box because that helps me in understanding where the cause of the problem may be.

Kyshman commented 2 years ago

Confirmed. The linux box does scan flawlessly both via GUI & CLI without Airsane running

scanimage -p -vvvvvvvvvvvvv > test.jpg scanimage: scanning image of size 850x1173 pixels at 1 bits/pixel scanimage: acquiring gray frame scanimage: read 125511 bytes in total Closing device Calling sane_exit scanimage: finished

With Airsane running

scanimage -p -vvvvvvvvvvvvv > /tmp/test.jpg scanimage: open of device hpaio:/par/HP_LaserJet_1100?device=/dev/parport0 failed: Invalid argument Calling sane_exit scanimage: finished

So the scanner as usual is not accessible when Airsane is running.

BTW I have stopped saned, both the socket and the service.

SimulPiscator commented 2 years ago

Does it acquire from the the LaserJet 1100 device, or the hp5590 device? Sorry, I'm a little confused.

Kyshman commented 2 years ago

I was actually just going to clarify that for you as you also had me a bit lost whein you mentioned the hpaio backend

I agree that it's strange that sane_open fails with an error code but still keeps some lock on the device so scanimage -L can't find it. I tend to see this as a bug in the hpaio backend.

The LaserJet 1100 is an ancient printer (only) connected on the same box via parallel port while the scanner is the hp5590 on USB which is using the sane-hp5590 backend.

This is the device that keeps disappearing when Airsane is started. We can safely diregard any mention of the 1100.

SimulPiscator commented 2 years ago

I was actually just going to clarify that for you as you also had me a bit lost whein you mentioned the hpaio backend

I was clearly lost there, sorry.

So you can successfully scan from the hp5590 device? Sometimes what happens is that a device appears on a USB port but disappears when activated or scanning because the USB port power is insufficient. Maybe the device is powered externally but cable or power supply are faulty?

Kyshman commented 2 years ago

So you can successfully scan from the hp5590 device?

Yes this working fine. I can scan locally on the Ubuntu box.

Its only when Airsane is started that the device disappears fron the scanimage listing and thus am unable to scan.

sane_init(nullptr, nullptr) sane_open(hp5590:libusb:001:002) -> SANE_Status Invalid argument sane_exit()

Can further debug info/level be activated?

SimulPiscator commented 2 years ago

No, I cannot look into the machinery behind sane_open() beyond its return value. Could you try scanimage -d hp5590:libusb:001:002 >test.pnm to make sure it is the same device name as in AirSane that is used?

Kyshman commented 2 years ago

lsusb

Bus 001 Device 002: ID 03f0:1705 Hewlett-Packard ScanJet 5590

scanimage -L

device `hp5590:libusb:001:002' is a HP 5590 Workgroup scanner

scanimage -d hp5590:libusb:001:002 >/tmp/test.pnm This works fine

SimulPiscator commented 2 years ago

OK, so it's not a power supply problem. Unfortunately, as I said, it is not possible to look into the sane_open() call when running airsaned. One last possibility would be that you have more than one libsane installed at different locations, and airsaned links to a different one than scanimage.

Kyshman commented 2 years ago

I upgraded sane to latest git stable

scanimage -V

scanimage (sane-backends) 1.0.32.128-3440e; backend version 1.0.32

One last possibility would be that you have more than one libsane installed at different locations, and airsaned links to a different one than scanimage.

whereis sane

sane: /usr/lib/i386-linux-gnu/sane /usr/lib/sane /etc/sane.d /usr/include/sane /usr/share/sane /usr/share/man/man7/sane.7.gz

whereis libsane

libsane: /usr/lib/i386-linux-gnu/libsane.so /usr/lib/i386-linux-gnu/libsane.a

So I have only one instance of sane installed but the issue still persists

Am now checking on the sane-hp5900 backend to see if I can tweak anything

Kyshman commented 2 years ago

Am now checking on the sane-hp5900 backend to see if I can tweak anything

There is little if anything to tweak on the backend.

The reason I am installing Airsane is that for some reason am unable to install sane-frontends via Macports on a clean install of macos (Big Sur). I had it working previously on Catalina where I was running scanimage on the macos.

Wasn't aware that scanimage comes with sane-backends which is already installed so now I have scanimage/xsane working on the macOS which satisfies my current needs.

Its a shame that Airsane from the Linux box isn't working thus Apple's ImageCapture framework apps cant acquire images from the scanner.

rcambrj commented 1 year ago

I just acquired an old hp5590 and I'm getting the same problem:

sane_init(nullptr, nullptr)
sane_open(hp5590:libusb:001:005) -> SANE_Status Invalid argument
sane_exit()
error: failed to open device

I can successfully scan with scanimage, but when airsaned is running it all breaks.

scanservjs on the same machine seems to work. So whatever that's doing, it's working... but I'm concerned about the RPi1 not having enough power to process large documents scanned through the ADF. This is easily solved with a beefier machine, but it's a shame, would have been nice to have it networked with airsaned.

SimulPiscator commented 1 year ago

One possible difference between airsaned and the other programs is that the other programs call sane_open() from the main thread whereas airsaned does so from a secondary thread. To test this, I created a branch "testing" that you might try.

rcambrj commented 1 year ago

Thanks for trying, I ran cmake and sudo make install on that branch, but the failure is the same 😞

SimulPiscator commented 1 year ago

Did you do a sudo systemctl restart airsaned after make install?

rcambrj commented 1 year ago

the systemctl unit is disabled, I just ran sudo -u saned airsaned --debug=true --access-log=-