RSS

Tag Archives: sane

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: , , , , , , , , , , ,

TP-Link TL-WR1043ND – Openwrt – Ch08_Photo_scanner_server

0) Briefing

  • To setup a service that I can remotely control my scanner and scan image directly to my computer.
  • The printer / scanner I am using is HP Deskjet F2280 All-in-one
  • You should have already done:
  • What next
    • Install sane-backends ( 9052 Byte in total )
      • Dependency : libjpeg libtiff libusb librt libv4l sane-libs zlib
    • Install sane-frontends ( 180 Byte in size )
    • Install HP printer/scanner library – hplip ( 6836 Byte in total )
      • Dependency : libpng libstdcpp cups
      • If you are not using HP, install something else.
    • Install xinetd for SANE ( 152 Byte in size )

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

1) Install SANE softwares

  • Open up your favorite terminal and login into the router
    ssh root@192.168.1.1
  • These commands will update database:
    opkg update
  • Install SANE, HP library and related files (16095 Byte in size), use other library if you are not using HP scanner:
    opkg install sane-backends sane-frontends hplip
  • Check if SANE can detect your scanner or not:
    scanimage -L
  • Should have similar result:

    device `hpaio:/usb/Deskjet_F2200_series?serial=CN88M4Q0Z40534′ is a Hewlett-Packard Deskjet_F2200_series all-in-one

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

2) Setup SANE as a network enable service

  • This part involve quite some effort to get SANE network enable. Personally, I think SANE in OpenWRT is not very complete. But don’t worry, all you need to do is to create and edit some config files.

2.1) Get around the check_host error in SANE

  • This is the most important step to get around the check host problem of SANE. You must get this done first. Otherwise even you got all the below settings right, you will still unable to get SANE work over the network.
    The problem is SANE wants to know the router own host name but SANE could not find it.
  • Edit the following file:
    vim /etc/host
  • Add the following line:

    192.168.1.1 OpenWRT

    IP_address = your_router_IP
    host_name = any_name_of_your_choice

2.2) Allow who can use your scanner from your network

  • Edit the following file:
    vim /etc/sane.d/saned.conf
  • To allow only a subnet of computers to use your scanner, add the following line:

    192.168.1.0/24

  • To allow all computer, add the following line, just a “+” sign:

    +

  • Start SANE in debug mode, so we can do some test after setting up the client software
    saned -d 128

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

3) Setup client side softwares

3.1) In Ubuntu:

  • Install the following software:
    sudo apt-get install sane-utils
  • If you also want graphical interface, install this as well:
    sudo apt-get install simple-scan
  • Edit the following file, to tell SANE where the network enabled scanner is:
    sudo vim /etc/sane.d/net.conf
  • Add the following line:

    192.168.1.1

  • We can test the connectivity from client to server now, from your computer:
    scanimage -L
  • On client side you should see this:

    device `net:192.168.3.1:hpaio:/usb/Deskjet_F2200_series?serial=CN88M4Q0Z40534′ is a Hewlett-Packard Deskjet_F2200_series all-in-one

  • On OpenWRT you should see similar result in saned debug output:

    [saned] check_host: access by remote host: 192.168.1.75
    [saned] init: access granted to mary@192.168.1.75
    [saned] bailing out, waiting for children…
    [saned] bail_out: all children exited

3.2) In Microsoft Windows

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

4) Set SANE as a daemon

  • SANE is setup now, but it will not startup by itself on boot, since SANE cannot set as a daemon in OpenWRT. So it has to be resided with xinetd.

4.1) Install xinetd

  • Install xinetd (extended Internet daemon) (152 Byte in size):
    opkg install xinetd

4.2) Config xinetd for SANE

4.2.1) Listening port

  • Check if SANE listening port is listed in /etc/service:
    cat /etc/service | grep sane
  • You should see the follow line, if not, add it to /etc/service

    sane-port    6566/tcp    sane saned

4.2.2) Add SANE to xinetd

  • Create folder /etc/xinetd.d and edit /etc/xinetd.d/sane by:
    mkdir /etc/xinetd.d && vim /etc/xinetd.d/sane
  • Add the following lines:

    service sane-port
    {
    disable        = no
    socket_type    = stream
    wait           = no
    user           = root
    group          = root
    server         = /usr/sbin/saned
    port           = 6566
    protocol       = tcp
    }

4.3) Start xinetd and set as service:

  • Enable xinetd to startup itself at boot, and start the service now:
    /etc/init.d/xinetd enable
    /etc/init.d/xinetd start

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

Appendix : References

 
4 Comments

Posted by on May 11, 2013 in Networking, Router

 

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

TP-Link TL-WR1043ND – Openwrt – Ch00_Introduction

Today, routers are very powerful electronics equipments, they are not just only routing data packages, giving out IPs or blocking unwanted connections anymore. Now they also can act as File Server or Printer server as well.

Of course, manufactures will not put every single function into one router, otherwise, how can they earn some big cash from you. That’s why there are third-party firmwares. These third-party firmwares are base on Linux, which able to provide endless choice of software for you to use. Dropbear for SSH. FTP, SFTP, Samba or NFS for file server. CUPS for print server. SANE for scanner. Asterisk for VoIP. And sound server, webcam server….. The only limitation is on the hardware itself.

There are 3 large camp on third-party firmwares: DD-WRT, OpenWRT and Tomato. Personally, I have never use Tomato, so I could not make any comment on that.

My experience with DD-WRT is with my TP-Link TL-WR741ND. Which I have one in Hong Kong as my pptp VPN server. 741ND + DD-WRT is a bullet prove combination. I use it many hours everyday with huge data flow for 2 years now.

However, there are limitations. 1) 741ND don’t have USB port, which I can’t use it for file and printer/scanner server. 2) 741ND only have 4MB ROM memory, which left no space for anyone to install extra softwares. 3) The difficulty of setting up a DD-WRT.

Performance wise, I would not say DD-WRT will have to much different compare to OpenWRT, since they are both just Linux base, the different would not be huge. However, the simplicity of setup procedure with OpenWRT, definitely makes it a winner.

As I said before, 741ND lack a USB port, which is not going to be my next new toy. However, if you don’t need to use USB. I would say 741ND is the only choice you should have. And it is dirt cheap as well, less than USD$20 in Hong Kong.

My new toy would be TP-Link TL-WR1043ND. It cost just over USD$55, which cost much more than 741ND. But it come with big guns: Giga-byte LAN ports, 3 antennae, a much faster processor and a USB port.

My new setup, will be a PPTP+OpenVPN VPN servers, printer server, scanner server and a Samba file server.

 
Leave a comment

Posted by on April 11, 2013 in Networking, Router

 

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

Network image scanning

If you have only one scanner but many computers, what is the easiest way to share it? Connect it to one computer and set that computer to be a server, then control the scanner over the network.

<—– Server Side —–>
First, make sure your scanner is working on the server computer. If you are using a USB scanner like me, just connect and preform a scan on the server to make sure it is working. In Ubuntu, Simple Scan is the default program, and it is the best scanning software I think.

Install the required software on the server:

sudo apt-get install sane-utils

Edit /etc/default/saned, to set sane to run as server:

# Set to yes to start saned                                                     
RUN=yes

Edit /etc/sane.d/saned.conf, add the following line to set which subnet you would like to share to:

192.168.1.0/24

Add the saned user to the lp group so it can access the scanner:

sudo adduser saned lp

Restart the saned daemon:

sudo service saned restart

Run the following command and make sure your scanner is installed:

$ scanimage -L

<—– Client Side —–>
Install the required software on the client:

sudo apt-get install sane-utils

Edit /etc/sane.d/net.conf, tell the client where the server is

## saned hosts
# Each line names a host to attach to.
# If you list "localhost" then your backends can be accessed either
# directly or through the net backend.  Going through the net backend
# may be necessary to access devices that need special privileges.
# localhost
192.168.1.1

Confirm settings:

$ scanimage -L

Open Simple Scan and test scan.

References:

https://help.ubuntu.com/community/ScanningHowTo
http://ubuntuforums.org/showthread.php?t=1519201

 
Leave a comment

Posted by on December 31, 2012 in Linux, Networking

 

Tags: , , , , ,

 
%d bloggers like this: