GM-Script-Writer-62850 / PHP-Scanner-Server

Allows you to use your Linux install as a web based scanner server thus allowing you to scan with any web enabled device; Now supports server side printing! (As of 1.4.11)
59 stars 17 forks source link

Malformed output from "scanimage -f ..." causes json_decode to fail (and scanners not be detected) #32

Closed nariox closed 8 years ago

nariox commented 8 years ago

I don't know if it was a recent update or not, but my scanner is not being detected automatically anymore. After some debugging, I've found out that the scanimage -f command returns: "[{"ID":0,"INUSE":0,"DEVICE":"hpaio:/usb/Photosmart_C4600_series?serial=CN978MG0DT05BQ","NAME":"Hewlett-Packard Photosmart_C4600_series all-in-one"},{"ID":1,"INUSE":0,"DEVICE":"hpaio:ect hp:/usb/Photosmart_C4600_series?serial=CN978MG0DT05BQ "HP Photosmart C4600 series" "HP Photosmart C4600 series USB CN978MG0DT05BQ HPLIP" "MFG:HP","NAME":"Hewlett-Packard Photosmart_C4600_series all-in-one"}]" I'm not sure why my scanner is being detected twice, but the main issue is that the second "DEVICE" is producing a malformed json statement (due to too many quotation marks). I'm not knowledgeable in PHP, but I imagine the fix should be simple. Anyone else experienced this? (I might need to disclose I'm using Arch, and not *buntu).

Thanks for the help

GM-Script-Writer-62850 commented 8 years ago

can you post the debug console's content when you scan for scanners?

nariox commented 8 years ago

Sure, it is: http@:/srv/http/scan$ scanimage -f "{\"ID\":%i,\"INUSE\":0,\"DEVICE\":\"%d\",\"NAME\":\"%v %m %t\"}," {"ID":0,"INUSE":0,"DEVICE":"hpaio:/usb/Photosmart_C4600_series?serial=CN978MG0DT05BQ","NAME":"Hewlett-Packard Photosmart_C4600_series all-in-one"},{"ID":1,"INUSE":0,"DEVICE":"hpaio:ect hp:/usb/Photosmart_C4600_series?serial=CN978MG0DT05BQ "HP Photosmart C4600 series" "HP Photosmart C4600 series USB CN978MG0DT05BQ HPLIP" "MFG:HP","NAME":"Hewlett-Packard Photosmart_C4600_series all-in-one"},
http@:/srv/http/scan$ groups 'http' lp mail scanner lpadmin http http@:/srv/http/scan$

nariox commented 8 years ago

I believe the issue is the "hpaio:ect hp:/usb/Photosmart_C4600_series?serial=CN978MG0DT05BQ "HP Photosmart C4600 series" "HP Photosmart C4600 series USB CN978MG0DT05BQ HPLIP"

GM-Script-Writer-62850 commented 8 years ago

can you run this? scanimage -f "%d%n%v %m %t%n%n" assuming your device string is full of stuff it should not have does it even work if you call the device by that name? scanimage -A -d '[device_string_here]'

GM-Script-Writer-62850 commented 8 years ago

clearly i do need to patch it for double quotes in the variables either way i just want to see if that will fix the issue or if it is also a upstream big in scanimage

GM-Script-Writer-62850 commented 8 years ago

Give that patch a try, it should at least fix your scanner, i don't know if the second found scanner (which looks like a error to me) will work

nariox commented 8 years ago

Yes, this fixes the detection. The second one shows up in the scanner page, but as "inactive", which is fine.

I have this scanner shared over the network with saned, I wonder if that's what scanimage is picking up.

Just in case you're still interested, here's the output of scanimage:

hpaio:/usb/Photosmart_C4600_series?serial=CN978MG0DT05BQ
Hewlett-Packard Photosmart_C4600_series all-in-one

hpaio:ect hp:/usb/Photosmart_C4600_series?serial=CN978MG0DT05BQ "HP Photosmart C4600 series" "HP Photosmart C4600 series USB CN978MG0DT05BQ HPLIP" "MFG:HP
Hewlett-Packard Photosmart_C4600_series all-in-one
GM-Script-Writer-62850 commented 8 years ago

it should not detect a sane share unless you also configure the server as a client to itself, even then it works just fine http://ubuntuforums.org/showthread.php?t=1519201

id say that additional entry is a bug in sane or the hplip driver a Shared HP printers device string looks like this net:10.0.0.50:hpaio:/usb/Deskjet_F4400_series?serial=CN05DC61TP05C5

nariox commented 8 years ago

Weird then. Well, I might be the only one with this weird behavior, but since at least the detection now works well, I guess we could close the bug.

Pedro Nariyoshi

On Tue, Dec 1, 2015 at 6:37 AM, GM-Script-Writer-62850 < notifications@github.com> wrote:

it should not detect a sane share unless you also configure the server as a client to itself, even then it works just fine http://ubuntuforums.org/showthread.php?t=1519201

— Reply to this email directly or view it on GitHub https://github.com/GM-Script-Writer-62850/PHP-Scanner-Server/issues/32#issuecomment-160942541 .

GM-Script-Writer-62850 commented 8 years ago

I would check on arch forums and see if anyone is able to get off data in there scanner list if there was not a malformed device uri the patch i made would never have been needed