Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[Solved] Scan from network-connected HP all-in-one?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
therealjrd
Tux's lil' helper
Tux's lil' helper


Joined: 18 May 2006
Posts: 120

PostPosted: Fri Apr 07, 2017 12:09 pm    Post subject: [Solved] Scan from network-connected HP all-in-one? Reply with quote

Hi all. Wasn't sure what category this should go in, so I put it here. Mods, please feel free to move as apropriate.

I have an HP M127fn all-in-one device. For logistical reasons in my office, it's connected to the rest of the system over my network. (Too long for a USB cable).

Printing works fine. I'm trying to work out how to get scans working. I've read through the sane/saned doc, but I don't see a way to get it to interface to a network-connected scanner. Perhaps that just isn't supported, and I should find a way to get the unit closer to the server, so I can use USB?

Any pointers/recipes/howtos much appreciated. Thanks in advance...


Last edited by therealjrd on Tue Apr 11, 2017 6:48 pm; edited 1 time in total
Back to top
View user's profile Send private message
Juippisi
Developer
Developer


Joined: 30 Sep 2005
Posts: 728
Location: /home

PostPosted: Fri Apr 07, 2017 2:53 pm    Post subject: Reply with quote

Hey,

in my Canon MFC8230 I have to go and press "Scan to computer" button in the Canon machine before any app realizes I have a scanner attached via network. Maybe, just maybe, thats the case for you too :)
Back to top
View user's profile Send private message
mvaterlaus
Apprentice
Apprentice


Joined: 01 Oct 2010
Posts: 235
Location: Switzerland

PostPosted: Tue Apr 11, 2017 9:17 am    Post subject: Reply with quote

hi therealjrd,
according to [1], your printer is capable of scanning over the network (look for "Scan to PC"). Maybe you did not configure the printers scanner queue. Can you give some information about the following points:


    * Do you have built net-print/hplip with the scanner use flag?
    * Does the command "scanimage -L" show your printer?
    * Did you set up the printer via "hp-setup -i $IP" ?


[1]http://hplipopensource.com/hplip-web/models/laserjet/hp_laserjet_pro_mfp_m127fn.html
_________________
For calming down your eyes or clearing your mind: www.patrickwehli.ch
Back to top
View user's profile Send private message
therealjrd
Tux's lil' helper
Tux's lil' helper


Joined: 18 May 2006
Posts: 120

PostPosted: Tue Apr 11, 2017 10:53 am    Post subject: Reply with quote

Thanks mvaterlaus

I read over the link you sent, but it doesn't seem to match my device. I can bring up the config page from the MFP, but there's nothing in any of the menus which offers to let me set of scanning functionality.

I do have hplip with use flag "scanner".
scanimage -L *does* see the device. It says it gets a timeout attempting to contact the device.
I did use hplip to set it up.

[Later]

Argh!

I went back and investigated some more the timeout reported by scanimage. It was attempting to do some sort of SNMP transaction to the device, and the device isn't responding.

A bit of digging revealed that I had disabled SNMP on the device. D'oh! Re-enabling it caused scanimage to work perfectly. Thanks for jogging me to look in the right place.

Fixing thread title.
Back to top
View user's profile Send private message
therealjrd
Tux's lil' helper
Tux's lil' helper


Joined: 18 May 2006
Posts: 120

PostPosted: Tue Apr 11, 2017 11:04 am    Post subject: [Solved] Scan from network-connected HP all-in-one? Reply with quote

Fixing subject for real
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


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

PostPosted: Tue Apr 11, 2017 11:07 am    Post subject: Reply with quote

Hi!

You can do it with a script that queries the status of the "scan to" button, then launch the scan.

See for example this link: http://bernaerts.dyndns.org/linux/75-debian/266-debian-hp-aio-scan-to-folder-server

I can also post my related scripts if you wish.
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
steveL
Watchman
Watchman


Joined: 13 Sep 2006
Posts: 5153
Location: The Peanut Gallery

PostPosted: Tue Apr 11, 2017 5:01 pm    Post subject: Reply with quote

xaviermiller wrote:
You can do it with a script that queries the status of the "scan to" button, then launch the scan.

See for example this link: http://bernaerts.dyndns.org/linux/75-debian/266-debian-hp-aio-scan-to-folder-server

That init.d script has a bug, apart from the usual dodgy sh. It will only show up in the Auto-Document feed path:
Code:
for SCAN_FILE in "$SCAN_FOLDER/$SCAN_MASK*.pnm"
should be:
Code:
for SCAN_FILE in "$SCAN_FOLDER/$SCAN_MASK"*.pnm
No doubt you've fixed it on your side.
Lack of quoting after all the previous care is disappointing, though it also looks like they're wrestling with backticks, which POSIX deprecated back in the mid-1990s.
Don't get me started on efficiency.. ;-)
Quote:
I can also post my related scripts if you wish.
Might be better, for Gentoo.

@therealjrd: To amend the subject line, you need to edit the original post (OP; also sometimes "Original Poster".)
That's the button at the top right of the OP, marked "edit"; then you can change its subject line.
Back to top
View user's profile Send private message
xaviermiller
Bodhisattva
Bodhisattva


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

PostPosted: Tue Apr 11, 2017 6:37 pm    Post subject: Reply with quote

Yeah, seems like I would have to package it ;)

Meanwhile, here are the scripts:

/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
      AUTOFEED=`wget --quiet -O - http://${PRINTER}/hp/device/notifications.xml | grep "<ADFLoaded>" | tail --lines=1 | sed "s/^.*<ADFLoaded>\([01]\)<\/ADFLoaded>.*$/\1/g"`      
      OUTPUT_PREFIX="scan_$(date '+%Y%m%d-%H%M%S')"

      source "${HELPER_DIR}/$name"

      if [ "$AUTOFEED" = "0" ]
      then
          scanimage --format=pnm --mode=Color --resolution=$RESOLUTION > "${SCAN_DIR}/${OUTPUT_PREFIX}_${RESOLUTION}.pnm" 2> /dev/null
      else
          scanimage --format=pnm --mode=Color --resolution=$RESOLUTION --batch="${SCAN_DIR}/${OUTPUT_PREFIX}_${RESOLUTION}-%d.pnm" --batch-start=1 --source ADF > /dev/null 2>&1
      fi

      for pnm in $(find "${SCAN_DIR}" -type f -name ${OUTPUT_PREFIX}\*)
      do
          img=$(echo $pnm | sed -e s/.pnm$/.${OUTPUT_FORMAT}/)
          convert -quality 100% "${pnm}" "${img}" > /dev/null 2>&1
          rm "${pnm}"
          chmod a+rw "${img}"
      done
       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

etc/hp-netscan.conf:
PRINTER="hplj2840"
SCAN_DIR="/data/nas/scan"
HELPER_DIR="/opt/hp-netscan/helpers"
/etc/init.d/hp-netscan:

#!/sbin/openrc-run

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
  eend $?
}

Then I write some "helpers", which are a set of pre-configured scan options, that will be displayed on the printer menu when you press the "scan to" button:
  • color_100_jpeg
  • color_300_jpeg
  • color_600_jpeg

The contents of one is
/opt/hp-netscan/helpers/color_300_jpeg:
RESOLUTION=300
OUTPUT_FORMAT=jpeg


HTH
_________________
Kind regards,
Xavier Miller
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo 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