English
Deutsch
  

Code


About Matthias Nott
Business Objects
Picture Galleries
Code
Technical
Download





Locations of visitors to this page

I've had a somewhat hard time to get the USB scanner to work after I switched to 2.6.15. I have an Epson Perfection 3170 PHOTO scanner connected to my USB Port. First, connecting the scanner to the port, I saw the following in /var/log/messages:

  1. Jan 19 14:36:18 linux kernel: usb 1-4: new high speed USB device using ehci_hcd and address 19
  2. Jan 19 14:36:18 linux /etc/hotplug/usb.agent[25441]: need a device for this command

scanimage -L and sane-find-scanner were both able to see the scanner:

  1. linux:/etc/hotplug/usb # scanimage -L
  2. device `epson:libusb:001:019` is a Epson Perfection 3170 flatbed scanner
  3. linux:/etc/hotplug/usb # sane-find-scanner
  4.  
  5.   # sane-find-scanner will now attempt to detect your scanner. If the
  6.   # result is different from what you expected, first make sure your
  7.   # scanner is powered up and properly connected to your computer.
  8.  
  9.   # No SCSI scanners found. If you expected something different, make sure that
  10.   # you have loaded a kernel SCSI driver for your SCSI adapter.
  11.  
  12. found USB scanner (vendor=0x04b8 [EPSON], product=0x0116 [EPSON Scanner]) at libusb:001:019
  13.   # Your USB scanner was (probably) detected. It may or may not be supported by
  14.   # SANE. Try scanimage -L and read the backend's manpage.
  15.  
  16.   # Not checking for parallel port scanners.
  17.  
  18.   # Most Scanners connected to the parallel port or other proprietary ports
  19.   # can't be detected by this program.
  20. linux:/etc/hotplug/usb #
  21.  

I read on Google that I had to download a proprietory scanner driver for the Epson scanner from http://www.avasys.jp/english/linux_e/dl_scan.html. There are three things to download:

  1. iscan-1.18.0-1.i386.rpm
  2. iscan-plugin-gt-9400-1.0.0-1.i386.rpm
  3. iscan-1.18.0-1.tar.gz

I unpacked the third file in an empty directory and compiled it using ./configure ; make ; make install. I then installed the remaining two packages using rpm -Uvh *.rpm. Yet I still was not able to scan though, as mentioned before, e.g. scanimage -L was able to see the scanner.

 

But it saw the wrong scanner. I followed all descriptions available on the net about editing /etc/sane.d/dll.conf, /etc/sane.d/saned.conf, /etc/sane.d/epkowa.conf, yet this did not help either.

 

At this point I noticed that scanimage -L was showing an "epson" scanner while it was supposed to see an "epkowa" scanner. And this though I had switched to epkowa in my dll.conf:

  1. # epson
  2. epkowa

Now obviously the dll.conf was not read from the place I expected it to be read from. Using strace, I was able to find out what was happening:

  1. linux:/ # strace scanimage -L 2>&1 | grep -i dll.conf
  2. open("./dll.conf", O_RDONLY)            = -1 ENOENT (No such file or directory)
  3. open("/usr/local/etc/sane.d/dll.conf", O_RDONLY) = 3
  4. linux:/ #
  5.  

As you can see, scanimage tries to open the dll.conf file from the current directory first, then from /usr/local/etc/sane.d, which is pretty confusing, as if you are currently editing the file in /etc/sane.d and try out scanimage from that directory, your changes may seem to be respected, while when you are working off another directory, your changes are no longer taken into account. As a consequence, I edited the files in /usr/local/etc/sane.d.

 

Here is the complete /usr/local/etc/sane.d/dll.conf:

  1. #
  2. # SANE Dynamic library loader config
  3. # written by YaST2, Wed Aug 24 15:02:02 2005
  4. #
  5. # enablethenextlineifyouwanttoallowaccessthroughthenetwork:
  6. # net
  7. # abaton
  8. # agfafocus
  9. # apple
  10. # avision
  11. # artec
  12. # artec_eplus48u
  13. # as6e
  14. # bh
  15. # canon
  16. # canon630u
  17. # canon_pp
  18. # coolscan
  19. # coolscan2
  20. # dc25
  21. # dc210
  22. # dc240
  23. # dmc
  24. # epson
  25. # fujitsu
  26. # gphoto2
  27. # gt68xx
  28. # hp
  29. # hpsj5s
  30. # hp5400
  31. # ibm
  32. # leo
  33. # ma1509
  34. # matsushita
  35. # microtek
  36. # microtek2
  37. # mustek
  38. # mustek_pp
  39. # mustek_usb
  40. # nec
  41. # niash
  42. # pie
  43. # pint
  44. # plustek
  45. # plustek_pp
  46. # pnm
  47. # qcam
  48. # ricoh
  49. # s9036
  50. # sceptre
  51. # sharp
  52. # sm3600
  53. # snapscan
  54. # sp15c
  55. # st400
  56. # tamarack
  57. # teco1
  58. # teco2
  59. # teco3
  60. # test
  61. # u12
  62. # umax
  63. # umax_pp
  64. # umax1220u
  65. # v4l
  66. # Thefollowingbackendsarenotincludedinthesane-backendsdistribution
  67. # Ifyouwanttousethem,downloadthemfromtheirwebpagesandreadtheir
  68. # documentation
  69. # HPOfficeJetbackendhomepage:http://hpoj.sf.net/
  70. # Uncommentthefollowinglineifhpojisinstalled:
  71. # hpoj
  72. epkowa
  73.  
  74. # EOF
  75.  

Here is the complete /usr/local/etc/sane.d/saned.conf:

  1. #
  2. # saned.conf
  3. #
  4. # The contents of the saned.conf  file  is  a  list  of  host  names,  IP
  5. # addresses or IP subnets (CIDR notation) that are permitted to use local
  6. # SANE devices. IPv6 addresses must be enclosed in brackets,  and  should
  7. # always  be specified in their compressed form.
  8. #
  9. # The hostname matching is not case-sensitive.
  10. #
  11. #scan-client.somedomain.firm
  12. #192.168.0.1
  13. #192.168.0.1/29
  14. #[2001:7a8:185e::42:12]
  15. #[2001:7a8:185e::42:12]/64
  16. localhost
  17. #
  18. # NOTE: /etc/inetd.conf (or /etc/xinetd.conf) and
  19. # /etc/services must also be properly configured to start
  20. # the saned daemon as documented in saned(8), services(4)
  21. # and inetd.conf(4) (or xinetd.conf(5)).
  22.  

Here is the complete /usr/local/etc/sane.d/epkowa.conf:

  1. # epkowa.conf -- sample configuration for the EPKOWA SANE backend
  2. # Copyright (C) 2004  Olaf Meeuwissen
  3. #
  4. # See sane-epkowa(5), sane-scsi(5) and sane-usb(5) for details.
  5.  
  6. # SCSI scanners can be configured simply by listing the path to the
  7. # device.  For example, if your system claims to have a /dev/scanner
  8. # SCSI device, all you have to do is uncomment the following line:
  9. #
  10. #/dev/scanner
  11. #
  12. # In the interest of maintainability, most installations would have
  13. # /dev/scanner sym-linked to the real SCSI scanner device node.
  14. #
  15. # An alternative way that works for many operating systems and is a
  16. # little bit more generic, is to have the backend probe for your SCSI
  17. # scanner with the following configuration command:
  18. #
  19. # scsi EPSON
  20.  
  21. # On systems with libusb, the following line is sufficient to get the
  22. # backend to recognise your USB scanners.  It presumes, however, that
  23. # the scanner---more precisely, it's USB product ID---is known to the
  24. # backend.
  25. # For all USB scanners that are officially supported by this backend,
  26. # this presumption is true.  A list of such scanners can be found in
  27. # sane-epkowa(5).
  28. #
  29. usb
  30.  
  31. option warmup 1
  32. option warmup-time 1
  33.  
  34. # For any USB scanner not known to the backend (yet), you may, at your
  35. # own peril(!!), force the backend to recognise and use it via libusb.
  36. # You can do so by the following configuration command:
  37. #
  38. #   usb <USB vendor ID> <USB product ID>
  39. #
  40. # SEIKO EPSON's USB vendor ID is '0x04b8' (without quotes).  In order
  41. # to find the USB product ID, use lsusb(1) or, on Linux systems, peek
  42. # at the information in /proc/bus/usb/devices.
  43. # A sample configuration for the Perfection 1650 (GT-8200), which has
  44. # a product ID of 0x0110, would look as follows:
  45. #
  46. #usb 0x04b8 0x0110
  47. #usb 0x04b8 0x0116
  48.  
  49. # When not accessing your USB scanner via libusb, you may need to use
  50. # one of the configuration commands below or commands that are almost
  51. # the same.  These commands typically access the scanner via a kernel
  52. # scanner module.
  53. #
  54. #usb /dev/usb/scanner0
  55. #usb /dev/usbscanner0
  56. #usb /dev/uscanner0
  57. #
  58. # Linux had a scanner module until version 2.6.2.  As of version 2.6.3
  59. # libusb is your only option.  Linux' scanner module can be loaded via
  60. # the modprobe(8) command like so:
  61. #
  62. #   modprobe scanner vendor=<USB vendor ID> product=<USB product ID>
  63. #
  64. # If the scanner module already knows the vendor and product IDs, you
  65. # do not have to specify them.  If you want to have this done automa-
  66. # tically every time you boot, you can add the above line, except for
  67. # the modprobe command itself, to your /etc/modules file.
  68.  
  69. # Although not tested with this backend, parallel port scanners should
  70. # be usable.  You can configure them as shown below, but I do not know
  71. # much about the details.  Information is welcome.
  72. #
  73. #pio 0x278
  74. #pio 0x378
  75. #pio 0x3BC
  76.  

I was still unable to scan. I found out with another strace that we were trying to load the file /usr/share/iscan/esfw32.bin, which was not there, but which was in the non-free folder of the source tree of the iscan source. I thus copied everything from the non-free folder to /usr/share/iscan which I first created.

 

Then when doing scanimage -L, the scanner immediately reacted, lighted up its lamp, and was working for root.

 

To get it to work for every other user, as well, I had to create the file /etc/hotplug/usb/libusbscanner:

  1. if [ "$ACTION" = "add" -a "$TYPE" = "usb" ]; then
  2.   chown root:users "$DEVICE"
  3.   chmod 0660 "$DEVICE"
  4.   /bin/logger Scanner $DEVICE detected and connected.
  5. fi

I finally created the following script to scan files into pdf's.

  1. #!/usr/bin/perl
  2. #
  3. # This script scans a multipart image into a pdf
  4. #
  5. use strict;
  6.  
  7. my ($outdir) = join(" ", @ARGV);
  8. my $output = "";
  9.  
  10. if($outdir eq "") {
  11.   $outdir = ".";
  12. }
  13.  
  14. #
  15. # Define the scanner here.
  16. #
  17. #my $scanner = "hp:/dev/sg0";
  18. #my $scanner = "plustek:libusb:003:002";
  19. #my $scanner = "epkowa:libusb:001:003";
  20. chop (my $scanner = `export LD_PRELOAD=/usr/lib/libstdc++.so.5.0.7 && scanimage -L`);
  21. if($scanner =~ /^.*(epkowa.*?).\s.*$/) {
  22.   $scanner = $1;
  23.   print "$scanner\n";
  24. } else {
  25.   exit;
  26. }
  27.  
  28.  
  29. #
  30. # Define the scan parameters here.
  31. #
  32. # Valid modes are:
  33. # Lineart|Halftone|Grayscale|Color
  34. #
  35. my $xres = "210mm";
  36. my $yres = "297mm";
  37. my $left = "0mm";
  38. my $top  = "0mm";
  39. my $mode = "Gray";
  40. my $res  = "200dpi";
  41. my $bwlight = "180";
  42. my $grlight = "100";
  43. my $light = "180";
  44. my $dir  = "/tmp/scan";
  45. my $file = "\@tmpscan";
  46. my $time = `date +"%Y%m%d"`; chomp($time);
  47.  
  48. #
  49. # Get the output file name and timestamp
  50. #
  51. if($output eq "") {
  52.   chop ($output .= `kdialog --title "XScan" --inputbox "Enter the Filename (.pdf will be appended) [scan]       : "`);
  53.   if($output eq "") { exit; }
  54. }
  55.  
  56. if($output !~ /^.*\s-\s\d\d\d\d\d\d\d\d$/ && $output !~ /^.*\s-\s\d\d\d\d\d\d\d\d\.[pP][dD][fF]$/) {
  57.   chop (my $tmptime = `kdialog --title "XScan" --inputbox "Enter the Timestamp [$time] (n for none)             : " "$time"`);
  58.   if($tmptime eq "") { exit; }
  59.  
  60.   if($tmptime ne "n") {
  61.     if($tmptime ne "") {
  62.       $output .= " - $tmptime";
  63.     } else {
  64.       $output .= " - $time";
  65.     }
  66.   }
  67. }
  68.  
  69. if($output =~ /^(.*)\.[pP][dD][fF](.*)$/) {
  70.   $output = "$1$2.pdf";
  71. } else {
  72.   $output .= ".pdf";
  73. }
  74.  
  75. #
  76. # Eventually create the working directory
  77. #
  78. if (!-d $dir) {
  79.   system("mkdir $dir");
  80. }
  81.  
  82. #
  83. # Scan the pages
  84. #
  85. my $next = "";
  86. my $page = 0;
  87. my $pageext = "";
  88. getFormat($mode, $res);
  89. do {
  90.   $page++;
  91.   if($page < 10) {
  92.     $pageext = "00".$page;
  93.   }
  94.   if($page >= 10 && $page < 100) {
  95.     $pageext = "0".$page;
  96.   }
  97.  
  98.   if ($mode eq "Binary") {
  99.     system("export LD_PRELOAD=/usr/lib/libstdc++.so.5.0.7 && scanimage -d $scanner --format pnm -x $xres -y $yres -l $left -t $top --mode $mode --resolution $res --threshold $light --speed=no >\"$dir/$file$pageext.pnm\"");
  100.   } else {
  101.     system("export LD_PRELOAD=/usr/lib/libstdc++.so.5.0.7 && scanimage -d $scanner --format pnm -x $xres -y $yres -l $left -t $top --mode $mode --resolution $res --speed=no >\"$dir/$file$pageext.pnm\"");
  102.   }
  103.  
  104.   system("pnm2jpg $dir $file $pageext &");
  105.  
  106.   $next = getFormat($mode, $res);
  107. } while ($next ne "q");
  108.  
  109. #
  110. # Wait for the last file to be converted from pnm to jpg by the pnm2jpg
  111. #
  112. my $wait = 1;
  113. while ($wait != 0) {
  114.   sleep(0.5);
  115.   if (!-e "$dir/$file$pageext.pnm") {
  116.     $wait = 0;
  117.   }
  118. }
  119.  
  120. #
  121. # Convert to pdf
  122. #
  123. system("convert \"$dir/$file*.jpg\" -adjoin \"$outdir/$output\"");
  124.  
  125. #
  126. # Clean up the scanned pages
  127. #
  128. system("rm \"$dir/$file\"*");
  129.  
  130. #
  131. # Open the file
  132. #
  133. system("acroread \"$outdir/$output\" &");
  134.  
  135.  
  136.  
  137. #
  138. # Get the color depth
  139. #
  140. sub getFormat {
  141.   my ($curmode, $curres) = @_;
  142.   my $msg = "Enter the next page Format: BGCXXX [".substr($curmode,0,1).substr($curres,0,length($curres)-3)."], q to finish : ";
  143.   my $def = substr($curmode,0,1).substr($curres,0,length($curres)-3);
  144.   chop (my $format = `kdialog --title "XScan" --inputbox "$msg" "$def"`);
  145.   if($format eq "") { $format = "q"; }
  146.  
  147.   if($format =~ /^([bBgGcC])(.*)$/) {
  148.     if(uc($1) eq "B") {
  149.       $mode = "Binary";
  150.       $light = $bwlight;
  151.     } elsif (uc($1) eq "G") {
  152.       $mode = "Gray";
  153.       $light = $grlight;
  154.     } elsif (uc($1) eq "C") {
  155.       $mode = "Color";
  156.       $light = $grlight;
  157.     }
  158.     if($2 ne "") {
  159.       $res = "$2dpi";
  160.     }
  161.     return "";
  162.   } elsif ($format =~ /^[qQ]$/) {
  163.     return "q";
  164.   }
  165. }
 


19.01.2006, 15:47 Copyright © 2005 MN Soft Industry Software, 108, route de la Fin, CH-1874 Champéry
Tel.: +41 797 844554; Fax: +41 860 797 844554, Responsible: Matthias Nott., mn(at)mnsoft.org
Top of Page