Benutzer-Werkzeuge

Webseiten-Werkzeuge


Übersetzungen dieser Seite:
de:alzheim-scanner

BAUSTELLE DONTREAD DONTBELIEVE

Mein Scanner als DAU-Kopierer

(Funktion: Rechner & Drucker einschalten, Papier einlegen, Knopf drücken)

Folgende Pakete aus debian-stable (lenny) installieren:

  • scanbuttond (Schnittstelle Scannerbuttons - bash-script)
  • netpbm (commandline-Grafikkonverter)
  • Ghostscript (Postscript-Interpreter) - nützlich, hier aber nicht erforderlich!
  • cups-foomatic (Druckertreiber)

(1) Test, ob Scanner erkannt wird:

$ sane-find-scanner 

.. zeigt eine Zeile mit „..found USB scanner ..“ - OK!

(2) Test, ob Scannerknopf-Events erkannt werden

$ scanbuttond -f 

.. zeigt z.B. „button 1 has been pressed on epson:libusb:004:002“ (siehe script /etc/scanbuttond/buttonpressed.sh)

(3) Jetzt scanbuttond mit root-Rechten per initscript starten

#! /bin/sh
### BEGIN INIT INFO
# Provides:          scanbuttond
# Required-Start:    
# Required-Stop:     
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: initscript for scanner button event tracing
# Description:       This file should be placed in /etc/init.d
### END INIT INFO

# Author: koarrl <jawa.cz@tplus.at>
#
# Do NOT "set -e"

# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="Scanner button event tracing"
NAME=scanbuttond
DAEMON=`which $NAME`
DAEMON_ARGS=""
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0

# Read configuration variable file if it is present @@@@ TODO for my own peculiar scanner@@@
[ -r /etc/default/$NAME ] && . /etc/default/$NAME

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh


# @@@@
VERBOSE=YES


# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

#
# Function that starts the daemon/service
#
do_start()
{
        # Return
        #   0 if daemon has been started
        #   1 if daemon was already running
        #   2 if daemon could not be started

        if [ -f "$PIDFILE" ]; then return 1; fi

        $DAEMON &
        PID=$(($!+1))
        if [ -z "$PID" ]; then return 2; fi
    
        echo $PID > $PIDFILE
        return 0;
}
# Function that stops the daemon/service
#
do_stop()
{
        # Return
        #   0 if daemon has been stopped
        #   1 if daemon was already stopped
        #   2 if daemon could not be stopped
        #   other if a failure occurred

        if ! [ -f "$PIDFILE" ]; then return 1; fi

        kill -9 `cat $PIDFILE`
        rm -f $PIDFILE
        echo "$NAME stopped!"
        return 0
}

#
# Function that sends a SIGHUP to the daemon/service
#
do_reload() {
        #
        # If the daemon can reload its configuration without
        # restarting (for example, when it is sent a SIGHUP),
        # then implement that here.
        #
        start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
        return 0
}

case "$1" in
  start)
        [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
        do_start
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  stop)
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
        do_stop
        case "$?" in
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
        esac
        ;;
  #reload|force-reload)
        #
        # If do_reload() is not implemented then leave this commented out
        # and leave 'force-reload' as an alias for 'restart'.
        #
        #log_daemon_msg "Reloading $DESC" "$NAME"
        #do_reload
        #log_end_msg $?
        #;;
 # restart|force-reload)
        #
        # If the "reload" option is implemented then remove the
        # 'force-reload' alias
        #
        #log_daemon_msg "Restarting $DESC" "$NAME"
        #do_stop
        #case "$?" in
        #  0|1)
        #       do_start
        #       case "$?" in
        #               0) log_end_msg 0 ;;
        #               1) log_end_msg 1 ;; # Old process is still running
        #               *) log_end_msg 1 ;; # Failed to start
        #       esac
        #       ;;
        #  *)
        #       # Failed to stop
        #       log_end_msg 1
        #       ;;
        #esac
        #;;
  *)
        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
        #echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
        echo "Usage: $SCRIPTNAME {start|stop}" >&2
        exit 3
        ;;
esac

:

(4) Nützliche commandlines für Scannerbutton-scripts (Annahme: Drucker ist nicht postscript-fähig, sonst wäre es einfacher)

scanne A4 & erzeuge Graustufen-tif-Bild (oder was auch immer, man scanimage)

$ scanimage --format tiff --mode Gray --resolution 300 --brightness -3 -l 0 -t 0 -x 215mm -y 280mm > scan.tif

konvertiere *.tif zu *.ps

$ tiff2ps -2 -w 8.27 -h 11.69 scan.tif > scan.ps

konvertiere *.ps in entsprechendes Drucker-raw-Format

  $ foomatic-rip -P 'HP_Laserjet_CP1515n' scan.ps > scan.raw

schicke Rohdaten zum Drucker - fertig!

  $ lp -s -d 'HP_Laserjet_CP1515n' -oraw test.raw

de/alzheim-scanner.txt · Zuletzt geändert: 2010/03/25 12:37 von koarrl