xsaneshell hack for network scanners

Problems and successes with specific brands/models of printers
Post Reply
Message
Author
plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

xsaneshell hack for network scanners

#1 Post by plinej »

I have an all in one HP printer/scanner on my wireless network. I was messing around with trying to get my scanner to work with lucid puppy 525 with no luck via xsane or peasyscan. I decided to hack xsaneshell to add a network button and some extra code and got it to work. For now this will only work for the first printer it finds but it should be easy enough to add a dialog box incase multiple printers are found on the network. This should find any network printer already set up in cups. I'll attach the modified script which goes in /usr/bin as well as post the code.

Code: Select all

#!/bin/sh

COMMOUT="`cat /etc/sane.d/dll.conf | grep '^#[a-zA-Z0-9]' | tr '#' ' ' | tr '\n' ' '`"


xmessage -bg "orange" -center -title "Frontend for Xsane" -buttons "USB:10,Parallel:11,SCSI:12,NETWORK:13,QUIT:20" "NOTE:
The list of supported drivers is in text file /etc/sane.d/dll.conf
When Xsane starts, your scanner (if it is connected and turned on)
should be autodetected. However, some entries in 'dll.conf' are
commented-out. Here is the list of SANE drivers that are commented
-out in file 'dll.conf':

$COMMOUT

If your scanner is one of these, then Xsane will not auto-detect it.
-- in that case, click 'QUIT' button and open 'dll.conf' in a text
   editor and uncomment the appropriate entry.
   
Xsane may be a bit 'insane' when detecting a SCSI scanner. There are
various things that you may have to do:
1. Run 'sane-find-scanner' in a terminal window.
2. Make sure 'sg' module is loaded.
3. Specify the device on the commandline, ex: # xsane microtek2:/dev/sg3
4. or maybe a symbolic link, ex: # ln -s /dev/sg3 /dev/scanner

To continue and run Xsane, answer this question:
Do you have a parallel-port, USB, Network, or SCSI scanner?"

RETVAL=$?
case $RETVAL in
 10)
  #modprobe scanner
  #2.6 kernel does not have module 'scanner'. instead relies on libusb.
  echo
  ;;
 11)
  modprobe parport_pc
  ;;
 12)
  modprobe sg
  ;;
  13)
  mkdir -p ~/.config/xsaneshell/
  lpstat -t | grep 'device for ' | grep ' socket://' | sed 's/device\ for\ //' | cut -f 1 -d ':' > ~/.config/xsaneshell/device
  lpstat -t | grep 'device for ' | grep ' socket://' | sed 's/device\ for\ //' | cut -f 3 -d ':' | cut -f 3 -d '/' > ~/.config/xsaneshell/ip
  exec xsane :/net/`cat ~/.config/xsaneshell/device`?ip=`cat ~/.config/xsaneshell/ip` &
  exit
  ;;
 *)
  exit
  ;;
esac

sleep 1
exec xsane
Attachments
xsaneshell.tar.gz
(1.03 KiB) Downloaded 542 times

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#2 Post by rcrsn51 »

What driver package did you use to install your printer? What URI is it using? Just socket://...?

I tried this but got "Error during device IO". The console had a bunch of error messages about missing modules.

How does xsane know which backend driver to use with a particular model scanner?

Also, is ":/net" correct? Or should it be "net:/"? Or "hpaio:/net/"?

Did you compile your own HPLIP package with network support?

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#3 Post by plinej »

My network printer: Officejet_6500_E709n

I installed from the Puppy package mananger:
foomatic-db-20100216-lupu & hpijs-3.10.6-dynppd & hplip-3.9.12-scan

Here is my output:

Code: Select all

lpstat -t | grep 'device for ' | grep ' socket://' | sed 's/device\ for\ //' | cut -f 1 -d ':'
gives me the result <Officejet_6500_E709n>

To get the ip address of my network printer:

Code: Select all

lpstat -t | grep 'device for ' | grep ' socket://' | sed 's/device\ for\ //' | cut -f 3 -d ':' | cut -f 3 -d '/'
gives me the result <192.168.1.149>

now running the actual xsane command:

Code: Select all

xsane :/net/Officejet_6500_E709n?ip=192.168.1.149
gives me the result:

Code: Select all

No log handling enabled - turning on stderr logging
Cannot find module (IP-MIB): At line 0 in (none)
Cannot find module (IF-MIB): At line 0 in (none)
Cannot find module (TCP-MIB): At line 0 in (none)
Cannot find module (UDP-MIB): At line 0 in (none)
Cannot find module (HOST-RESOURCES-MIB): At line 0 in (none)
Cannot find module (SNMPv2-MIB): At line 0 in (none)
Cannot find module (SNMPv2-SMI): At line 0 in (none)
Cannot find module (NOTIFICATION-LOG-MIB): At line 0 in (none)
Cannot find module (DISMAN-EVENT-MIB): At line 0 in (none)
Cannot find module (DISMAN-SCHEDULE-MIB): At line 0 in (none)
Cannot find module (UCD-SNMP-MIB): At line 0 in (none)
Cannot find module (UCD-DEMO-MIB): At line 0 in (none)
Cannot find module (SNMP-TARGET-MIB): At line 0 in (none)
Cannot find module (NET-SNMP-AGENT-MIB): At line 0 in (none)
Cannot find module (HOST-RESOURCES-TYPES): At line 0 in (none)
Cannot find module (SNMP-FRAMEWORK-MIB): At line 0 in (none)
Cannot find module (SNMP-MPD-MIB): At line 0 in (none)
Cannot find module (SNMP-USER-BASED-SM-MIB): At line 0 in (none)
Cannot find module (SNMP-VIEW-BASED-ACM-MIB): At line 0 in (none)
Cannot find module (SNMP-COMMUNITY-MIB): At line 0 in (none)
Cannot find module (IP-FORWARD-MIB): At line 0 in (none)
Cannot find module (NET-SNMP-EXTEND-MIB): At line 0 in (none)
Cannot find module (UCD-DLMOD-MIB): At line 0 in (none)
Cannot find module (SNMP-NOTIFICATION-MIB): At line 0 in (none)
Cannot find module (SNMPv2-TM): At line 0 in (none)
Cannot find module (NET-SNMP-VACM-MIB): At line 0 in (none)

(xsane:11790): Gtk-WARNING **: GtkSpinButton: setting an adjustment with non-zero page size is deprecated
Even with all of the cannot find module messages xsane launches and works with my network scanner.

the full output of <lpstat -t> results in:

Code: Select all

scheduler is running
system default destination: Officejet_6500_E709n
device for CUPS-PDF: pdf-writer:/export/share/pdf/
device for Officejet_6500_E709n: socket://192.168.1.149:9100
device for pdf_writer: pdf-writer:/dev/null
CUPS-PDF accepting requests since Sat 03 Jul 2010 04:06:21 AM EDT
Officejet_6500_E709n accepting requests since Mon 11 Jul 2011 01:55:14 PM EDT
pdf_writer accepting requests since Sat 03 Jul 2010 04:13:54 AM EDT
printer CUPS-PDF is idle.  enabled since Sat 03 Jul 2010 04:06:21 AM EDT
printer Officejet_6500_E709n is idle.  enabled since Mon 11 Jul 2011 01:55:14 PM EDT
printer pdf_writer is idle.  enabled since Sat 03 Jul 2010 04:13:54 AM EDT
net:/ And hpaio:/net/ both work

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#4 Post by rcrsn51 »

Wow. The correct URI I saw on an HP site is

Code: Select all

xsane hpaio:/net/Officejet_6500_E709n?ip=192.168.1.149
so I'm surprised that it works at all.

I am trying the same thing with an Officejet 4500. I get the same set of error messages as you, but then Xsane aborts with an I/O error.

I saw a reference that you can fix this by turning on "SNMP writing" somewhere. I think that they were talking about a router setting.

I suspect that this method only applies to HP scanners.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#5 Post by plinej »

That's possible, hopefully it helps someone out though.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#6 Post by rcrsn51 »

It works! I had been testing in Quirky, but when I switched to Lupu it worked.

I will set up a Brother networked printer and see what happens there.

Thanks.

[Edit] Your method did not work with a Brother unit. However, Brother has their own method for setting up a networked scanner which works fine in Puppy.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#7 Post by rcrsn51 »

I got HP network scanning working with Quirky and Wary. The problem was that CUPS 1.3.11 did not correctly report the device name. If I used the CUPS 1.4 name, xsane would scan.

Also, I was able to modify Peasyscan so it would work with a networked HP scanner.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#8 Post by plinej »

Did you post an update for peasyscan? I wouldn't mind using that.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#9 Post by rcrsn51 »

It takes some manual modification.

1. Go to the folder /usr/local/peasyscan.

2. Open the file "peasyscan" and delete Lines 6-10. This block of code checks for a scanner. But the scanimage command can't detect a remote HP scanner.

3. Open the file "scan". Change Line 3 from

Code: Select all

$PEASYPATH/xscanimage-peasy 2> /dev/null
to, for example:

Code: Select all

$PEASYPATH/xscanimage-peasy hpaio:/net/Officejet_4500_G510n-z?ip=192.168.2.215 2> /dev/null
So instead of running xsane, you are launching xscanimage-peasy with the command line from your hack above.

Please report back.

[Update] Read here for a patch that lets Peasyscan access HP networked printer/scanners.
Last edited by rcrsn51 on Tue 12 Jul 2011, 12:37, edited 1 time in total.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#10 Post by plinej »

Works good, thanks.

plinej
Posts: 1742
Joined: Mon 14 Aug 2006, 02:21

#11 Post by plinej »

I'm not sure why but out.pnm gets saved to /root not /tmp in peasyscan so I modified the script a bit to find the file in /root instead.

User avatar
rcrsn51
Posts: 13096
Joined: Tue 05 Sep 2006, 13:50
Location: Stratford, Ontario

#12 Post by rcrsn51 »

Press the Reset button in the first screen. That will get the output going back to /tmp.

Post Reply