openpaperwork / pyinsane

Python library to access and use image scanners (Linux/Windows/etc) (Sane/WIA) -- Moved to Gnome's Gitlab
https://gitlab.gnome.org/World/OpenPaperwork/pyinsane
63 stars 24 forks source link

pyinsane.rawapi.SaneException: Error during device I/O #8

Closed sisco70 closed 10 years ago

sisco70 commented 10 years ago

Hallo,

I'm switched from 1.2.1 to the latest version of pyinsane (1.3.1) on a Ubuntu 13.04 64bit (fully updated). I have an HP OfficeJet 6700 Premium.

Now, when i try to scan from ADF i have this error:

pyinsane.rawapi.SaneException: <class 'pyinsane.rawapi.SaneStatus'> : Error during device I/O (9)

To reproduce this issue simply run :

import pyinsane.abstract as pyinsane

devices = pyinsane.get_devices()
assert(len(devices) > 0)
device = devices[0]

print("I'm going to use the following scanner: %s" % (str(device)))
scanner_id = device.name

if not "ADF" in device.options['source'].constraint:
    print("No document feeder found")
else:
    device.options['source'].value = "ADF"
    # Beware: Some scanner have "Lineart" or "Gray" as default mode
    device.options['mode'].value = 'Color'
    scan_session = device.scan(multiple=True)
    try:
        while True:
            try:
                scan_session.scan.read()
            except EOFError:
                print ("Got a page ! (current number of pages read: %d)"  % (len(scan_session.images)))
    except StopIteration:
        print("Document feeder is now empty")
        for idx in range(0, len(scan_session.images)):
            image = scan_session.images[idx]

the output is:

francesco@xyz:~$ python test.py 
I'm going to use the following scanner: Scanner 'hpaio:/net/Officejet_6700?ip=192.168.0.99' (Hewlett-Packard, Officejet_6700, all-in-one)
Got a page ! (current number of pages read: 1)
Traceback (most recent call last):
  File "test.py", line 20, in <module>
    scan_session.scan.read()
  File "/usr/local/lib/python2.7/dist-packages/pyinsane/abstract.py", line 289, in read
    Scan.read(self)
  File "/usr/local/lib/python2.7/dist-packages/pyinsane/abstract.py", line 174, in read
    read = rawapi.sane_read(sane_dev_handle[1], SANE_READ_BUFSIZE)
  File "/usr/local/lib/python2.7/dist-packages/pyinsane/rawapi.py", line 677, in sane_read
    raise SaneException(SaneStatus(status))
pyinsane.rawapi.SaneException: <class 'pyinsane.rawapi.SaneStatus'> : Error during device I/O (9)

Thank you

jflesch commented 10 years ago

You're right. I've broken something. You get a SaneException, but I actually get an infinite loop.

jflesch commented 10 years ago

I did a mess in the ADF support when modifying the API for the 1.3.x ... sorry for the inconvenience.

It should be fixed now: 38551143b0a7bad4e7ea4ce42990b028e649c65c 6da006b18ba9fb771b194ef57339f54a983eac49

Can you test it and tell me if it works for you now ? If it's ok, I'll release a 1.3.2 asap.

jflesch commented 10 years ago

I'm pretty sure your bug and mine are actually the same. I'm also confident it's fixed now, so I've just released the 1.3.2 with this fix included. If you still have your bug with the 1.3.2, I can still release a version 1.3.3 later if required.

Please tell me if the 1.3.2 works for you.

sisco70 commented 10 years ago

Ok! Now it works! Thank you.

jflesch commented 10 years ago

You're welcome :)