RSS

Tag Archives: scanimage

TP-Link TL-WR1043ND – Openwrt – Ch09_Buttons

0) Briefing

  • As my Scan Button on my scanner is not working with OpenWRT/Linux, I am going to use the QSS button on my TP-Link TL-WR1043ND to act as my scan button.
    When I press the QSS button, OpenWRT will instruct my scanner to scan an image, save it to the share folder, so I can access it through Samba.
  • The printer / scanner I am using is HP Deskjet F2280 All-in-one
  • You should have already done:
  • What next
    • Just need to add and edit some config files

——————————————————————————–

1) Button handler script – for TP-Link 1043ND

  • If you are using other router, you may need other script, check it yourself.
  • Add the following folder and edit the sript:
    mkdir /etc/hotplug.d/button && vim /etc/hotplug.d/button/00-button
  • Add the following lines to the script:

    #!/bin/sh
    . /lib/functions.sh
    do_button () {
    local button
    local action
    local handler
    local min
    local max

    config_get button $1 button
    config_get action $1 action
    config_get handler $1 handler
    config_get min $1 min
    config_get max $1 max

    [ “$ACTION” = “$action” -a “$BUTTON” = “$button” -a -n “$handler” ] && {
    [ -z “$min” -o -z “$max” ] && eval $handler
    [ -n “$min” -a -n “$max” ] && {
    [ $min -le $SEEN -a $max -ge $SEEN ] && eval $handler
    }
    }
    }

    config_load system
    config_foreach do_button button

——————————————————————————–

2) Tell the system what to do when button pressed

  • Execute the following commands:
    uci add system button    
    uci set system.@button[-1].button=wps
    uci set system.@button[-1].action=pressed
    uci set system.@button[-1].handler='logger Shit things happen'
    uci commit system
  • Press the button, you should see “Shit things happen” when you read system log by:
    logread
  • If your button is working, set it to work with SANE when pressed:
    uci set system.@button[-1].handler='scanimage --format=tiff --mode Gray --resolution 300 > /mnt/shares/public/$(date +"%Y%m%d-%H%M%S").tiff'
    uci commit system

——————————————————————————–

Appendix : References

Advertisements
 
Leave a comment

Posted by on May 12, 2013 in Networking, Router

 

Tags: , , , , , , , , , , ,

 
%d bloggers like this: