OpenWRT+SANE实现远程扫描
工作平台:
客户端 Win7 x64
服务器端 Netgear WNDR3700+Canon Pixma MP280
搬家的时候捡了台打印扫描一体机,因为路由器放在客厅所以想把打印机接在路由上面,这样电脑就可以实现无线扫描和打印了。
开始路由器上面刷的是OpenWRT 12.09 (Attitude Adjustment),但是因为12.09里面带的libsane是1.0.22的,而Canon MP280要在最新的1.0.23里面才能支持,所以刷了snapshot的版本。
在http://www.sane-project.org/sane-supported-devices.html里面可以看到最新版本(1.0.23)对于扫描仪的支持情况。
注意:因为libsane无法装在路由器里面(空间不足),需要一个usb hub+闪存盘来装这些软件。
以下命令都以最新的snapshot版本为基准,在稳定版(12.09)上的操作略有不同。
首先需要设置extroot:
opkg update
opkg install kmod-usb2 block-mount kmod-fs-ext4 e2fsprogs
以上命令安装路由对闪存盘的支持。然后插上闪存盘,执行
mkfs.ext3 /dev/sda1
假设闪存盘是在/dev/sda1。
mkdir -p /mnt/sda1
mount -t ext3 /dev/sda1 /mnt/sda1
tar -C /overlay -cvf - . | tar -C /mnt/sda1 -xf -
由于最新的Barrier Breaker里面没有fstab包而改用了ubox,所以需要手工创建fstab:
block detect > /etc/config/fstab
然后修改里面的config段类似如下:
config mount option target /overlay option uuid aaaabbbb-ccdd-eeff-aaaabbbbcccc option device /dev/sda1 option fstype ext3 option options rw,sync option enabled 1 option enabled_fsck 0
reboot之后用df -h查看可用空间,应该接近闪存盘的大小了。
然后安装扫描仪支持:
opkg update
opkg install sane-backends sane-frontends xinetd
装完之后执行:
sane-find-scanner
如果出现类似以下输出:
# sane-find-scanner will now attempt to detect your scanner. If the # result is different from what you expected, first make sure your # scanner is powered up and properly connected to your computer. # No SCSI scanners found. If you expected something different, make sure that # you have loaded a kernel SCSI driver for your SCSI adapter. # Also you need support for SCSI Generic (sg) in your operating system. # If using Linux, try "modprobe sg". found USB scanner (vendor=0x04a9 [Canon], product=0x1746 [MP280 series]) at libusb:001:003 # 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.
则说明至少部分检测到了扫描仪。否则……还是等sane的更新吧。
然后执行scanimage确认检测到扫描仪:
scanimage -L
应该有类似如下输出:
device `pixma:04A91746_226D25' is a CANON Canon PIXMA MP280 multi-function peripheral
说明检测扫描仪成功。接下来修改/etc/sane.d/saned.conf限制客户端范围,在ip段里面加入192.168.1.1/24。
然后修改/etc/services加入
sane-port 6566/tcp
创建/etc/xinetd.d/sane:
service sane-port { socket_type = stream server = /usr/sbin/saned protocol = tcp user = root group = root wait = no disable = no }
建立saned服务。最后
/etc/init.d/xinetd start
/etc/init.d/xinetd enable
开机时启动xinetd。
Windows上的客户端推荐使用saneTwain (http://sanetwain.ozuzo.net/),虽然作者说这个在x64下不工作,但是我在Win7 x64上使用没有问题。这个的设置非常直观,第一次打开时设置设备,ip填路由ip,其余保持默认即可。
参考: