OpenWrt Forum Archive

Topic: how to capture usb scanner button?

The content of this topic has been archived between 23 Apr 2018 and 4 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Hello, I found several tutorials, how to control scanner from openwrt terminal or from web gui, seems doable, but I'd like to make idiot proof scanning solution with low power consumption, which would require put paper into scanner and press one of the buttons on the scanner, simple like fax.

What I don't know is how to detect the event, that some of the scanner buttons has been pressed on the usb scanner. Is it possible at all? Could someone please tell me?

The background for anyone, whos interested:

I have some old canon usb scanner and I need wifi router (as client) to get connectivity to the workplace at the store, so I was thinking about buying cheap tp link wr842nd which has 8MB flash+usb and using this old scanner.

The goal is to scan papers to the ftp instead of faxing them out, then scanning on the other side and saving them to ftp. It should be easy for store workes, who are masters at driving a forklift, but don't know anyhing about computers and computer is not needed there anyway.

Probably not possible, but if the router has a WPS button, you could configure that to start the scanner (assuming the scanner is supported under Linux in the first place).

Maybe possible, assuming your scanner is an usb device with HID buttons.

- Install kmod-usb-hid
- Install triggerhappy
- Restart the router
- follow http://wiki.openwrt.org/doc/howto/hardw … iggerhappy

If possible your scanner button should be mapped to /dev/input/event

Thank you, guys! The wps button seems like a great idea, should be easy, because it is supported in openwrt directly smile But I will look into the HID solution first, because the wps button probably would not last long wink

Hello, I found that HID buttons don't work with scanner sad But I found something else for linux - scanbuttond: http://scanbuttond.sourceforge.net/ Is it possible to port this to openwrt somehow (if it is not too heavy)?

I could probably still use reset/wps button for scanning, but I don't think the button is capable of surviving several clicks daily smile

(Last edited by nozombian on 19 Jun 2013, 14:58)

Not sure if scanbuttond would detect anything since it's just a daemon like triggerhappy.

Might be more modules are needed for HID buttons, might be polled buttons. Install these modules and give it another try

kmod-input-gpio-keys-polled
kmod-input-polldev

kmod-input-gpio-keys-polled shouldn't be needed but doesn't hurt.

Thank you, I tried them too, but I still don't have no /dev/input at the first place. Maybe I'm missing something? I coud test periodicaly some event myself, if I'd known which, but I have all the packages you suggested installed and no /dev/input to monitor.

root@wr842nd:~# lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 03f0:0a01 Hewlett-Packard ScanJet 2400c

root@wr842nd:~# sane-find-scanner
found USB scanner (vendor=0x03f0 [Hewlett-Packard], product=0x0a01 [hp scanjet scanner], chip=GL646_HP) at libusb:001:004

root@wr842nd:~# thd --dump /dev/input/event*
Error opening '/dev/input/event*': No such file or directory

(Last edited by nozombian on 20 Jun 2013, 07:08)

Try to connect another usb device, mouse or keyboard USB, and look at /dev/input/event again. If triggerhappy is able to work with the mouse buttons then all is ok and your scanner button cannot be mapped to /dev/input/event.

I've packages scanbuttond for openwrt: http://patchwork.openwrt.org/patch/3380/
My epson scanner attached to an wrt843n works fine. Your HP scanner (0x03f0, 0x0a01) is expected to work.

Kind regards,

syssi

(Last edited by syssi on 20 Jun 2013, 14:14)

danitool wrote:

Try to connect another usb device, mouse or keyboard USB, and look at /dev/input/event again. If triggerhappy is able to work with the mouse buttons then all is ok and your scanner button cannot be mapped to /dev/input/event.

Keyboard is working fine, so scanner is probably not an HID device sad Thank you for your kind help anyway.

syssi wrote:

I've packages scanbuttond for openwrt: http://patchwork.openwrt.org/patch/3380/
My epson scanner attached to an wrt843n works fine. Your HP scanner (0x03f0, 0x0a01) is expected to work.

Kind regards,

syssi

That's great syssi, thank you, but I have absolutely no idea what to do with your patch smile I can compile openwrt, configure something here and there, but I'm not a guru, just an user sad

If you or someone could point me to the right direction, maybe I'll be able to handle that wink Thanks!

This may help you:

- download http://patchwork.openwrt.org/patch/3380/raw/ to your build root
- apply the patch opening a terminal console in your buld root

patch -p0 -i OpenWrt-Devel-new-package---scanbuttond-resent.patch

- make menuconfig an select the package scanbuttond
- build your firmware

Good news about this app, probably I'll add info in the wiki to
http://wiki.openwrt.org/doc/howto/hardware.button
But I prefer someone testing the app write about it in the wiki.

danitool wrote:

This may help you:

- download http://patchwork.openwrt.org/patch/3380/raw/ to your build root
- apply the patch opening a terminal console in your buld root

patch -p0 -i OpenWrt-Devel-new-package---scanbuttond-resent.patch

I wonder how you managed to use the above instruction to apply the downloaded patched file without error messages. When I tried your suggestion above, I got the following error messages:

sh-4.2$ patch -p0 -i ~/Downloads/OpenWrt-Devel-new-package---scanbuttond-resent.patch
patching file feeds/packages/utils/scanbuttond/patches/debian-0.2.3.cvs20090713-9.patch
patch: **** malformed patch at line 1339: ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'

sh-4.2$

I didn't, it's just a suggestion. The patch seems messed, so manual corrections will be needed.

danitool wrote:

I didn't, it's just a suggestion. The patch seems messed, so manual corrections will be needed.

Please kindly indicate so on your post.

Thank you, but if it does not work, I second that please wink

(Last edited by nozombian on 20 Jun 2013, 21:08)

The patch was borked (not my fault). It containded some broken lines. I fixed it, download this new one:

- download https://files.myopera.com/danitool/open … -patch.zip and uncompress to your build root
- apply the patch opening a terminal console in your buld root

patch -p0 -i OpenWrt-Devel-new-package---scanbuttond-resent.patch

- execute these commands

./scripts/feeds update -a
./scripts/feeds install scanbuttond

- make menuconfig an select the package scanbuttond under utils
- build your firmware

Thank you.

That's perfect, man! Thank you. Patch worked, I'm compiling now...

Scanbuttond seems to be running after restart, so I killed it, created /etc/scanbuttond/buttonpressed.sh, chmod 755ed it, run scanbuttond -f to see what's happening, but pressed keys still do nothing sad

From what I understood so far, scanbuttond schould periodically check usb scanner and look for pressed keys. But USB led is not blinking, when scanbuttond is running. It should blink, if scanbuttond communicated with scanner, right? So what I'm missing yet?

Btw. SANE is scanning quite fine (more than 100dpi causes scanner to malfuction, but 100dpi is sufficient) and when scanimage is running, usb led blinks. But I have to invoke it by wps button, which is not useable for everyday use.

syssi wrote:

I've packages scanbuttond for openwrt: http://patchwork.openwrt.org/patch/3380/
My epson scanner attached to an wrt843n works fine. Your HP scanner (0x03f0, 0x0a01) is expected to work.

Kind regards,

syssi

I didn't find  the ID 0x03f0, 0x0a01 in the scanbuttond source code, then Hewlett-Packard ScanJet 2400c scanners aren't supported unless someone patch the code to support them

Ic, thank you very much for help. Looks like I'm running out of luck here neutral

So I will have to buy usb hub+mouse for adittional ~$6 and hope, that it will be possible to capture mouse button wink

kmod-hid-generic must be selected for buttons on USB devices to work on trunk, at least it helped me use the buttons on my USB sound card.

Thanks, I will try it. Now it is solved using old mouse with broken wheel and usb hub and instead of ftp it is done via email. But it works at about 90%, sometimes it sends empty (zero bytes) page for unknown reasons, but it is useable.

danitool wrote:

The patch was borked (not my fault). It containded some broken lines. I fixed it, download this new one:

- download https://files.myopera.com/danitool/open … -patch.zip and uncompress to your build root

Anyone still have this patch?

(Last edited by ujin on 15 Dec 2015, 07:21)

ujin wrote:
danitool wrote:

The patch was borked (not my fault). It containded some broken lines. I fixed it, download this new one:

- download https://files.myopera.com/danitool/open … -patch.zip and uncompress to your build root

Anyone still have this patch?

You may want to read this and contact the poster about his/her scanbuttond package. Once you get it, please kindly post here.