Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
SUCCESS using a hplip networked scanner on Raspberry Pi
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on Alternative Architectures
View previous topic :: View next topic  
Author Message
XavierMiller
Moderator
Moderator


Joined: 23 Jul 2004
Posts: 5568
Location: ~Brussels - Belgique

PostPosted: Thu Jul 24, 2014 7:59 pm    Post subject: SUCCESS using a hplip networked scanner on Raspberry Pi Reply with quote

Hello,

the scanner USE flag is hard-masked for the arm, but I tested to scan from a network HP All-in-one printer and it worked flawlessly on a Raspberry Pi, in command-line mode (no X, just "scanimage").

Next step: implement a "scan to folder" daemon, as described in some German forums or blogs.
_________________
Xavier Miller
(FR) Merci de respecter les règles du forum.
http://www.xaviermiller.be
Back to top
View user's profile Send private message
XavierMiller
Moderator
Moderator


Joined: 23 Jul 2004
Posts: 5568
Location: ~Brussels - Belgique

PostPosted: Thu Aug 21, 2014 8:52 pm    Post subject: Reply with quote

Next step: I've created a "scan to network" daemon thanks to this excellent article: http://rende.se/index.php?n=Main.ScanToFolder

My scripts assume there is only one network server, so there is no need to prefix items by host name.
/etc/hp-netscan.conf:
PRINTER="hplj2820"
SCAN_DIR="/data/nas/scan"
HELPER_DIR="/opt/hp-netscan/helpers"


/opt/hp-netscan/bin/scanloop:
#!/bin/bash

cd "`dirname $0`"

source /etc/hp-netscan.conf

set -o pipefail
while true; do
   # if scan-to button pressed - run the command corresponding to the destination name
   name=`wget -q -O - http://${PRINTER}/hp/device/notifications.xml \
         | egrep -o '<ScanToDeviceDisplay>(.*)</ScanToDeviceDisplay>' \
         | sed -e 's/<ScanToDeviceDisplay>//' \
         | sed -e 's/<\/ScanToDeviceDisplay>//' \
         | sed -e 's/.*://'` && {
      if [ "$name" != "" ]; then
         if [ -x "${HELPER_DIR}/$name" ]; then
            (cd ${SCAN_DIR}; OUTPUT_PREFIX="scan_$(date +%Y%m%d%H%M%S)" "${HELPER_DIR}/$name" >/dev/null 2>&1)
            chmod a+rw ${SCAN_DIR}/*
         fi
      fi
   }

   # update scan-to destinations in printer if necessary
   ./scanto_destination -l | sed  's/.*://' >/tmp/printer-dests &&
   ls ${HELPER_DIR} >/tmp/command-dests &&
   diff /tmp/printer-dests /tmp/command-dests | egrep '<|>' |
     sed 's#<#./scanto_destination -d#;s#>#./scanto_destination -a#' | bash

   sleep 5
done

/opt/hp-netscan/bin/scanto_destination:
#!/bin/bash
# command to maintain the scan-to destination list in the HP Color LaserJet 2840 printer

source /etc/hp-netscan.conf

if [ "$1" == "-a" ]; then
    name=$2
    postdata="AddScanToDest_1=$HOSTNAME^${name/:/%3a}^DestFolder"
    wget -q -O - --post-data="$postdata" http://${PRINTER}/hp/device/set_config.html
elif [ "$1" == "-d" ]; then
    name=$2
    postdata="RemoveScanToDest_1=${name/:/%3a}"
    wget -q -O - --post-data="$postdata" http://${PRINTER}/hp/device/set_config.html
elif [ "$1" == "-l" ]; then
    wget -q -O - http://${PRINTER}/hp/device/info_scanto_destinations.xml \
    | sed -n '/<DeviceDisplay>/s/<\/*DeviceDisplay>//gp'
else
    echo 'usage: scanto_destination -l -a <destname> -d <destname> for listing adding and deleting destinations'
fi

and a sample helper
/opt/hp-netscan/helpers/color_300_tiff:
RESOLUTION=300
scanimage --format=tiff --resolution $RESOLUTION > ${OUTPUT_PREFIX}_${RESOLUTION}.tiff


and the openrc script
/etc/init.d/hp-netscan:
#!/sbin/runscript

start() {
  ebegin "Starting hp_netscan"
  start-stop-daemon --start --exec /opt/hp-netscan/bin/scanloop \
    --pidfile /var/run/hp-netscan.pid -b -m
  eend $?
}

stop() {
  ebegin "Stopping hp_netscan"
  start-stop-daemon --stop --exec /opt/hp-netscan/bin/scanloop \
    --pidfile /var/run/hp-netscan.pid -b -m
  eend $?
}

_________________
Xavier Miller
(FR) Merci de respecter les règles du forum.
http://www.xaviermiller.be
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on Alternative Architectures All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum