Raspberry Pi
scanbd (Raspbian)로 스캔 스테이션 만들기
수색…
소개 및 설치
이 문서의 목적은 사용자 인터페이스없이 스캐너를 사용하는 것입니다. 일반적으로 스캐너 버튼을 눌러 PDF 스캔 파일을 Google 드라이브 또는 보관 용 계정에 직접 업로드하는 것이 일반적입니다.
scanbd는 스캐너 버튼에서 작업을 트리거 할 수 있도록 허용합니다.
스캐너를 폴링하면 scanbd가 장치를 잠급니다. scanimage와 같은 로컬 도구에서 스캔해야하기 때문에 필요한 경우 폴링에서 scandb를 인터럽트하는 프록시를 설정해야합니다. 이것은 네트워크를 모니터하고 스캐너에 대한 로컬 액세스에 대한 scanbd보다 우선 순위를 부여하는 scanbm의 작업입니다.
따라서 다음을 수행해야합니다.
- 네트워크에서 스캔 만하도록 로컬 sane 구성을 설정합니다 (scanbm을 통해).
- 액세스 권한을 갖고 로컬 스캐너를 폴링하도록 scanbd 구성
루트 로서 :
apt-get update
apt-get install libconfuse-dev libsane-dev libudev-dev libusb-dev xinetd
최신 버전의 scanbd는 다음에서 찾을 수 있습니다. https://sourceforge.net/projects/scanbd/files/releases/
# Download the latest version of **scanbd**.
wget https://sourceforge.net/projects/scanbd/files/releases/scanbd-1.4.4.tgz/download
# Uncompress
tar xvzf scanbd-1.4.4.tgz && cd 1.4.4
# Configure with the installation path in /etc/
./configure --disable-Werror
# install it
make
make install
# Add a dbus policy to authorize "saned" user to manage scanbd :
cp integration/scanbd_dbus.conf /etc/dbus-1/system.d/
# Add the init script to manage the daemon :
cp integration/scanbd.debian /etc/init.d/scanbd
scanbd 가 설치되었지만 아직 구성되지 않았습니다.
네트워크에서 스캔 할 수 있도록 구성
sane의 로컬 구성은 /etc/saned.d 안에 /etc/saned.d
/etc/sane.d/dll.conf
# /etc/sane.d/dll.conf - Configuration file for the SANE dynamic backend loader
#
# Backends can also be enabled by configuration snippets under
# /etc/sane.d/dll.d directory -- packages providing backends should drop
# a config file similar to dll.conf in this directory, named after the package.
#
# The next line enables the network backend; comment it out if you don't need
# to use a remote SANE scanner over the network - see sane-net(5) and saned(8)
net
dll.conf 에는 net 백엔드 만 있습니다.
/etc/sane.d/net.conf :
# This is the net backend config file.
## net backend options
# Timeout for the initial connection to saned. This will prevent the backend
# from blocking for several minutes trying to connect to an unresponsive
# saned host (network outage, host down, ...). Value in seconds.
connect_timeout = 3
## 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
이 시점에서 scanbm 은 아직 구성되지 않았으므로 네트워크에서 스캐너에 연결할 수 없습니다. 설정을 테스트하려면 scanbd와 함께 scanbm을 설정해야합니다.
로컬 스캐너를 폴링하도록 scanbd 구성
로컬 스캐너 확인
lsusb를 사용하여 productId (여기서 1909)를 식별하십시오.
pi:# lsusb
pi:# Bus 001 Device 005: ID 04a9:1909 Canon, Inc. CanoScan LiDE 110
해당 productId를 사용하여 grep 올바른 구성 파일 (스캐너 모델에 따라 다릅니다. 나를 위해 genesys.conf입니다 ).
pi:# grep 1909 /etc/sane.d/*conf
pi:# /etc/sane.d/genesys.conf:usb 0x04a9 0x1909
scanbd 구성 폴더 내에 파일 복사 :
cp /etc/sane.d/genesys.conf /usr/local/etc/scanbd/
cp /etc/sane.d/dll.conf /usr/local/etc/scanbd/
/usr/local/etc/scanbd/dll.conf를 편집하고 net 을 올바른 스캐너 백엔드로 바꿉니다.
# /etc/sane.d/dll.conf - Configuration file for the SANE dynamic backend loader
#
# Backends can also be enabled by configuration snippets under
# /etc/sane.d/dll.d directory -- packages providing backends should drop
# a config file similar to dll.conf in this directory, named after the package.
#
# The next line enables the network backend; comment it out if you don't need
# to use a remote SANE scanner over the network - see sane-net(5) and saned(8)
genesys
scanbd가 로컬 스캐너를 찾았는지 확인합니다.
이제 우리는 테스트 할 준비가되었습니다 :
scanbd -d7 -f
env var SANE_CONFIG_DIR을 조작 할 수있는만큼 피해주십시오. 그것은 문제를 일으킬 수 있습니다. 기본값은 /usr/local/etc/scanbd/scanbd.conf와 init 스크립트에 이미 설정되어 있습니다.
출력은 다음과 유사해야합니다.
scanbd: foreground
scanbd: reading config file /usr/local/etc/scanbd/scanbd.conf
scanbd: debug on: level: 7
scanbd: dropping privs to uid saned
scanbd: dropping privs to gid scanner
scanbd: group scanner has member:
scanbd: saned
scanbd: pi
scanbd: drop privileges to gid: 110
scanbd: Running as effective gid 110
scanbd: drop privileges to uid: 110
scanbd: Running as effective uid 110
scanbd: dbus_init
scanbd: dbus match type='signal',interface='org.freedesktop.Hal.Manager'
scanbd: SANE_CONFIG_DIR=/usr/local/etc/scanbd/sane.d
scanbd: sane version 1.0
scanbd: Scanning for local-only devices
scanbd: found device: genesys:libusb:001:005 Canon LiDE 110 flatbed scanner
여기에서 가장 중요한 것은 found device 입니다.
'찾은 기기'가 표시되지 않으면 어떻게해야하나요?
구성, 특히이 설명서의 식별 부분을 다시 확인하고 다음을 입력하여 잘못된 SANE_CONFIG_DIR 환경 변수를 지워야합니다.
unset SANE_CONFIG_DIR
네트워크에서 scanbm 수신 대기하도록 xinetd 구성
/etc/xinetd.d/sane-port 를 작성하십시오.
service sane-port
{
port = 6566
socket_type = stream
wait = no
user = saned
group = scanner
server = /usr/local/sbin/scanbm
server_args = scanbm -c /usr/local/etc/scanbd/scanbd.conf
disable = no
}
/! \ scanbm 의 경로를 double-check하여
which scanbm
그런 다음 xinetd를 다시 시작하고 scanbd를 시작 하십시오 .
service xinetd restart
/etc/init.d/scanbd start
이제 scanimage -L 이 스캐너를 표시해야합니다.
이 단계의 대부분의 문제는 사용 권한과 관련이 있습니다.
sudo -u saned -s를 실행하여 saned로 로그 할 때scanimage -L작동하는지 확인하십시오.그렇지 않다면 USB 사용 권한을 확인하십시오 :
ls -al /dev/bus/usb/***
스캐너 버튼에서 동작 트리거
작업은 /usr/local/etc/scanbd/scanbd.conf 있습니다. 나는 스캔 , 복사 , 이메일 및 파일 인 4 개의 버튼을 가지고있다.
기본 구성 파일에는 기본 동작이 모두 포함되어 있지 않으므로 수동으로 블록을 추가해야 할 수 있습니다. 스캐너 모델에 따라 더 적거나 많은 버튼을 가질 수 있습니다.
각 작업에 대해 스크립트 옵션에 대한 사용자 지정 경로를 설정합니다.
action scan {
filter = "^scan.*"
numerical-trigger {
from-value = 1
to-value = 0
}
desc = "Scan to file"
# script must be an relative path starting from scriptdir (see above),
# or an absolute pathname.
# It must contain the path to the action script without arguments
# Absolute path example: script = "/some/path/foo.script
script = "/home/pi/scan.sh"
}
scanbd.conf 끝에서 다른 기본 동작을 주석 처리하는 것을 잊지 마십시오.
# devices
# each device can have actions and functions, you can disable not relevant devices
#include(scanner.d/avision.conf)
#include(scanner.d/fujitsu.conf)
#include(scanner.d/hp.conf)
#include(scanner.d/pixma.conf)
#include(scanner.d/snapscan.conf)
#include(scanner.d/canon.conf)
이제 사용자 지정 스크립트를 만들어 각 동작을 처리 할 수 있습니다.
/sys/class/leds/led0/trigger기준으로 한 각 행은 진행 상황을 모니터하기 위해 LED를 제어하기위한 것입니다.cat /sys/class/leds/led0/trigger는 여러분이 원하는 모든 것을 할 수 있습니다.
/home/pi/scan.sh
#!/bin/bash
# don't forget to create the folder
scan_dir=/home/pi/scanned-files
datetime=`date +%F_%H%M%S`
echo none >/sys/class/leds/led0/trigger
case $SCANBD_ACTION in
scan)
filename=file-$datetime
logger -t "scanbd: $0" "$SCANBD_DEVICE $SCANBD_ACTION - scanning --resolution 150 --mode Color --depth 8 --format=tiff to $scan_dir/$filename.jpg"
echo timer >/sys/class/leds/led0/trigger
scanimage -d $SCANBD_DEVICE --resolution 150 --mode Color --depth 8 --format=tiff --brightness 5 --contrast 20 | convert tiff:- -compress jpeg $scan_dir/$filename.pdf
echo none >/sys/class/leds/led0/trigger
logger -t "scanbd: $0" "Finished scanning"
;;
email)
logger -t "scanbd: $0" "Emailing $scan_dir/file-*pdf"
echo heartbeat >/sys/class/leds/led0/trigger
# here are the lines to send the file
echo none >/sys/class/leds/led0/trigger
esac