📜 ⬆️ ⬇️

Network scanning is easy

This article is for dummies on how to set up scanning images over a network using an Asus WL-500gpv2 router, Samsung SCX-4220 multifunction printer, and Windows. With pictures.
I will tell on the example of firmware OpenWrt Backfire 10.03.1-rc5. It differs from Oleg's famous firmware by the possibility of more detailed software setup and the ability to manage packages from the web interface.
The list of equipment compatible with the firmware here .
This instruction is most likely suitable for any router from this table, which has at least 8mb of flash memory and at least 32mb of operational memory.

Firmware

Download it here .
The method of firmware may vary depending on the model of the router. This instruction is for routers like mine.
Install the firmware using the utility to restore the firmware from asus .
  1. We connect the router to the computer via Ethernet (via any of the lan-ports)
  2. We put the router into recovery mode - turn off the power of the router, hold down the Reset / Restore button, turn on the power, hold the button until the power indicator starts blinking
  3. No configuration of ip-addresses is necessary, unless you assign the address from 192.168.1.0/255.255.255.0 to a computer other than 192.168.1.1, and run the ping on 192.168.1.1
  4. Run the program Firmware Restoration, disable the firewall (the program asks for it), select the firmware file with the extension .trx


  5. We are waiting for a couple of minutes until the router appears at 192.168.1.1


Scan and Print Setup

First of all we change the password of the router:
')


Configuring Internet access:



We configure the DHCP server, and we change the address if it does not suit 192.168.1.1. I change it to 192.168.11.1, in the future all settings will be to this address:



Scanning


Next, go to the package configuration.


Click Update package lists (if you want to put a package, this operation should be done every time the router is restarted), look for through the Filter field and put the packages:
  1. nano - more friendly than vi, editor
  2. sane-backends, sane-frontends
  3. xinetd - for network access
  4. kmod-usb-printer, kmod-usb-ohci, kmod-usb-uhci, kmod-usb2, kmod-usb-storage - support for various USB-devices at the kernel level

Reboot the router.

Connect to the router via ssh .
The sane-find-scanner should output something like the following:
found USB scanner (vendor=0x04e8 [Samsung], product=0x341b [SCX-4200 Series]) at libusb:001:004
# Your USB scanner was (probably) detected. It may or may not be supported by
# SANE. Try scanimage -L and read the backend's manpage.

# Not checking for parallel port scanners.

# Most Scanners connected to the parallel port or other proprietary ports
# can't be detected by this program.

Notice the values vendor=0x04e8 , product=0x341b , libusb:001:004 , we need them.

Now, either you are lucky or you have to make additional settings.
I was not lucky:
root@OpenWrt:~# scanimage -L

No scanners were identified. If you were expecting something different,
check that the scanner is plugged in, turned on and detected by the
sane-find-scanner tool (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).


Here you can find out which scanner model corresponds to which model of backend. Samsung SCX-4220 complies with backend sane-xerox_mfp.5 .
Here you can see the manual, from which it is clear that the config is in the file /etc/sane.d/xerox_mfp.conf
We edit it:

nano /etc/sane.d/xerox_mfp.conf

Add a line to the file

usb 0x04e8 0x341b

and, just in case, this line, as advised in the forums

usb libusb:001:004

The version of backends in this firmware is 1.0.20, and, interestingly, when using the latest version (it seems 1.0.22, kernel version 2.6), which I installed on the firmware from Oleg, the scanner was never defined by me. I also met a description of this situation on the forums, so I chose the firmware with the 2.4 kernel version.

Save the file, check:

root@OpenWrt:~# scanimage –L
device `xerox_mfp:libusb:001:004' is a SAMSUNG ORION multi-function peripheral


The scanner is determined, all is well.

Now set up network access:

nano /etc/sane.d/saned.conf

Add a line to the file 192.168.11.0/24 (you must specify the subnet of your router)

nano /etc/xinetd.conf

Add the following lines to the file:

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


Run xinetd in debug information output mode:

root@OpenWrt:~# xinetd -d
Service defaults
Bind = All addresses.
Only from: All sites
No access: No blocked sites
No logging

Service configuration: saned
id = saned
flags = IPv4
socket_type = stream
Protocol (name,number) = (tcp,6)
port = 6566
wait = no
user = 0
group = 0
Groups = no
PER_SOURCE = -1
Bind = All addresses.
Server = /usr/sbin/saned
Server argv = saned
Only from: All sites
No access: No blocked sites
No logging

11/9/2@07:43:31: DEBUG: 29656 {cnf_start_services} Started service: saned
11/9/2@07:43:31: DEBUG: 29656 {cnf_start_services} mask_max = 6, services_started = 1
11/9/2@07:43:31: NOTICE: 29656 {main} xinetd Version 2.3.14 started with loadavg options compiled in.
11/9/2@07:43:31: NOTICE: 29656 {main} Started working: 1 available service
11/9/2@07:43:31: DEBUG: 29656 {main_loop} active_services = 1


As you can see, the service is running.

If the service does not start, check that the / etc / services file has the line saned 6566 , and if it is missing, add it.

Now download and install SaneTwain
The archive instruction and 2 files - sanetwain.ds and scanimage.exe
Run scanimage.exe , specify the address of the router in the settings:

restart scanimage.exe :


Why a mistake?

Check out the syslog entries in the web interface:
Sep 2 07:59:19 OpenWrt daemon.debug saned[31278]: saned (AF-indep+IPv6) from sane-backends 1.0.20 starting up
Sep 2 07:59:19 OpenWrt daemon.debug saned[31278]: check_host: access by remote host: 192.168.11.139
Sep 2 07:59:19 OpenWrt daemon.debug saned[31278]: check_host: getaddrinfo for local hostname failed: Name or service not known
Sep 2 08:02:52 OpenWrt daemon.warn xinetd[29722]: Exiting...


By searching the forums, we find out that in this situation it all works, we need to add an entry in the hosts with the name for the router's address:

root@OpenWrt:~# nano /etc/hosts

Add a line:

192.168.11.1 OpenWrt

Restart xinetd:

killall xinetd
xinetd


Restart scanimage.exe (it's buggy, maybe, only from the second time everything will be ok)


We see that everything works. Hooray.

Now you need to enable xinetd autorun in the web interface of the router:


Restart the router, check the work again.

Now copy the second file, sanetwain.ds , to the C: \ Windows \ twain_32 \ directory.
After that, in programs with twain support, you can use the scanner, including the wonderful Screenshot Captor program for creating screenshots:


Print

Now set up printing over the network:
Install the luci-app-p910nd package.

Make the following settings in the web interface of the router:



Make sure that the server starts when the router is restarted:



and the fact that it really started:

root@OpenWrt:~# ps|grep p9100
32079 root 680 S /usr/sbin/p9100d -b -f /dev/usb/lp0 0


Set up the printer:



Click "Test Print", hooray!
Printing over the network on all the firmware I watched was configured without problems, so I am sure that you will not have problems either.

Free up space on the router for other programs.

Connect via ssh.
The idea is to remove unnecessary us backends.
backends are in the / usr / lib / sane / folder
As you can see from man , our backend files are libsane-xerox_mfp.so.1 and libsane-xerox_mfp.so.1.0.20
Accordingly, if you do not plan to connect another scanner, all the rest can be removed without fail, which will release
root@OpenWrt:/usr/lib/sane# cd /usr/lib/sane/
root@OpenWrt:/usr/lib/sane# du -m
7 .

About 3.5 MB! Why 3.5 and not 7? Because in this directory exactly half of the files are symbolic links to libraries located in the same directory.

The removal method is not the most elegant, but, nevertheless, effective (install not offer mc, there is no place for it):
root@OpenWrt:/usr/lib/sane# rm libsane-a*
root@OpenWrt:/usr/lib/sane# rm libsane-b*
root@OpenWrt:/usr/lib/sane# rm libsane-c*
root@OpenWrt:/usr/lib/sane# rm libsane-d*
root@OpenWrt:/usr/lib/sane# rm libsane-e*
root@OpenWrt:/usr/lib/sane# rm libsane-f*
root@OpenWrt:/usr/lib/sane# rm libsane-g*
root@OpenWrt:/usr/lib/sane# rm libsane-h*
root@OpenWrt:/usr/lib/sane# rm libsane-i*
root@OpenWrt:/usr/lib/sane# rm libsane-j*
rm: cannot remove 'libsane-j*': No such file or directory
root@OpenWrt:/usr/lib/sane# rm libsane-k*
rm: cannot remove 'libsane-k*': No such file or directory
root@OpenWrt:/usr/lib/sane# rm libsane-l*
root@OpenWrt:/usr/lib/sane# rm libsane-m*
root@OpenWrt:/usr/lib/sane# rm libsane-n*
root@OpenWrt:/usr/lib/sane# rm libsane-o*
rm: cannot remove 'libsane-o*': No such file or directory
root@OpenWrt:/usr/lib/sane# rm libsane-p*
root@OpenWrt:/usr/lib/sane# rm libsane-q*
root@OpenWrt:/usr/lib/sane# rm libsane-r*
root@OpenWrt:/usr/lib/sane# rm libsane-s*
root@OpenWrt:/usr/lib/sane# rm libsane-t*
root@OpenWrt:/usr/lib/sane# rm libsane-u*
root@OpenWrt:/usr/lib/sane# rm libsane-v*
rm: cannot remove 'libsane-v*': No such file or directory
root@OpenWrt:/usr/lib/sane# rm libsane-w*
rm: cannot remove 'libsane-w*': No such file or directory


The main thing - do not get carried away, and not kill what needs to be left

Now the result is clear - to:



and after:



Editing the file
root@OpenWrt:/usr/lib/sane# nano /etc/sane.d/dll.conf

comment # all-lines not related to our backend (all but xerox_mfp )

Now, scanimage runs faster (it does not waste time initializing all the backends), and there is enough space to install other necessary services.

PS
On the wl500g.info forum, I read the comments that the scanner in such a connection is slower than being directly connected to the computer.

Let's check ... We scan A4 sheet in color in different resolutions.

600dpi through a router (wifi, while watching a video on youtube at 720p) 4min 16sec, directly 1min 47sec (through a router it is actually 2.5 times slower);
300 dpi through a 62sec router, directly 31sec;
150dpi through a 20sec router, directly 15sec (here the difference is quite small)

Basically, 150 dpi is enough to illustrate A4 documents or text recognition. In a situation where one scanner for several people and the scan volumes are small, it’s quite a solution.
In a situation where high resolutions are needed with large volumes of scanning, such a solution, of course, will not work ...

Pps
Note that we managed to do everything without connecting flash drives, mounting swap and other tricks like / opt, and there was only one unused USB port in the router.

Source: https://habr.com/ru/post/127739/


All Articles