No scanning: "Failed to get_device … 0x40000003, Invalid value"

Hello,

I’ve just installed Paperwork on a Debian testing machine (‘bullseye’) using flatbak. According to the splash screen I am using Paperwork 1.3.1-27-g69075a47.

Unfortunately, scanning does not work using my Brother ADS-2100e – which has been running fine earlier with Debian stable and the flatpak.

When I try to scan, Paperwork asks me if the scanner is turned on. In the terminal, I get the following messages:

INFO   paperwork.frontend.util.config Will scan using sane:net:127.0.0.1:brother4:bus3;dev1
INFO   paperwork.paperwork            ../subprojects/libinsane/src/bases/sane.c:L212(ensure_sane_is_init): Sane version code: 0x100001B
INFO   paperwork.paperwork            ../subprojects/libinsane/src/bases/sane.c:L385(lis_sane_get_device): Sane: get_device(net:127.0.0.1:brother4:bus3;dev1) ...
ERROR  paperwork.paperwork            ../subprojects/libinsane/src/workarounds/cache.c:L568(cache_get_device): Failed to get_device(sane:net:127.0.0.1:brother4:bus3;dev1): 0x40000003, Invalid value
ERROR  paperwork.paperwork            ../subprojects/libinsane/src/normalizers/source_nodes.c:L442(lis_sn_get_device): wrapped->get_device() failed: 0x40000003, Invalid value
WARNING paperwork.frontend.util.config Exception while configuring scanner: <class 'gi.repository.GLib.GError'>: libinsane-quark: Libinsane get devices error: 0x40000003, Invalid value (4)
ERROR  paperwork.frontend.util.config libinsane-quark: Libinsane get devices error: 0x40000003, Invalid value (4)
Traceback (most recent call last):
File "/app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/util/config.py", line 350, in get_scanner
    return _get_scanner(config, libinsane, devid, preferred_sources)
File "/app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/util/config.py", line 300, in _get_scanner
    dev = libinsane.get_device(devid)
gi.repository.GLib.GError: libinsane-quark: Libinsane get devices error: 0x40000003, Invalid value (4)
INFO   paperwork.paperwork            ../subprojects/libinsane/src/bases/sane.c:L311(lis_sane_list_devices): Sane: list_devices() ...
INFO   paperwork.paperwork            ../subprojects/libinsane/src/bases/sane.c:L364(lis_sane_list_devices): Sane: list_devices(): 1 devices found
INFO   paperwork.frontend.util.config Will try another scanner id: sane:net:127.0.0.1:brother4:bus3;dev2
INFO   paperwork.frontend.util.config Will scan using sane:net:127.0.0.1:brother4:bus3;dev2
INFO   paperwork.paperwork            ../subprojects/libinsane/src/bases/sane.c:L385(lis_sane_get_device): Sane: get_device(net:127.0.0.1:brother4:bus3;dev2) ...
ERROR  paperwork.paperwork            ../subprojects/libinsane/src/workarounds/cache.c:L568(cache_get_device): Failed to get_device(sane:net:127.0.0.1:brother4:bus3;dev2): 0x40000003, Invalid value
ERROR  paperwork.paperwork            ../subprojects/libinsane/src/normalizers/source_nodes.c:L442(lis_sn_get_device): wrapped->get_device() failed: 0x40000003, Invalid value
WARNING paperwork.frontend.mainwindow  Exception while configuring scanner: <class 'gi.repository.GLib.GError'>: libinsane-quark: Libinsane get devices error: 0x40000003, Invalid value (4). Assuming scanner is not connected
ERROR  paperwork.frontend.mainwindow  libinsane-quark: Libinsane get devices error: 0x40000003, Invalid value (4)
Traceback (most recent call last):
File "/app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/util/config.py", line 367, in get_scanner
    config, libinsane, devices[0].get_dev_id(), preferred_sources
File "/app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/util/config.py", line 300, in _get_scanner
    dev = libinsane.get_device(devid)
gi.repository.GLib.GError: libinsane-quark: Libinsane get devices error: 0x40000003, Invalid value (4)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/mainwindow/__init__.py", line 1444, in do
    self.__config, self.__libinsane
File "/app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/util/config.py", line 372, in get_scanner
    raise exc
File "/app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/util/config.py", line 350, in get_scanner
    return _get_scanner(config, libinsane, devid, preferred_sources)
File "/app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/util/config.py", line 300, in _get_scanner
    dev = libinsane.get_device(devid)
gi.repository.GLib.GError: libinsane-quark: Libinsane get devices error: 0x40000003, Invalid value (4)
INFO   paperwork.frontend.util.dialog Showing popup !

Basically the same errors come up when using the built-in diagnosis tool: https://andwil.de/temp/paperworkdiag.txt.

When using Skanlite, scanning works just fine. Skanlite uses “brother4:bus3;dev2”.

Does anyone have an idea on how to get the scanner running again with Paperwork? Please let me know if you need any additional information.

Thanks a lot!

Hello,

In the last logs you just posted, we can see that Paperwork also used "brother4:bus3;dev2.

Anyway, if I’m not mistaken, “busX;devY” probably refers to your USB bus (you can probably confirm that with lsusb). And the last number may change if your device disconnect and reconnect, or if you reboot your computer. I assume this is what is happening here.

Unfortunately, Paperwork 1.3.1 isn’t really smart about that. If the exact device ID is not found, it doesn’t try to look for another device with a similar ID. So each time you open Paperwork, you have to open the settings first so it looks for scanners, and then you should be able to scan (… until the device ID changes again).

This issue has been fixed in what-will-be-Paperwork-2.0.

Best regards,

Hi Jerome, thanks for your reply and your work! I am really looking forward for Paperwork 2.0! :+1:

I’ve just freshly rebooted my system and as the first step after running flatpak run work.openpaper.Paperwork I’ve opened the settings. Unfortunately, nothing much happens here as well: The device dropdown names my scanner, but “default source” and “resolution” remain empty. The terminal throws:

INFO   paperwork.frontend.util.actions Action: [Open settings dialog]
/app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/util/__init__.py:163: Warning: g_value_type_transformable: assertion 'src_type' failed

(paperwork:3): Gtk-WARNING **: 18:23:55.005: gtkliststore.c:834: Unable to convert from (null) to gchararray
INFO   paperwork.frontend.settingswindow Language name translations loaded
INFO   paperwork.frontend.settingswindow Translation: German | Deutsch
INFO   paperwork.frontend.settingswindow Translation: English | Englisch
/app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/settingswindow/__init__.py:881: Warning: unable to set property 'xpad' of type 'guint' from value of type 'gchararray'
INFO   paperwork.frontend.util.jobs   [Scheduler progress] Starting
INFO   paperwork.frontend.util.jobs   [Scheduler progress] Started
/usr/lib/python3.7/site-packages/gi/overrides/GLib.py:497: Warning: unable to set property 'xpad' of type 'guint' from value of type 'gchararray'
super(MainLoop, self).run()
INFO   paperwork.frontend.settingswindow Looking for scan devices ...
INFO   paperwork.paperwork            ../subprojects/libinsane/src/bases/sane.c:L212(ensure_sane_is_init): Sane version code: 0x100001B
INFO   paperwork.paperwork            ../subprojects/libinsane/src/bases/sane.c:L311(lis_sane_list_devices): Sane: list_devices() ...
INFO   paperwork.paperwork            ../subprojects/libinsane/src/bases/sane.c:L364(lis_sane_list_devices): Sane: list_devices(): 1 devices found
INFO   paperwork.frontend.settingswindow Device found: [Brother ADS-2100e] -> [sane:net:127.0.0.1:brother4:bus3;dev2]
INFO   paperwork.frontend.settingswindow End of scan for device
INFO   paperwork.frontend.settingswindow Got value [['Brother ADS-2100e', 'sane:net:127.0.0.1:brother4:bus3;dev2']]
WARNING paperwork.frontend.util.jobs   Job DeviceFinder:0 took 8336ms and is unstoppable ! (maximum allowed: 500ms)
INFO   paperwork.frontend.settingswindow Selected scanner: sane:net:127.0.0.1:brother4:bus3;dev2
INFO   paperwork.frontend.settingswindow Looking for sources of device [sane:net:127.0.0.1:brother4:bus3;dev2]
INFO   paperwork.paperwork            ../subprojects/libinsane/src/bases/sane.c:L385(lis_sane_get_device): Sane: get_device(net:127.0.0.1:brother4:bus3;dev2) ...
ERROR  paperwork.paperwork            ../subprojects/libinsane/src/workarounds/cache.c:L568(cache_get_device): Failed to get_device(sane:net:127.0.0.1:brother4:bus3;dev2): 0x40000003, Invalid value
ERROR  paperwork.paperwork            ../subprojects/libinsane/src/normalizers/source_nodes.c:L442(lis_sn_get_device): wrapped->get_device() failed: 0x40000003, Invalid value
ERROR  paperwork.frontend.util.jobs   ===> Job SourceFinder:0 raised an exception: <class 'gi.repository.GLib.GError'>: libinsane-quark: Libinsane get devices error: 0x40000003, Invalid value (4)
ERROR  paperwork.frontend.util.jobs    0: /app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/util/jobs.py: L  180: _run
ERROR  paperwork.frontend.util.jobs    1: /app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/settingswindow/__init__.py: L  171: do
ERROR  paperwork.frontend.util.jobs   ---> Job SourceFinder:0 was started by:
ERROR  paperwork.frontend.util.jobs    0:   /app/bin/paperwork: L   11: <module>
ERROR  paperwork.frontend.util.jobs    1: /app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/paperwork.py: L  222: main
ERROR  paperwork.frontend.util.jobs    2: /app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/paperwork.py: L  210: main
ERROR  paperwork.frontend.util.jobs    3: /usr/lib/python3.7/site-packages/gi/overrides/GLib.py: L  497: run
INFO   paperwork.frontend.settingswindow Selected device: sane:net:127.0.0.1:brother4:bus3;dev2
ERROR  paperwork.frontend.util.jobs    4: /app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/settingswindow/__init__.py: L  558: _do
INFO   paperwork.frontend.settingswindow Selected source: 
ERROR  paperwork.frontend.util.jobs    5: /app/lib/python3.7/site-packages/paperwork-1.3.1-py3.7.egg/paperwork/frontend/util/jobs.py: L  256: schedule
INFO   paperwork.frontend.settingswindow Scanner sources: []

… and nothing more happens. Do you have any more ideas? :-/

INFO   paperwork.frontend.settingswindow Got value [['Brother ADS-2100e', 'sane:net:127.0.0.1:brother4:bus3;dev2']]
(...)
ERROR  paperwork.paperwork            ../subprojects/libinsane/src/workarounds/cache.c:L568(cache_get_device): Failed to get_device(sane:net:127.0.0.1:brother4:bus3;dev2): 0x40000003, Invalid value

Hm, so this is not simply the device ID changing.

My guess is that the problem is due to the use of the Sane Brother backend and the Sane backend net together (you have to use the Sane backend net since Flatpak runs applications in containers). Since the Brother backend is proprietary, I think this is close to impossible to debug.

What you can try is to install Paperwork without Flatpak (and therefore not usethe Sane backend net). By the way, Paperwork 1.3.1 is available in Debian testing: https://packages.debian.org/bullseye/paperwork-gtk .

That’s a good point. I’ve just installed Paperwork from the testing repositories, as you recommended. And I get a few steps further than with the flatpak. :slight_smile:

When opening the settings dialogue, Paperwork detects the scanner, the default source (“feeder (left-aligned)”) and sets the resolution (“300 (recommended)”). This didn’t work with the flatpak. :wink:

However, when I start the calibration scan, the popup

Error while scanning: Error while scanning: libinsane-quark: Libinsane opt[mode]->set_value() error: 0x400000003, Invalid value (4)

appears again. This is the terminal output: https://andwil.de/temp/paperworkdiag-2020-07-05.txt

Can you find anything useful in there? The basic issue still seems to be the same. :-/

Yes, it goes further. Now it fails to set the option mode. I suspect it can easily be fixed in Libinsane. I just need more information regarding your scanner.

Can you submit a scan test report using IronScanner please ?

Sound promising! I’ve just submitted the report: https://openpaper.work/de/scanner_db/report/458/

Thanks!

Good news: It’s fixed in Libinsane.

Bad news: This fix will cause a minor issue with scanners like the Brother MFC-7360N. The mode Color may appear twice in Paperwork settings. I’m going to fix it later.

Other bad news: For now, you must install and use the Libinsane fresh from Git. The easiest way for that is to uninstall Paperwork, and install it from the sources: https://gitlab.gnome.org/World/OpenPaperwork/paperwork/-/blob/master/doc/install.devel.markdown . Just so you know:

  • In the instructions, you can skip the git checkout develop command if you want Paperwork 1.3.1 and not 1.99.1
  • The commands in this doc will automatically fetch Libinsane from Git.
  • They will install Paperwork in ~/git/paperwork/venv so your system will remain clean (except for the apt install part, of course).
1 Like

That did the trick, thanks a lot for your time!

I don’t know much about patreon, but if you mail me your paypal address, I’d be happy to buy you a drink. :wink:

You’re welcome :slight_smile:

Patreon is about recurrent donations. For one-time payment, I agree that Paypal makes more sense. I guess I should add it on the website. Anyway my Paypal address is my email address: jflesch@openpaper.work .