Raspberry Pi
स्कैनबड (रास्पियन) के साथ एक स्कैन स्टेशन बनाएं
खोज…
परिचय और स्थापना
इस प्रलेखन का उद्देश्य किसी भी यूजर इंटरफेस के बिना स्कैनर का उपयोग करना है। एक सामान्य उपयोग केवल स्कैनर-बटन दबाकर Google स्कैन या ड्रॉपबॉक्स पर एक पीडीएफ स्कैन की गई फ़ाइल अपलोड करना है।
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
स्कैनबीडी अब स्थापित है लेकिन अभी तक कॉन्फ़िगर नहीं किया गया है।
नेटवर्क से स्कैन करने के लिए समझ को कॉन्फ़िगर करें
/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
इस बिंदु पर, स्कैनबम अभी तक कॉन्फ़िगर नहीं किया गया है, नेटवर्क से कोई स्कैनर नहीं पहुंच सकता है। हमें सेट अप का परीक्षण करने के लिए स्कैनबीडी के साथ-साथ स्कैनबीम स्थापित करने की आवश्यकता है।
स्थानीय स्कैनर को प्रदूषित करने के लिए scanbd कॉन्फ़िगर करें
स्थानीय स्कैनर को पहचानें
Lsusb का उपयोग करके, productId (यहाँ 1909) की पहचान:
pi:# lsusb
pi:# Bus 001 Device 005: ID 04a9:1909 Canon, Inc. CanoScan LiDE 110
उस ProductId के साथ, सही कॉन्फ़िगरेशन फ़ाइल को grep करें (यह आपके स्कैनर मॉडल पर निर्भर करता है, मेरे लिए यह genesys.bf है :
pi:# grep 1909 /etc/sane.d/*conf
pi:# /etc/sane.d/genesys.conf:usb 0x04a9 0x1909
फ़ाइल को अपने स्कैनबेड कॉन्फ़िगरेशन फ़ोल्डर के अंदर कॉपी करें:
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 -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
नेटवर्क पर सुनने के लिए स्कैन करने के लिए 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
}
/! \ _ स्कैनबाम के पथ की जांच करें
which scanbmसाथwhich scanbm
फिर, xinetd को पुनरारंभ करें और scanbd शुरू करें :
service xinetd restart
/etc/init.d/scanbd start
scanimage -L को अब स्कैनर प्रदर्शित करना चाहिए।
इस स्तर पर अधिकांश मुद्दे अनुमतियों की चिंता करते हैं। सुनिश्चित करें कि
scanimage -Lतब काम करता है जब आपsudo -u saned -sकर के रूप में लॉग इन होते हैं।यदि नहीं, तो 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सापेक्ष प्रत्येक पंक्ति एलईडी के नियंत्रण के लिए है कि क्या चल रहा है। आप जो चाहें कर सकते हैं,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