# [Unresolved] Xsane scanner tool

## mark2

It will not detect my HP ScanJet 8200 flatbed scanner. But scanimage -L gives:

```
device 'avision':libusb:001:005' is a Hewlett-Packard ScanJet 8200 flatbed scanner
```

I followed all the steps in the wiki and cannot seem to find out why it won't connect.

----------

## soulsource

Have you tried running xsane from the command line, to see if it gives some informative output? 

Also, have you tried to run xsane as root? Of course I'm not suggesting to always scan as root, but if xsane works when being run with full privileges, you've probably got a permission issue that can be resolved by writing a suitable UDEV rule. For instance you could create a group for all users allowed to use scanners, add your user to it, and write an UDEV rule that gives this group access to the scanner.

Another crazy idea: Have you tried to use other USB ports, or a different cable? I had similar issues (scanimage found the scanner, but xsane couldn't use it), and I'm meanwhile certain they were caused by a cheap USB cable... What confirmed that it's the cable was that after switching it with the printer cable of my girlfriend's computer, her printer didn't work any more... Funny enough, I'm still using that cable, but on a different USB port, where obviously my mainboard has slightly higher voltage levels (or accepts lower voltage input).

----------

## mark2

I will try running it from the command line. I'm not sure, but I thought that I had. I did try running it as root, but it gave the same error.

I like your idea of a different USB cable, because I have two cables piggybacked since the original one is not long enough. So I will try that and post back.

Thanks.

----------

## mark2

Well, that didn't work. I used a completely new USB cable, plenty long enough, but it was of no help. I get the error:

```
Failed to open device 'avision:libusb:001:0018':Operation not supported.
```

And this is running xsane from the command line as root. which, of course, first gives me the message as to how dangerous this is.

Nor does it matter which USB port I try.

----------

## russK

wondering if you have either SANE_BACKENDS="hp" or SANE_BACKENDS="avision"

just a shot in the dark

----------

## mark2

Good question. I didn't really know there was a difference, to tell the truth. How do I change that?

----------

## soulsource

Oh, I didn't even think about SANE_BACKENDS...

It's an auto-expand variable for portage (similar to the LINGUAS or the VIDEO_CARDS variable) and can be defined in /etc/portage/make.conf

----------

## mark2

I added the SANE_BACKENDS="hp" to make.conf, but it made no difference.

----------

## The Doctor

I have also been unable to get xsane and hp to work properly. However, I did find a workaround that is very effective. That is to use hp-scan. Here is the man page if you want to try it

----------

## mark2

Thanks Doctor, but the link you provided didn't quite show me what to do for a scanner. It says the Hplip does not work for scanners. And, unfortunately it seems that my scanner is not supported by SANE Backends, either. When I run "sane-find-scanner", I get:

```
found USB scanner (vendor=0x03f0 [hp], product=0x0b01 [hp scanjet 8200]) at libusb:008:002
```

And then trying scanimage -L after editing and commenting out "avision" in /etc/sane.d/dll.conf, I get No scanners were identified. Don't know why it was identifying it as avision before, but now it looks like I'll have to replace this HP ScanJet 8200 with one that IS in the SANE Backends list.

Unless someone more knowledgeable than myself has any other suggestions.

----------

## Buffoon

http://www.sane-project.org/sane-mfgs.html#Z-HEWLETT-PACKARD

It shows your scanner is supported.

----------

## soulsource

My scanner, a HP Scanjet 7400c, requires the avision backend, the same might be true for yours.

----------

## mark2

 *Buffoon wrote:*   

> http://www.sane-project.org/sane-mfgs.html#Z-HEWLETT-PACKARD
> 
> It shows your scanner is supported.

 

Yes, that is true. I found that while doing some digging.

 *soulsource wrote:*   

> My scanner, a HP Scanjet 7400c, requires the avision backend, the same might be true for yours.

 

I also discovered that the avision backend is for my scanner, so I went back and uncommented that in my /etc/sane.d/dll.conf and restored my make.conf also. I went through the Gentoo Wiki as well, which btw is a bit outdated since hotplug and coldplug are way out of date. So far nothing is helping it to connect. I can detect it with both sane-find-scanner and scanimage -L as well, but something is still not making the connection. It keeps coming back with Operation not supported, which is not making sense. Yet.

I going to try a reboot.

----------

## mark2

The reboot did nothing to help. Also ran through the Hplip setup with the tarball and after following the instructions to download it to my desktop, now I have a crap load of files all over my desktop. If it's not going to work, I want to clean up this thing. I tried to run the hp-setup and hp-scan and I don't guess I know where to find these commands, because that is what it says, "Command not found". If the instructions are going to tell one what to run, why do they not also tell one just where to find the command? This sort of documentation is no doubt the reason so many inexperienced users (of which I am one) experience great frustration.

I had absolutely no trouble whatsoever installing Cups and my Oki 6100C printer.

----------

## soulsource

Strange... 

I'm honestly out of clever ideas, and back to wild guesses... Have you enabled the global "scanner" use flag?

----------

## bbgermany

Can you post your configfile (/etc/sane.d/avision.conf) and the full output of "lsusb" please. Maybe you need some tweaking there. 

Thx, bb

EDIT: Please add "avision" back to your make.conf and dll.conf. It is needed for your scanner according to the sane website!

----------

## mark2

First my make.conf:

```
 These settings were set by the catalyst build script that automatically

# built this stage.

# Please consult /usr/share/portage/config/make.conf.example for a more

# detailed example.

CFLAGS="-march=athlon64 -O2 -pipe"

CXXFLAGS="${CFLAGS}"

# WARNING: Changing your CHOST is not something that should be done lightly.

# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.

CHOST="x86_64-pc-linux-gnu"

# These are the USE flags that were used in addition to what is provided by the

# profile used for building.

USE="bindist branding mmx sse sse2 nvidia gtk -gnome -kde gimp gmp-autoupdate \

     jemalloc3 jit media-video/ffmpeg minimal startup-notification \

     -qt4 dbus jpeg lock scanner session thunar udev usb svg X xcomposite xinerama\

     alsa encode vorbis xv xvid x264"

PORTDIR="/usr/portage"

PORT_LOGDIR="/usr/portage/elog"

DISTDIR="${PORTDIR}/distfiles"

PKGDIR="${PORTDIR}/packages"

PORTAGE_ELOG_CLASSES="info error log"

PORTAGE_ELOG_SYSTEM="save"

MAKEOPTS="-j3"

INPUT_DEVICES="evdev"

VIDEO_CARDS="nvidia"

XFCE_PLUGINS="brightness clock trash"

SANE_BACKENDS="avision"

CONFIG_PROTECT_MASK="/etc/udev/udev.conf"

CONFIG_PROTECT_MASK="/etc/portage/package.use/xfce"

CONFIG_PROTECT_MASK="/etc/portage/package.use/scribus"

#SYNC="rsync://rsync3.us.gentoo.org/gentoo-portage"
```

Now my /etc/sane.d/avision.conf:

```
# These are the possible options. Normally any scanner

# should work just fine without them - and they are only

# needed for test and debugging. So if you experience problems

# and you solve them with enabling options here, please notify

# the SANE/Avision maintainer: Mike Kelly <mike@piratehaven.org>

#option disable-gamma-table

#option disable-calibration

#option force-a4

#scsi AVISION

#scsi FCPA

#scsi MINOLTA

#scsi MITSBISH MCA-S600C

#scsi MITSBISH MCA-SS600

#scsi HP

#scsi hp

#scsi /dev/scanner

# usb libusb:002:003

# usb 0x03f0 0x0701

usb 0x03f0 0x0b01

```

And my complete /etc/sane.d/dll.conf file:

```
  GNU nano 2.3.6                            File: /etc/sane.d/dll.conf                                                                

# enable the next line if you want to allow access through the network:

net

abaton

agfafocus

apple

avision

artec

artec_eplus48u

as6e

bh

canon

canon630u

canon_dr

#canon_pp

cardscan

coolscan

#coolscan2

coolscan3

#dc25

#dc210

#dc240

dell1600n_net

dmc

epjitsu

#epson

epson2

fujitsu

#gphoto2

genesys

gt68xx

hp

hp3900

hpsj5s

hp3500

hp4200

hp5400
```

I did add avision back into this last, but I've posted what I could in the hope that something sticks out that I don't see. I even added the hp8200 in the list, which for some reason I couldn't get to copy out of the terminal window. It only copies what is active.

 Oh yes, the output of lsusb:

```
marktux / # lsusb

Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 008 Device 002: ID 03f0:0b01 Hewlett-Packard ScanJet 82x0C

Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 001 Device 005: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub

Bus 001 Device 002: ID 059b:0177 Iomega Corp. Hi-Speed USB-to-IDE Bridge Controller

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 004 Device 003: ID 0a09:5000  

Bus 004 Device 002: ID 0a09:5000  

Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Bus 003 Device 002: ID 046d:c521 Logitech, Inc. Cordless Mouse Receiver

Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

```

Thanks,

Mark

----------

## bbgermany

 *mark2 wrote:*   

> 
> 
> Now my /etc/sane.d/avision.conf:
> 
> ```
> ...

 

Ok it looks like this could be wrong, because you have enabled the usb-useflag globally in your make.conf. This is because of the RDEPEND in sane-backends:

```

usb? ( >=virtual/libusb-1-r1:1[${MULTILIB_USEDEP}] )

```

 *mark2 wrote:*   

> 
> 
>  Oh yes, the output of lsusb:
> 
> ```
> ...

 

I think it should look like this according to your current USB connection:

```

# These are the possible options. Normally any scanner

# should work just fine without them - and they are only

# needed for test and debugging. So if you experience problems

# and you solve them with enabling options here, please notify

# the SANE/Avision maintainer: Mike Kelly <mike@piratehaven.org>

#option disable-gamma-table

#option disable-calibration

#option force-a4

#scsi AVISION

#scsi FCPA

#scsi MINOLTA

#scsi MITSBISH MCA-S600C

#scsi MITSBISH MCA-SS600

#scsi HP

#scsi hp

#scsi /dev/scanner

# usb libusb:002:003

# usb 0x03f0 0x0701

usb libusb:008:002

```

Please try this and check whether you can run scanimage as root from the console. We should have a look at xsane later, since you are not able to scan at the moment at all.

greets, bb

----------

## mark2

Thanks, bb.

scanimage -L (as root in console) produces the following:

```
device `avision:libusb:008:002' is a Hewlett-Packard ScanJet 8200 flatbed scanner
```

----------

## NeddySeagoon

mark2,

Are you in the scanner and or plugdev groups?

One of those is obsolete but I can't recall which.

----------

## mark2

I am in the scanner group, but not the plugdev group. Also the usb group.

----------

## NeddySeagoon

mark2,

I think the scanner group gave access to /dev/scanner in the days when the kernel had a usbscanner option in menuconfig.

When libusb came along  /dev/scanner went away.

If you have plugdev group on your system, add yourself to it, then logout and back in to pick up the new group membership.

If the plugdev group does not exist, you don't need it.

Google suggests my memory is faulty and plugdev came along with HAL, which has long since gone away again.

----------

## mark2

I used getent group to show:

```
root:x:0:root

bin:x:1:root,bin,daemon

daemon:x:2:root,bin,daemon

sys:x:3:root,bin,adm

adm:x:4:root,adm,daemon

tty:x:5:

disk:x:6:root,adm

lp:x:7:lp,mark

mem:x:8:

kmem:x:9:

wheel:x:10:root,mark

floppy:x:11:root

news:x:13:news

uucp:x:14:uucp

console:x:17:

audio:x:18:mark

cdrom:x:19:mark

tape:x:26:root

video:x:27:root,mark

cdrw:x:80:mark

usb:x:85:mark

users:x:100:mark

portage:x:250:portage

utmp:x:406:

nogroup:x:65533:

nobody:x:65534:

sshd:x:22:

man:x:15:

input:x:249:

mark:x:1000:

messagebus:x:248:

ldap:x:439:

lpadmin:x:106:mark

polkitd:x:105:

ntp:x:104:

scanner:x:103:mark

```

So, it does not appear the plugdev exists. And I would assume since my kernel is version 4.0.5 that usbscanner is not an option.

----------

## russK

 *mark2 wrote:*   

> Well, that didn't work. I used a completely new USB cable, plenty long enough, but it was of no help. I get the error:
> 
> ```
> Failed to open device 'avision:libusb:001:0018':Operation not supported.
> ```
> ...

 

If you are still getting the "Operation not supported", I think it is probably some configuration, library, or driver issue as opposed to a permissions issue.

Maybe try running with 'strace' to see how/when the error code is generated.

----------

## mark2

The only problem I ran into with strace is that there is so much more code than I can capture on a screen. And it won't wgetpaste because it says there is nothing to post.

----------

## russK

 *mark2 wrote:*   

> The only problem I ran into with strace is that there is so much more code than I can capture on a screen. And it won't wgetpaste because it says there is nothing to post.

 

mark,

You would need need to strace the process trying to access the scanner, xsane would be too much with child processes and such.

maybe this:

```
strace -o strace.out scanimage >image.png

cat strace.out | wgetpaste

```

I think many pastebin services limit the post size to 500K, hopefully it will take it.   Otherwise the tail end is probably more important than the head.

HTH

----------

## mark2

Thanks, russK. That produced quite an output, around 23000 lines, but here it is: https://bpaste.net/show/ca1a354cfc75

But the first part gave:

```
scanimage: open of device avision:libusb:008:003 failed: Operation not supported
```

----------

## russK

A few things I noticed that would be worth looking into, unfortunately some could be red herrings:

line 12980 and several other places:

```
open("/dev/scanner", O_RDWR|O_EXCL|O_NONBLOCK) = -1 ENOENT (No such file or directory)

```

So, it tried to open /dev/scanner.  I have seen instructions on the web about setting up udev rules for /dev/scanner

Twice it seemed to be getting down to brass tacks when it did the following:

```
open("/dev/bus/usb/008/003", O_RDWR)    = 12

ioctl(12, SNDRV_CTL_IOCTL_TLV_READ or USBDEVFS_GET_CAPABILITIES, 0x643c30) = 0

write(7, "\1", 1)                       = 1

read(6, "\1", 1)                        = 1

open("/sys/bus/usb/devices/8-1/bConfigurationValue", O_RDONLY) = 13

read(13, "1\n", 5)                      = 2

close(13)                               = 0

ioctl(12, USBDEVFS_SETCONFIGURATION, 0x7ffe4c5024fc) = 0

ioctl(12, USBDEVFS_CLAIMINTERFACE, 0x7ffe4c5024cc) = 0

```

But then it seemed to time out

the device it was using there was 008 / 003 ... did it move?

One of those attempts was right after reading the avision.so library, so I would assume that was when it was trying the avision backend.  Do you have the hp backend as well?

You can have both in make.conf,

```
SANE_BACKENDS="avision hp"
```

Another shot in the dark, since I noticed it scans /sys/bus/dcsi/devices several times, in the old days I think you needed generic SCSI device support for some scanners, even over USB, so check your kernel to see if you have CONFIG_CHR_DEV_SG.

HTH

----------

## mark2

Ok, I don't have the hp backend in the make.conf, but if it won't hurt anything, I'll try your suggestion with that, though I suspect that won't really make any difference.

I will check into the udev rules for /dev/scanner.

The change on the device seems to have taken place because I did disconnect the usb cable from the back of the scanner itself, but I put it right back to test a suggestion I had read. So it was not like I moved it to a different usb port on the computer - THAT did not change. I wondered about the 008 / 003 myself as it didn't make sense. It was definitely timing out, though.

I got sane-find-scanner to show this:

```
  # sane-find-scanner will now attempt to detect your scanner. If the

  # result is different from what you expected, first make sure your

  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that

  # you have loaded a kernel SCSI driver for your SCSI adapter.

found USB scanner (vendor=0x03f0 [hp], product=0x0b01 [hp scanjet 8200]) at libusb:008:003

  # Your USB scanner was (probably) detected. It may or may not be supported by

  # SANE. Try scanimage -L and read the backend's manpage.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports

  # can't be detected by this program.
```

I will also check the kernel for CONFIG_CHR_DEV_SG and post back.

----------

## mark2

I re-configured the kernel to make sure that OHCI and EHCI were compiled as modules. I could not find CONFIG_CHR_DEV_SG anywhere in the kernel configuration. My kernel version is 4.0.5, so maybe it's just not in there.

I did add the hp backend in make.conf.

I wrote a rule in /etc/udev/rules.d/91-local.rules that I found in searching and it looks like this:

```
SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="0b01", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"
```

It has not made any difference. I don't know if a reboot is necessary or not.

----------

## mark2

Update: I did a reboot, ran xsane and it reported the device 008 / 002 this time, but it still cannot open avision:008:003, Operation not supported.

I left it running emerge --sync since it said that it was last run 31 days ago.

----------

## russK

 *mark2 wrote:*   

> ... I could not find CONFIG_CHR_DEV_SG anywhere in the kernel configuration. My kernel version is 4.0.5, so maybe it's just not in there.

 

Sorry, I should have spelled out "SCSI generic support".  I have 4.0.5, it's in there, Device Drivers -> SCSI device support -> SCSI generic support

A tip someone provided on the forums before, in menuconfig you can hit '/' and search for settings, so '/' and "CHR_DEV_SG" will confirm it's there and point the way.

----------

## bbgermany

 *mark2 wrote:*   

> Update: I did a reboot, ran xsane and it reported the device 008 / 002 this time, but it still cannot open avision:008:003, Operation not supported.
> 
> I left it running emerge --sync since it said that it was last run 31 days ago.

 

If it changed to 008/002, sane-find-scanner will produce something like "avision:008:002" then. So you wont be able to access it via "avision:008:003" then. 

greets, bb

----------

## mark2

@russK:

I went back through the kernel and did find Device Drivers -> SCSI device support -> SCSI generic support. It was set as a module and was like that from the get-go. So, just to test, I switched to the kernel, and recompiled. Now it's running emerge -auvDN @world and it is doing about 46 packages, most of them updates.

I feel like there is something I'm supposed to do after it finishes, just not sure what that might be. Depclean? I don't know....

@bb:

I may made a typo in reporting 008 /003. For now Xsane, scanimage -L, and sane-find-scanner all report the device 008:002. Sorry, it's late and I'm just not positive on that note.

----------

## russK

 *mark2 wrote:*   

> @russK:
> 
> I went back through the kernel and did find Device Drivers -> SCSI device support -> SCSI generic support. It was set as a module and was like that from the get-go. So, just to test, I switched to the kernel, and recompiled. Now it's running emerge -auvDN @world and it is doing about 46 packages, most of them updates.
> 
> I feel like there is something I'm supposed to do after it finishes, just not sure what that might be. Depclean? I don't know....
> ...

 

mark,

Your persistence is admirable.  If you had SCSI generic support from the get-go then I imagine that was not part of the problem.  One thing I forgot to mention before was to look at 'dmesg' output after unplugging and reconnecting the scanner, sometimes it can be illuminating.

Since this scanner has been around for a long time, I would think also that and emerge update with or without depclean is not going to solve anything unless you are still changing USE flags and the SANE_BACKENDS values.  The Doctor mentioned he has had bad luck with xsane but uses hp-scan from hplip.  If The Doctor can't make it work, then by God it just might not.

I have an HP OfficeJet style multi-function device that actually works with both xsane and hplip.  Perhaps when you are tired of beating your head against the xsane wall    :Smile:   , you may want to try hplip, with the scanner USE flag.

----------

## russK

Oh sorry about the hplip suggestion, I missed the fact that hplip doesn't support scanners that don't print     :Embarassed: 

----------

## mark2

I did try the hplip with no luck, of course. This one has a button that can send to a printer, but interestingly none of the buttons on the scanner will work or initiate even a manual scan. There may very well be something dead in it. But anyway, last ditch effort:

dmesg after reconnecting the scanner can be seen here: https://bpaste.net/show/a1186da99a46

I ran xsane after that and this time it referred to 008 / 003, saying:  *Quote:*   

> Failed to open device 'avision:libusb:008:003': Operation not supported.

 

[small edit]I unplugged the power cord, reconnected, ran xsane once more for giggles, and this time it references 008 / 004 with the above message. Go figure.

The last few lines of dmesg have the only reference to this scanner that I noticed.

```
[85803.500029] usb 8-1: new full-speed USB device number 3 using ohci-pci

[85803.714050] usb 8-1: not running at top speed; connect to a high speed hub

[85803.743048] usb 8-1: New USB device found, idVendor=03f0, idProduct=0b01

[85803.743051] usb 8-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3

[85803.743054] usb 8-1: Product: hp scanjet 8200

[85803.743056] usb 8-1: Manufacturer: hp

[85803.743058] usb 8-1: SerialNumber: SCN36AT07407
```

So, I don't know... I just may have to look at buying a new scanner? Any suggestions?

----------

## bbgermany

I have an old Canoscan Lide 20 laying in the closet. Ill try to figure out how to get this running, maybe we can adopt it to your avision config then  :Wink: 

greets, bb

EDIT: I looked a bit around the manpages for sane-backends and I have a few questions:

1st: Do you use libusb? check if /proc/bus/usb is mounted

2nd: Could you replace the line "usb libusb:008:003" with "usb 0x03f0 0x0b01" instead and try again?

3rd: Do you have sane-backends compiled with debug? If yes, you could use "export SANE_DEBUG_AVISION=7" for more information about the issue.

4th: A studid question, but is saned running?

----------

## mark2

 *bbgermany wrote:*   

> I have an old Canoscan Lide 20 laying in the closet. Ill try to figure out how to get this running, maybe we can adopt it to your avision config then 
> 
> greets, bb
> 
> EDIT: I looked a bit around the manpages for sane-backends and I have a few questions:
> ...

 

Well, 1st: I can use lsusb, but when I try to mount /proc/bus/usb it says it does not exist. And looking in the /proc/usb directory there is only input and pci.

And 2nd: I replaced the line as suggested, but then xsane could not find the device. So I plugged it into a different usb port which shows up as libusb:001:019. As a matter of fact, running sane-find-scanner produces:

```
  # sane-find-scanner will now attempt to detect your scanner. If the

  # result is different from what you expected, first make sure your

  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that

  # you have loaded a kernel SCSI driver for your SCSI adapter.

could not open USB device 0x1d6b/0x0001 at 008:001: Input/output error

found USB scanner (vendor=0x03f0 [hp], product=0x0b01 [hp scanjet 8200]) at libusb:001:019

  # Your USB scanner was (probably) detected. It may or may not be supported by

  # SANE. Try scanimage -L and read the backend's manpage.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports

  # can't be detected by this program.

```

Then when the xsane window is looking for scanners, it lasts for about 2 seconds, disappears, then in a little while the error comes back:

```
Failed to open device 'avision:libusb:001:019': Operation not supported.
```

For 3rd: No, I did not compile sane-backends with debug.

And checking 4th: I did service saned restart, and it came back with:

```
* Caching service dependencies ...                                                                                  [ ok ]

 * /var/run/saned: creating directory

 * Starting saned ...

 * start-stop-daemon: failed to start `/usr/sbin/saned'

 * Failed to start saned                                                                                             [ !! ]

 * ERROR: saned failed to start
```

Meantime I will emerge sane-backends with debug and try again.

----------

## mark2

Update: emerge sane-backends --debug failed to emerge media-gfx/sane-backends-1.0.24-r5.

The debug info is here: https://bpaste.net/show/0db5e7bb079e

That's over 16,000 lines and I don't have the experience to make sense out of that.

----------

## russK

 *mark2 wrote:*   

> Update: emerge sane-backends --debug failed to emerge media-gfx/sane-backends-1.0.24-r5.
> 
> The debug info is here: https://bpaste.net/show/0db5e7bb079e
> 
> That's over 16,000 lines and I don't have the experience to make sense out of that.

 

Sorry I don't see much that would be helpful there, looks like it failed with a "C compiler cannot create executables"

On the other hand, google suggests that it might help to run scanimage like this:

```
SANE_DEBUG_AVISION=255 SANE_DEBUG_HP=255 scanimage >image.png 2>debug.out

cat debug.out | wgetpaste

```

----------

## mark2

First, the output of your suggested scanimage produced this: https://bpaste.net/show/1ce0c459c485

Interesting. So it wouldn't let me emerge sane-backends-1.0.24-r5 when I tried. I dug into /usr/portage/elog by using a terminal on elog, which btw had a big red X over it and kept saying permissions denied. But in the terminal I could navigate into media-gfx/sane-backends to see what was actually in there. And I found some files that may be causing the problem here at: https://bpaste.net/show/cda6027a413f

And another folder called 'files'. The contents of it are here: https://bpaste.net/show/5ba516f50802

So I am wondering if there might be something in editing the saned.confd. It is showing this:

```
# The user saned should drop its privileges to after startup

#SANED_USER=""
```

----------

## mark2

So I thought that if the C compiler could not run executables, then I should switch to root and emerge gcc. It tried to emerge gcc-4.9.3, but that also failed with the same error message about executables.

Looks like a stalemate. I did find:

```
Configuring source in /var/tmp/portage/sys-devel/gcc-4.9.3/work/gcc-4.9.3 ...

 * gcc-config: Active gcc profile is invalid!
```

----------

## russK

 *mark2 wrote:*   

> So I thought that if the C compiler could not run executables, then I should switch to root and emerge gcc. It tried to emerge gcc-4.9.3, but that also failed with the same error message about executables.
> 
> Looks like a stalemate. I did find:
> 
> ```
> ...

 

mark,

gcc 4.9.3 recently went stable, a week or so ago.  Prior to this you were probably humming along just fine with 4.8.5.  This issue I would say has nothing to do with your scanner woes.  My suggestion would be to avoid switching to 4.9.3 until you are finished working on the scanner problem.  It is generally OK to have multiple slots of gcc installed at the same time, I personally have not switched yet:

```
gcc-config -l

 [1] x86_64-pc-linux-gnu-4.7.4

 [2] x86_64-pc-linux-gnu-4.8.5 *

 [3] x86_64-pc-linux-gnu-4.9.3

```

You can read about upgrading the compiler on the wiki:  https://wiki.gentoo.org/wiki/Upgrading_GCC

It is something you sort of have to commit to, downgrading can be problematic.

Regarding the debug.out that you captured, it actually looks kind of promising to me, based on how much information it was able to probe from the scanner, it looked tantalizingly close to getting somewhere (although I must admit I'm not an expert  :Smile:   ).   All the way through around line 1007 I think it might have been OK and then it was trying to do something with "ADF firmware resets..."  , which I think is Automatic Document Feeder.  Your scanner does not have a automatic document feeder I assume?  Maybe if there is a way to configure avision to not use or disable ADF, just wondering.

HTH

----------

## russK

Another possibility, I noticed here on the scanimage manpage, 'scanimage -A' produces some help output with a lot of options, and for mine I saw this:

```
scanimage -A

All options specific to device `hpaio:/net/Officejet_Pro_8600?ip=192.168.1.16':

  Scan mode:

    --mode Lineart|Gray|Color [Lineart]

        Selects the scan mode (e.g., lineart, monochrome, or color).

    --resolution 75|100|200|300dpi [75]

        Sets the resolution of the scanned image.

    --source Flatbed|ADF|Duplex [Flatbed]

        Selects the scan source (such as a document-feeder).

```

Do you get the same option, '--source'?   If so, seems like in your case you might add the option '--source Flatbed' to your scanimage command.

----------

## mark2

Well, I had already managed to upgrade to gcc-4.9.3, but trying scanimage -A and scanimage --source Flatbed produced the same error as before. open of device avision:libusb:001:019 failed: Operation not supported.

It is indicative of something that when I launch xsane as root, the scanner buttons light up, but nothing else happens. Also true of the other scanner commands. So something triggers activity, but it does not go anywhere.

The upgrade did allow me to emerge sane-backends, though.

----------

## sebB

After adding SANE_BACKENDS="avision" to your make.conf, have you recompiled sane-backends?

----------

## russK

Another shot in the dark might be to try the sane-backends 1.0.25_pre20150628 ebuild or the live 9999 ebuild.

----------

## mark2

@ sebB:

Yes.

@: russK:

I tried emerge sane-backends 1.0.25_pre20150628, but it says no ebuilds to satisfy. How do I get it to do that? Right now it has done 1.0.24-r4, but when I run the gui it shows 0.999 in the title bar.

----------

## russK

mark,

maybe I typed it wrong, you can see all of the ebuilds in portage like this with 'equery', which is in the gentoolkit package:

```
equery list -p sane-backends

 * Searching for sane-backends ...

[IP-] [  ] media-gfx/sane-backends-1.0.24-r5:0

[-P-] [ ~] media-gfx/sane-backends-1.0.25_pre20150628:0

[-P-] [ -] media-gfx/sane-backends-9999:0

```

So you would have to unmask it :  https://wiki.gentoo.org/wiki/Knowledge_Base:Unmasking_a_package

----------

## mark2

Thanks for the tip, russK, but it made no difference. Also, when I launch xsane the little windows shows briefly, but long enough to note the title bar shows 0.999 (only 3 9's), before it comes up with the same message as before.

Also now it tells me that 10 config files in '/etc' need updating. I have looked in the emerge man page, but it has never made sense how to update config files. I realize this is completely off topic, but I'm not sure that it is not germane to the situation.

----------

## russK

Right, it could be germane to the new version not working (maybe), but you need to know it in general anyway.

When you update packages, they might have new config file settings.  But you probably don't want portage to just blow away your existing config files, which a lot of time and effort might have gone in to.  So dispatch-conf provides a mechanism for keeping your existing files, but also bringing in the suggested files from the new version.  I personally find dispatch-conf can be rather clumsy, if there is a large number of differences between the new files and the old files, but I'm not complaining.

Usually the number of differences is small, and I hit 'u', which means use the new file.  Then I might go and fix the file manually.  Sometimes I hit 'z' for zap, which means keep the old file.  After you go through this a few times you'll start to realize how it works.   Looking at the wiki page, https://wiki.gentoo.org/wiki/Dispatch-conf, I see it talks about vimdiff which I should probably learn how to use.  At times I have resorted to using meld outside of dispatch-conf.

In any case, it's best to go through the process of making sure your config files are up to snuff with new versions after they are emerged.

----------

## mark2

Well, that's good. I did run dispatch-conf as it prompted and hit 'u', which is what probably allowed that newest version to complete emerging. I will study the link you've provided and the information I can dig up on vimdiff.

Maybe I can determine why xsane keeps showing 0.999 in its title bar. It's like the newest is not being used, seems to me.

----------

## russK

xsane is different from sane-backends

I see xsane-0.999 too.

Use equery again,

```
equery list -p xsane

 * Searching for xsane ...

[IP-] [  ] media-gfx/xsane-0.999-r1:0

```

So 0.999-r1 is the only version of xsane in portage, also, the 'I' means this is the version installed.

Usually a version with a lot of 9's in it is a live ebuild, meaning a version that is pulled straight from git, subversion, or cvs for the project.  But I it's usually very large like 9999, not a fraction like 0.999.  In this case, xsane-0.999 really is the number of the latest package that has been released on their downloads page:  http://www.xsane.org/

----------

## mark2

I have the same exact response using equery. I thought I might be able to see something if I connected it to my Macbook Pro. It did nothing when I connected the USB cable. I could not even detect it using Printers and Scanners in System Preferences. I looked on the Internet to see if the scanner is supported on the Mac, but it is not even listed under their list of supported scanners. What is strange, however, there are NO scanners listed on that page. So much for Mac superiority! Another reason I prefer LInux, ahem.

It does bother me that the scanner's control panel doesn't do much. It will run through the options of saving to Wordpad, etc, and let you choose the number of copies, but none of the other buttons respond. If it weren't for the fact that scanimage and sane-find-scanner detect it at all, I would almost think it is dead or damaged in some way. I'm about to give up on it and go look for one.

Thanks, everyone, for your patience, persistence, and willingness to help with all your suggestions. You are one terrific resource!

----------

## Buffoon

I'd recommend a networked scanner, but of course I do not know whether it suits you or not.

----------

## mark2

 *Buffoon wrote:*   

> I'd recommend a networked scanner, but of course I do not know whether it suits you or not.

 

Thanks, Buffoon. I can do that here at home. I'll look into that.

----------

## jonathan183

I use mdev and have an HP Scanjet G2410 which uses the genesys sane-backend, I had some problems initially setting this up and change ownership to root:scanner and set read/execute/write for the scanner group as part of starting the system.

You might want to check the scanner group has required permissions, it might also be worth trying creating a symlink at /dev/scanner pointing to your scanner to see if that helps.

----------

## russK

Another avenue might be Windows in a virtual machine.

Sorry we haven't found a solution but at least maybe we learned a thing or two in the process.

----------

## mark2

Big update! As it turns out the scanner is not at all dead or damaged. After some digging I learned how to go into diagnostic mode with the buttons on the control panel, and was able to navigate through a lot of tests. Once I knew that, I tried once again emerging all the components, xsane, sane-backends, sane-frontends, etc. None of which did any good.

But.

On a whim, I downloaded Vuescan and extracted it, then ran it. Lo and behold, it worked. It picked up the scanner without a hiccup, I scanned a color picture which just happened to be me and my first son 35 years ago. The only trouble is ... this is not free software. They want $39.95 for the standard version, or $79.95 for the professional version, because in the trial version it overlays a watermark over the entire image. Which I could handle with the Gimp, but that requires some detailed pixel editing. What a pain.

So, if this program can communicate with the scanner, there has to be something somewhere preventing xsane from doing the same. If "Operation is not supported", I am wondering how to enable my own support. Is this programming, or script writing? Enquiring minds wanna know.

At least the scanner won't be going out to be recycled. The diagnostics showed that it had only performed 600 scans so it should have a lot of life left in it. Also, I can set it to do 600 dpi, which I think is pretty good for my purposes.

----------

## sebB

Can you try with a live cd (ubuntu, fedora...) and see if it work.

----------

## mark2

 *sebB wrote:*   

> Can you try with a live cd (ubuntu, fedora...) and see if it work.

 

Hmmm, that's a thought. It'll take awhile before I get a chance, but it's worth a shot. Thanks, sebB!

----------

## bbgermany

Ok, it looks like, you entered the following problem as well:

http://lists.alioth.debian.org/pipermail/sane-devel/2014-September/032639.html

According to your debug output, sane-backend is looking for an ADF (automatic document feeder). I think you dont have one on your scanner, do you? Since this is not responding, the system is telling you "Operation not supported." 

There seems to be a fix for this issue, but it dont know whether this is in the version of sane-backends you have installed. Maybe you can add this by yourself. Its located in the link above.

greets bb

EDIT: you can try the following patches by hand

for sane-backends-1.0.24 use this:

```

--- a/backend/avision.c 2013-08-25 23:22:58.000000000 +0200

+++ b/backend/avision.c 2015-10-13 14:54:47.870445826 +0200

@@ -3164,7 +3164,7 @@

 get_accessories_info (Avision_Scanner* s)

 {

   Avision_Device* dev = s->hw;

-  int try = 3;

+  int try = 1;

   /* read stuff */

   struct command_read rcmd;

@@ -3238,7 +3238,8 @@

         goto RETRY;

       }

       DBG (1, "get_accessories_info: Maximum retries attempted, ADF unresponsive.\n");

-      return SANE_STATUS_UNSUPPORTED;

+      return SANE_STATUS_GOOD;

     }

   }

```

for sane-backends-1.0.25_pre20150628 use this:

```

--- a/backend/avision.c 2015-06-27 19:06:50.000000000 +0200

+++ b/backend/avision.c 2015-10-13 15:00:31.090450521 +0200

@@ -3168,7 +3168,7 @@

 get_accessories_info (Avision_Scanner* s)

 {

   Avision_Device* dev = s->hw;

-  int try = 3;

+  int try = 1;

   /* read stuff */

   struct command_read rcmd;

@@ -3242,7 +3242,8 @@

         goto RETRY;

       }

       DBG (1, "get_accessories_info: Maximum retries attempted, ADF unresponsive.\n");

-      return SANE_STATUS_UNSUPPORTED;

+      return SANE_STATUS_GOOD;

     }

   }

```

----------

## mark2

You are right. I do not have the ADF. But I have not been able to use the patch you've provided for the sane-backends-1.0.25_pre20150628 that I have. Maybe something I'm missing?

I get this:

```
marktux mark # patch a/backend/avision.c 2015-06-27 19:06:50.000000000 +0200

patch: 19:06:50.000000000: extra operand

patch: Try 'patch --help' for more information.

marktux mark # +++ b/backend/avision.c 2015-10-13 15:00:31.090450521 +0200

bash: +++: command not found

marktux mark # @@ -3168,7 +3168,7 @@

bash: @@: command not found

marktux mark #  get_accessories_info (Avision_Scanner* s)

bash: syntax error near unexpected token `Avision_Scanner*'

marktux mark #  {

>    Avision_Device* dev = s->hw;

> -  int try = 3;

> +  int try = 1;

> 

>    /* read stuff */

>    struct command_read rcmd;

> @@ -3242,7 +3242,8 @@

>          goto RETRY;

>        }

bash: Avision_Device*: command not found

bash: -: command not found

bash: +: command not found

bash: /bin: Is a directory

bash: struct: command not found

bash: @@: command not found

bash: goto: command not found

marktux mark #        DBG (1, "get_accessories_info: Maximum retries attempted, ADF unresponsive.\n");

bash: syntax error near unexpected token `1,'

marktux mark # -      return SANE_STATUS_UNSUPPORTED;

bash: -: command not found

marktux mark # +      return SANE_STATUS_GOOD;

bash: +: command not found

marktux mark #      }

bash: syntax error near unexpected token `}'

marktux mark #    } 

```

----------

## russK

mark

Have you a local overlay ?   Or are you trying to build from source?   ...

So whatever, I was able to use the patch from bb (not exactly) and create a 1.0.25 ebuild that builds if you want to go that road.

If so, first follow the first part of this wiki page to create a local overlay:  https://wiki.gentoo.org/wiki/Overlay/Local_overlay

Then, create an ebuild kindof like this:

```
mkdir -p /usr/local/portage/media-gfx/sane-backends

cp -r /usr/portage/media-gfx/sane-backends/files /usr/local/portage/media-gfx/sane-backends

```

This is the ebuild that I made by copying and changing 1.0.25_pre20150628 ebuild.  I'm sure it could be simplified but it would have taken more time  :Wink: 

Put this in /usr/local/portage/media-gfx/sane-backends/sane-backends-1.0.25.ebuild:  

```
# Copyright 1999-2015 Gentoo Foundation

# Distributed under the terms of the GNU General Public License v2

# $Id$

EAPI="5"

inherit autotools eutils flag-o-matic multilib multilib-minimal udev user toolchain-funcs

# gphoto and v4l are handled by their usual USE flags.

# The pint backend was disabled because I could not get it to compile.

IUSE_SANE_BACKENDS="

   abaton

   agfafocus

   apple

   artec

   artec_eplus48u

   as6e

   avision

   bh

   canon

   canon630u

   canon_dr

   canon_pp

   cardscan

   coolscan

   coolscan2

   coolscan3

   dc210

   dc240

   dc25

   dell1600n_net

   dmc

   epjitsu

   epson

   epson2

   fujitsu

   genesys

   gt68xx

   hp

   hp3500

   hp3900

   hp4200

   hp5400

   hp5590

   hpljm1005

   hpsj5s

   hs2p

   ibm

   kodak

   kodakaio

   kvs1025

   kvs20xx

   kvs40xx

   leo

   lexmark

   ma1509

   magicolor

   matsushita

   microtek

   microtek2

   mustek

   mustek_pp

   mustek_usb

   mustek_usb2

   nec

   net

   niash

   p5

   pie

   pixma

   plustek

   plustek_pp

   pnm

   qcam

   ricoh

   rts8891

   s9036

   sceptre

   sharp

   sm3600

   sm3840

   snapscan

   sp15c

   st400

   stv680

   tamarack

   teco1

   teco2

   teco3

   test

   u12

   umax

   umax1220u

   umax_pp

   xerox_mfp"

IUSE="avahi doc gphoto2 ipv6 nls snmp systemd threads usb v4l xinetd"

for backend in ${IUSE_SANE_BACKENDS}; do

   case ${backend} in

   # Disable backends that require parallel ports as no one has those anymore.

   canon_pp|hpsj5s|mustek_pp|\

   pnm)

      IUSE+=" -sane_backends_${backend}"

      ;;

   mustek_usb2|kvs40xx)

      IUSE+=" sane_backends_${backend}"

      ;;

   *)

      IUSE+=" +sane_backends_${backend}"

   esac

done

REQUIRED_USE="

   sane_backends_mustek_usb2? ( threads )

   sane_backends_kvs40xx? ( threads )

"

DESCRIPTION="Scanner Access Now Easy - Backends"

HOMEPAGE="http://www.sane-project.org/"

MY_PV="r001"

case ${PV} in

9999)

   EGIT_REPO_URI="git://anonscm.debian.org/sane/sane-backends.git"

   inherit git-r3

   ;;

*1.0.25)

   MY_P=${P}

   SRC_URI="https://alioth.debian.org/frs/download.php/file/4146/${P}.tar.gz"

   ;;

esac

LICENSE="GPL-2 public-domain"

SLOT="0"

if [[ ${PV} != "9999" ]] ; then

   KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd ~amd64-linux ~x86-linux"

fi

RDEPEND="

   sane_backends_dc210? ( >=virtual/jpeg-0-r2[${MULTILIB_USEDEP}] )

   sane_backends_dc240? ( >=virtual/jpeg-0-r2[${MULTILIB_USEDEP}] )

   sane_backends_dell1600n_net? ( >=virtual/jpeg-0-r2[${MULTILIB_USEDEP}]

                           >=media-libs/tiff-3.9.7-r1[${MULTILIB_USEDEP}] )

   avahi? ( >=net-dns/avahi-0.6.31-r2[${MULTILIB_USEDEP}] )

   sane_backends_canon_pp? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )

   sane_backends_hpsj5s? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )

   sane_backends_mustek_pp? ( >=sys-libs/libieee1284-0.2.11-r3[${MULTILIB_USEDEP}] )

   usb? ( >=virtual/libusb-1-r1:1[${MULTILIB_USEDEP}] )

   gphoto2? (

      >=media-libs/libgphoto2-2.5.3.1:=[${MULTILIB_USEDEP}]

      >=virtual/jpeg-0-r2[${MULTILIB_USEDEP}]

   )

   v4l? ( >=media-libs/libv4l-0.9.5[${MULTILIB_USEDEP}] )

   xinetd? ( sys-apps/xinetd )

   snmp? ( net-analyzer/net-snmp )

   systemd? ( sys-apps/systemd:0= )

"

DEPEND="${RDEPEND}

   v4l? ( sys-kernel/linux-headers )

   doc? (

      virtual/latex-base

      dev-texlive/texlive-latexextra

   )

   >=virtual/pkgconfig-0-r1[${MULTILIB_USEDEP}]"

# We now use new syntax construct (SUBSYSTEMS!="usb|usb_device)

RDEPEND="${RDEPEND}

   !<sys-fs/udev-114

   abi_x86_32? (

      !<=app-emulation/emul-linux-x86-medialibs-20140508

      !app-emulation/emul-linux-x86-medialibs[-abi_x86_32(-)]

   )"

MULTILIB_CHOST_TOOLS=(

   /usr/bin/sane-config

)

pkg_setup() {

   enewgroup scanner

   enewuser saned -1 -1 -1 scanner

}

src_prepare() {

   cat >> backend/dll.conf.in <<-EOF

   # Add support for the HP-specific backend.  Needs net-print/hplip installed.

   hpaio

   # Add support for the Epson-specific backend.  Needs media-gfx/iscan installed.

   epkowa

   EOF

   epatch "${FILESDIR}"/${PN}-1.0.25-avision-adf.patch

   # Fix for "make check".

   sed -i -e 's/sane-backends 1.0.24git/sane-backends 1.0.24/' testsuite/tools/data/html*

   mv configure.{in,ac} || die

   AT_NOELIBTOOLIZE=yes eautoreconf

}

src_configure() {

   append-flags -fno-strict-aliasing

   # if LINGUAS is set, just use the listed and supported localizations.

   if [[ ${LINGUAS+set} == "set" ]]; then

      mkdir -p po || die

      strip-linguas -u po

      printf '%s\n' ${LINGUAS} > po/LINGUAS

   fi

   multilib-minimal_src_configure

}

multilib_src_configure() {

   # the blank is intended - an empty string would result in building ALL backends.

   local BACKENDS=" "

   use gphoto2 && BACKENDS="gphoto2"

   use v4l && BACKENDS="${BACKENDS} v4l"

   for backend in ${IUSE_SANE_BACKENDS}; do

      if use "sane_backends_${backend}" && [ ${backend} != pnm ]; then

         BACKENDS="${BACKENDS} ${backend}"

      fi

   done

   local myconf=(

      $(use_enable usb libusb_1_0)

      $(multilib_native_use_with snmp)

   )

   # you can only enable this backend, not disable it...

   if use sane_backends_pnm; then

      myconf+=( --enable-pnm-backend )

   fi

   if ! use doc; then

      myconf+=( --disable-latex )

   fi

   if use sane_backends_mustek_pp; then

      myconf+=( --enable-parport-directio )

   fi

   if ! { use sane_backends_canon_pp || use sane_backends_hpsj5s || use sane_backends_mustek_pp; }; then

      myconf+=( sane_cv_use_libieee1284=no )

   fi

   # relative path must be used for tests to work properly

   ECONF_SOURCE=${S} \

   SANEI_JPEG="sanei_jpeg.o" SANEI_JPEG_LO="sanei_jpeg.lo" \

   BACKENDS="${BACKENDS}" \

   econf \

      $(use_with gphoto2) \

      $(multilib_native_use_with systemd) \

      $(use_with v4l) \

      $(use_enable avahi) \

      $(use_enable ipv6) \

      $(use_enable nls translations) \

      $(use_enable threads pthread) \

      "${myconf[@]}"

}

multilib_src_compile() {

   emake VARTEXFONTS="${T}/fonts"

   if tc-is-cross-compiler; then

      pushd "${BUILD_DIR}"/tools >/dev/null || die

      # The build system sucks and doesn't handle this properly.

      # https://alioth.debian.org/tracker/index.php?func=detail&aid=314236&group_id=30186&atid=410366

      tc-export_build_env BUILD_CC

      ${BUILD_CC} ${BUILD_CPPFLAGS} ${BUILD_CFLAGS} ${BUILD_LDFLAGS} \

         -I. -I../include -I"${S}"/include \

         "${S}"/sanei/sanei_config.c "${S}"/sanei/sanei_constrain_value.c \

         "${S}"/sanei/sanei_init_debug.c "${S}"/tools/sane-desc.c -o sane-desc || die

      local dirs=( hal hotplug hotplug-ng udev )

      local targets=(

         hal/libsane.fdi

         hotplug/libsane.usermap

         hotplug-ng/libsane.db

         udev/libsane.rules

      )

      mkdir -p "${dirs[@]}" || die

      emake "${targets[@]}"

      popd >/dev/null

   fi

   if use usb; then

      sed -i -e '/^$/d' \

         tools/hotplug/libsane.usermap || die

   fi

}

multilib_src_install() {

   emake INSTALL_LOCKPATH="" DESTDIR="${D}" install \

      docdir="${EPREFIX}"/usr/share/doc/${PF}

   if multilib_is_native_abi; then

      if use usb; then

         insinto /etc/hotplug/usb

         doins tools/hotplug/libsane.usermap

      fi

      udev_newrules tools/udev/libsane.rules 41-libsane.rules

      insinto "/usr/share/pkgconfig"

      doins tools/sane-backends.pc

   fi

}

multilib_src_install_all() {

   keepdir /var/lib/lock/sane

   fowners root:scanner /var/lib/lock/sane

   fperms g+w /var/lib/lock/sane

   dodir /etc/env.d

   if use usb; then

      exeinto /etc/hotplug/usb

      doexe tools/hotplug/libusbscanner

      newdoc tools/hotplug/README README.hotplug

   fi

   dodoc NEWS AUTHORS ChangeLog* PROBLEMS README README.linux

   prune_libtool_files --all

   if use xinetd; then

      insinto /etc/xinetd.d

      doins "${FILESDIR}"/saned

   fi

   newinitd "${FILESDIR}"/saned.initd saned

   newconfd "${FILESDIR}"/saned.confd saned

}

pkg_postinst() {

   if use xinetd; then

      elog "If you want remote clients to connect, edit"

      elog "/etc/sane.d/saned.conf and /etc/hosts.allow"

   fi

   elog "If you are using a USB scanner, add all users who want"

   elog "to access your scanner to the \"scanner\" group."

}

```

Put this in /usr/local/portage/media-gfx/sane-backends/files/sane-backends-1.0.25-avision-adf.patch:

```
--- a/backend/avision.c

+++ b/backend/avision.c

@@ -3168,7 +3168,7 @@

 get_accessories_info (Avision_Scanner* s)

 {

   Avision_Device* dev = s->hw;

-  int try = 3;

+  int try = 1;

   

   /* read stuff */

   struct command_read rcmd;

@@ -3242,7 +3242,7 @@

         goto RETRY;

       }

       DBG (1, "get_accessories_info: Maximum retries attempted, ADF unresponsive.\n");

-      return SANE_STATUS_UNSUPPORTED;

+      return SANE_STATUS_GOOD;

     }

   }

 

```

run, 'ebuild /usr/local/portage/media-gfx/sane-backends/sane-backends-1.0.25.ebuild digest'

Then,

```
emerge =media-gfx/sane-backends-1.0.25
```

Hopefully it installs and works!

----------

## bbgermany

There is an other way to apply "user-patches" as well, if you dont want to mess with a local overlay. I havent used it up to now, but it should work as well. You should have a look at this blog:

http://klaig.blogspot.de/2011/07/how-to-apply-user-patches-in-portage.html

I dont know, if it works for sane-backends, but imo it is worth a try  :Wink: 

bb

EDIT: looks like, this wont work for sane-backends, but you can do it this way:

1st: create a file with the patch contents ({$PATCHFILE})

2nd:

```

$ ebuild /usr/portage/media-gfx/sane-backends/sane-backends-{$VERSION}.ebuild prepare

$ cd /var/tmp/portage/media-gfx/sane-backends/sane-backends-{$VERSION}/work/sane-backends-1.0.24/

$ cat {$PATCHFILE} | patch -p1

$ ebuild /usr/portage/media-gfx/sane-backends/sane-backends-{$VERSION}.ebuild merge

```

greets, bb

----------

## mark2

Hi russK, I tried your procedure (thank heaven for copy/paste) but I've gotten an error, which is this:

```
ebuild /usr/local/portage/media-gfx/sane-backends/sane-backends-1.0.25.ebuild digest

/usr/local/portage/media-gfx/sane-backends/sane-backends-1.0.25.ebuild: line 337: warning: here-document at line 186 delimited by end-of-file (wanted `EOF')

/usr/local/portage/media-gfx/sane-backends/sane-backends-1.0.25.ebuild: line 338: syntax error: unexpected end of file

 * ERROR: media-gfx/sane-backends-1.0.25::local failed (depend phase):

 *   error sourcing ebuild

 * 

 * Call stack:

 *   ebuild.sh, line 584:  Called die

 * The specific snippet of code:

 *            source "$EBUILD" || die "error sourcing ebuild"

 * 

 * If you need support, post the output of `emerge --info '=media-gfx/sane-backends-1.0.25::local'`,

 * the complete build log and the output of `emerge -pqv '=media-gfx/sane-backends-1.0.25::local'`.

 * Working directory: '/usr/lib64/python3.4/site-packages'

 * S: '/var/tmp/portage/media-gfx/sane-backends-1.0.25/work/sane-backends-1.0.25'
```

But also, I looked into /usr/local/portage/media-gfx/sane-backends and there was another folder named 'files'. It contained  things which I'm not sure how they got in there, but I guess I must have done it. Anyway they can be seen here: https://bpaste.net/show/c4c5a8fd0d1f. Does this make any difference.

@bb:

I wanted to try your procedure, but I am unclear what you mean by 'create a file with the patch contents ({$PATCHFILE})'. Is that the actual name? I'm sorry but I often get confused by terminology that I'm not familiar with.  :Embarassed: 

----------

## bbgermany

 *mark2 wrote:*   

> Hi russK, I tried your procedure (thank heaven for copy/paste) but I've gotten an error, which is this:
> 
> ```
> ebuild /usr/local/portage/media-gfx/sane-backends/sane-backends-1.0.25.ebuild digest
> 
> ...

 

Somehow, I had the same issue. You could try changing the two lines by hand instead of using a patchfile

 *mark2 wrote:*   

> 
> 
> @bb:
> 
> I wanted to try your procedure, but I am unclear what you mean by 'create a file with the patch contents ({$PATCHFILE})'. Is that the actual name? I'm sorry but I often get confused by terminology that I'm not familiar with. 

 

$PATCHFILE is just a replacement for a name, you can choose. You could use the terminology russK suggested or whatever you want.

greets bb

----------

## mark2

Ignorance showing again. Can't seem to determine which two lines.

 *Quote:*   

> 
> 
> Somehow, I had the same issue. You could try changing the two lines by hand instead of using a patchfile

 

Tried counting to line 186, maybe got close, but it made no sense. And don't know what to change it to IF I'm looking at the right place.

----------

## bbgermany

Hi, no problem,

here are the lines that need changing in backends/avision.c:

1st: search for "Avision_Device* dev = s->hw; " and replace in the following line "int try = 3; " with "int try = 1;"

2nd: search for "DBG (1, "get_accessories_info: Maximum retries attempted, ADF unresponsive.\n");" and replace in the following line "return SANE_STATUS_UNSUPPORTED;" with "return SANE_STATUS_GOOD;"

thats all, greets bb

EDIT: Oh the first is not in line 187 its at around line 3168  :Wink: 

----------

## mark2

That explains it. I wasn't even looking in the right place! I will go back in after I get off work and post back with results.

Thanks for the clarification, bb!

----------

## mark2

I am lost. I cannot find backends/avision.c and I don't remember any file with over 3,160 lines. Where is this supposed to be? It is certainly not in /usr/local/portage/media-gfs/sane-backends/.

----------

## russK

 *mark2 wrote:*   

> Hi russK, I tried your procedure (thank heaven for copy/paste) but I've gotten an error, which is this:
> 
> ```
> ebuild /usr/local/portage/media-gfx/sane-backends/sane-backends-1.0.25.ebuild digest
> 
> ...

 

mark,

Copy and paste is awesome, but in this case it probably caused this hiccup.  At around line 191 of the ebuild, I have "EOF", preceded by a single TAB character.  I wonder how it ended up in your version?  It should be legal for you to simply delete all of the white space before "EOF" so that it appears by itself at the beginning of the line.  Then pick up the steps again from there.  Hopefully that solves it.  Incidentally, my version of the ebuild has a lot of TAB characters in it, I hope you don't bump into other similar problems due to the copy having converted the TABs to spaces.  I suspect it should be OK.

BTW, the scripting feature being used in src_prepare() there is called a "here document":  http://tldp.org/LDP/abs/html/here-docs.html, for anyone interested.

The other files in the 'files' directory can live there, they came from the copy operation.  If they are not used, they are harmless.

Awesome you're using a multi-pronged attack on this problem, you're bound to get it working eventually    :Smile: 

HTH

----------

## russK

 *mark2 wrote:*   

> I am lost. I cannot find backends/avision.c and I don't remember any file with over 3,160 lines. Where is this supposed to be? It is certainly not in /usr/local/portage/media-gfs/sane-backends/.

 

Sorry we have you running in circles with two different approaches.

You won't find the source in the overlay tree.  It gets unpacked under /var/tmp/portage during emerge.  Maybe you had unpacked some source somewhere when you were trying to apply the patch manually.  

When I unpacked one of the sane-backend tarballs, that file was under backend/avision.c, not backends/avision.c

----------

## mark2

Well, that got another step closer as the ebuild completed after taking out the tab before the EOF. That was copied from your earlier post, but that's neither here nor there. At any rate, when I ran the emerge =media-gfx/sane-backends-1.0.25, it errored out with the following:

```
 * IMPORTANT: 11 config files in '/etc/portage' need updating.

 * See the CONFIGURATION FILES section of the emerge

 * man page to learn how to update config files.

Calculating dependencies... done!

>>> Verifying ebuild manifests

>>> Emerging (1 of 1) media-gfx/sane-backends-1.0.25::local

 * sane-backends-1.0.25.tar.gz SHA256 SHA512 WHIRLPOOL size ;-) ...                                                           [ ok ]

>>> Unpacking source...

>>> Unpacking sane-backends-1.0.25.tar.gz to /var/tmp/portage/media-gfx/sane-backends-1.0.25/work

>>> Source unpacked in /var/tmp/portage/media-gfx/sane-backends-1.0.25/work

>>> Preparing source in /var/tmp/portage/media-gfx/sane-backends-1.0.25/work/sane-backends-1.0.25 ...

 * Cannot find $EPATCH_SOURCE!  Value for $EPATCH_SOURCE is:

 * 

 *   /usr/local/portage/media-gfx/sane-backends/files/sane-backends-1.0.25-avision-adf.patch

 *   ( sane-backends-1.0.25-avision-adf.patch )

 * ERROR: media-gfx/sane-backends-1.0.25::local failed (prepare phase):

 *   Cannot find $EPATCH_SOURCE!

 * 

 * Call stack:

 *     ebuild.sh, line   93:  Called src_prepare

 *   environment, line 4047:  Called epatch '/usr/local/portage/media-gfx/sane-backends/files/sane-backends-1.0.25-avision-adf.patch'

 *   environment, line 1917:  Called die

 * The specific snippet of code:

 *                   die "Cannot find \$EPATCH_SOURCE!";

 * 

 * If you need support, post the output of `emerge --info '=media-gfx/sane-backends-1.0.25::local'`,

 * the complete build log and the output of `emerge -pqv '=media-gfx/sane-backends-1.0.25::local'`.

 * The complete build log is located at '/usr/portage/elog/media-gfx:sane-backends-1.0.25:20151015-215156.log'.

 * For convenience, a symlink to the build log is located at '/var/tmp/portage/media-gfx/sane-backends-1.0.25/temp/build.log'.

 * The ebuild environment file is located at '/var/tmp/portage/media-gfx/sane-backends-1.0.25/temp/environment'.

 * Working directory: '/var/tmp/portage/media-gfx/sane-backends-1.0.25/work/sane-backends-1.0.25'

 * S: '/var/tmp/portage/media-gfx/sane-backends-1.0.25/work/sane-backends-1.0.25'
```

What is $EPATCH_SOURCE?

It gave a log file but it would not allow me to paste it, saying permission denied. I don't understand that because I am doing in a terminal as root. Of course I'm logged in as my user on the machine, but that puzzles me. I hate to have to reboot, log in as root, and then go from there. Must be a reason for that, but whatever.

As to your follow up post, I can't seem to find where I might have unpacked some source on that, but I did find sane-backends-1.0.25.tar.gz in /var/tmp/portage/media-gfx/sane-backends-1.0.25/distdir/.

----------

## russK

Right, you're getting close.  The file you do need in the 'files' directory, I posted the contents in the same post as the ebuild.  The file should be in '/usr/local/portage/media-gfx/sane-backends/files/sane-backends-1.0.25-avision-adf.patch', and the contents again:

```
--- a/backend/avision.c

+++ b/backend/avision.c

@@ -3168,7 +3168,7 @@

 get_accessories_info (Avision_Scanner* s)

 {

   Avision_Device* dev = s->hw;

-  int try = 3;

+  int try = 1;

   

   /* read stuff */

   struct command_read rcmd;

@@ -3242,7 +3242,7 @@

         goto RETRY;

       }

       DBG (1, "get_accessories_info: Maximum retries attempted, ADF unresponsive.\n");

-      return SANE_STATUS_UNSUPPORTED;

+      return SANE_STATUS_GOOD;

     }

   }

 

```

You will need to do the digest step again before you can try the emerge.

----------

## bbgermany

Hi all,

i created an archive für your local overlay. Just extract it to the overlay root and run the following:

```

ebuild $OVERLAYDIR/media-gfx/sane-backends/sane-backends-1.0.25_pre20150628.ebuild digest

emerge -av =media-gfx/sane-backends-1.0.25_pre20150628

```

The package includes the patch

download -> http://www.sheppi.de/~beier/download/sane-backends-overlay.tar.bz2

greets, bb

----------

## mark2

Well! russK, with your pointer, I found that the *avision-adf.patch was in the same directory as 'files'. After I moved into 'files', ran digest, it emerged correctly into media-gfx/sane-backends-1.0.25::local. And it ran xsane under root, as well as my user. So success on that front!

In trying to scan either a document or picture, the 8200 does MA Timeout and xsane reports an I/O error. I hit the cancel button, but it sits there (how long, I don't know as I'm in a hurry this morning), but I have to unplug the USB and power off then back on. But at least it is working this far.

Thank you guys so much for sticking with me and getting me this far. Can't tell you how much this has helped me.

I will check back a little later.

bb, sorry I didn't get a chance to try your overlay. I'm sure it would work as well. Unless it would do something that the preceeding procedure does not. As I say, I will check back to see if there any further thoughts on this.

Thanks again!

----------

## bbgermany

You're welcome. Glad to see a sign of life is coming from that "thing" beside payed software.

greets, bb

----------

## mark2

I have been unable to get the scanner to respond further. Xsane is loading without crashing and when clicking Acquire Preview or Scan, it will cause the 8200 to respond, but then it freezes. At one point when I was trying to use hplip to install drivers, I downloaded and extracted to my Desktop. I couldn't run setup successfully, but I am wondering if somehow this is interfering?  Also I have a mess of files all over my Desktop and now would really like to get rid of them. I never could stand a cluttered Desktop full of icons and files. Can I simply select them and delete them, or do I need to do some kind of uninstall? Even if they're not harming anything, I want to get rid of them. I know this second bit is not specifically germane to the topic of the post, and I can open another thread if I should.

----------

## bbgermany

Whats the resolution you have set for aquireing? I hvae read, some scanners act stranges if its set beloww 600dpi.

greets bb

----------

## russK

I see one place in the code, the hw entry for the 8200 has it defined with a flipping duplex adf, you might want to patch it to say it does not have the adf, or avoid calling the get accessories call altogether.  I'm traveling now or i could post another patch, I'll check back tomorrow to see what's happening.

----------

## mark2

I had turned off my computer while the grandkids were here, and when I turned it back on and launched xsane, it came up with an error box and a message I had never seen before. Since I can't post a screenshot, the message says:

```
Error while loading device settings:

/home/mark/.sane/xsane/Hewlett-Packard:Scanjet8200.drc is not a device-rc file !!!
```

And a Close button. The preview screen came up but all options were grayed out. When I click the Close button, then the Preview window becomes active, but at the bottom where it has Acquire preview, Cancel preview, there is a box that has 

###, ###, ###

###, ###, ###

Then the scanner tries to engage, the light bar runs to the end of the document, and the Control Panel LCD shows DMA Timeout. I have tried to find out where I can change the DMA Timeout settings through the Control Panel but have not yet had success. In other searching, I found a thread in a Debian forum where the users had determined that the length of the USB cable had an effect on the DMA Timeout. They said that when they switched to a 3-foot cable, their 8200 began working. I had been using a 5m cable, so I changed to a 6-foot cable with no change. In the documentation HP says that the supplied USB cable with that scanner is a 3m length, so mine is within their specs, but since they only provided support for Windows or Mac, that may not apply to Linux. I don't know, but I will look for a shorter USB tomorrow when I return to work. I work in the IT department for our school district.

----------

## russK

mark,

Is it possible this scanner was never updated with a firmware update since it was manufactured?  I ask because I was reading about a firmware update that you can download from HP that addresses some kind of DMA thing:

I hope these links point you to it, the file is COL4534.exe

http://h20566.www2.hp.com/hpsc/swd/public/readIndex?sp4ts.oid=214600&swLangOid=8&swEnvOid=228

http://h20566.www2.hp.com/hpsc/swd/public/detail?sp4ts.oid=214600&swItemId=sj_16052_1&swEnvOid=228

I have no idea how to use the firmware update, hopefully there are some instructions, I imagine you would have to use Windows to do it.

Also I wonder if you should back up that drc file and let xsane try to create a new one.  When xsane comes up for me, it has already detected my HP OfficeJet copier/scanner, and there I am able to change the "scan source" dropdown to Flatbed.

----------

## mark2

 *russK wrote:*   

> mark,
> 
> Is it possible this scanner was never updated with a firmware update since it was manufactured?  I ask because I was reading about a firmware update that you can download from HP that addresses some kind of DMA thing:
> 
> I hope these links point you to it, the file is COL4534.exe
> ...

 

You are correct that the firmware has never been updated. I did look for it but saw that it was a Windows executable file so it won't work on my box. BUT. I do have one that I can use here at home, so I will try that.

I have not seen the option to select the "scan source", but I will look for it.

How should I back up the  drc file? Just copy it somewhere? Where would be a good place?

----------

## russK

 *mark2 wrote:*   

> You are correct that the firmware has never been updated. I did look for it but saw that it was a Windows executable file so it won't work on my box. BUT. I do have one that I can use here at home, so I will try that.
> 
> I have not seen the option to select the "scan source", but I will look for it.
> 
> How should I back up the  drc file? Just copy it somewhere? Where would be a good place?

 

Right, probably should connect the scanner to a Windows box to update the firmware.  I doubt wine would work.    A virtual windows guest on your Linux host might work.  If you have an available Windows box just use that.

To back up the drc file, I would just rename it with a 'mv' command, e.g.:

```
mv /home/mark/.sane/xsane/Hewlett-Packard:Scanjet8200.drc /home/mark/.sane/xsane/Hewlett-Packard:Scanjet8200.drc-bak
```

Here is a picture of my xsane with the scan source field circled in red:

https://www.dropbox.com/s/ow464sgy1n4ue2b/xsane.png?dl=0

edit: here is the relevant page from the documentation:  http://www.xsane.org/doc/sane-xsane-scan-options-doc.html

HTH

----------

## mark2

I connected it to an XP machine, which recognized it and allowed it to scan a document. I downloaded the firmware update, but XP will not allow it to run. It complains that it cannot find a file named C9930A.bin when that is one of the very files the executable extracts. Even when run as Administrator. The file looks like a self-executing extractable (with the little C-clamp type icon), but I am not having any luck getting it to run. At least I know the scanner does work under Windows XP.

I will try the drc backup and reconnect to my Gentoo box and re-run xsane to see if that will help. As an aside, I did locate a 3-foot USB cable at work and will hook it up that way to see if it will help with the DMA Timeout.

[Edit] I backed up the drc as you suggested, but xsane did not create a new drc. Running sane-find-scanner produced:

```
sane-find-scanner

  # sane-find-scanner will now attempt to detect your scanner. If the

  # result is different from what you expected, first make sure your

  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that

  # you have loaded a kernel SCSI driver for your SCSI adapter.

could not fetch string descriptor: Operation timed out

could not fetch string descriptor: Operation timed out

found USB scanner (vendor=0x03f0, product=0x0b01) at libusb:001:009

  # Your USB scanner was (probably) detected. It may or may not be supported by

  # SANE. Try scanimage -L and read the backend's manpage.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports

  # can't be detected by this program.
```

Then scanimage -L came up with:

```
/ # scanimage -L

No scanners were identified. If you were expecting something different,

check that the scanner is plugged in, turned on and detected by the

sane-find-scanner tool (if appropriate). Please read the documentation

which came with this software (README, FAQ, manpages).
```

Xsane says no devices available running as my user, or as root.

The funny thing is that when xsane came up with the Advanced Options window before I backed up the drc file, at the bottom NVRAM values it showed Vendor HP and Model C9930A. So does that mean the firmware had been updated sometime in the past? I restored the backup drc and ran xsane as root again, but now it does not detect the device anymore. Until I power it off, wait 10 seconds, bring it back up and then it will detect the scanner with scanimage -L and xsane will run, but still cannot scan. My scan source shows 2 choices: Normal or ADF.

[Further edit:] I have noticed that I am getting an I/O error when xsane times out after trying Acquire preview. I am thinking that the DMA Timeout is being caused by this I/O error. I have a feeling that something is using or preventing the scanner from sending a scan to the computer. I now notice that the scanner light bar does run down the document after I changed SP=600 on its control panel interface. Any ideas how I can dig into this I/O thing? [/edit]

----------

## russK

 *mark2 wrote:*   

> I connected it to an XP machine, which recognized it and allowed it to scan a document. I downloaded the firmware update, but XP will not allow it to run. It complains that it cannot find a file named C9930A.bin when that is one of the very files the executable extracts. Even when run as Administrator. The file looks like a self-executing extractable (with the little C-clamp type icon), but I am not having any luck getting it to run. At least I know the scanner does work under Windows XP.

 

Seems strange that HP would leave a patch out there for years with a fundamental problem like that.  There must be a use case where it works.  Did you have any HP scanning software installed?  I notice they have a full scanning package available for download.

 *mark2 wrote:*   

> I backed up the drc as you suggested, but xsane did not create a new drc. Running sane-find-scanner produced:
> 
> ```
> sane-find-scanner
> 
> ...

 

Sorry I don't have any ideas there, whether it's the DMA thing or still related to trying to detect the ADF or something else.

Regards,

russk

----------

## bbgermany

OK guys,

I downloaded the firmware and extracted it in Windows with 7Zip. It definitily contains the bin-file, which is called by the setup. Maybe you should try to extract and run the setup.exe by hand in windows. Since i dont have a 8200 laying around for testing, im not able to check if the updater is faulty, but it seems, you really need this update, coz it fixes connection problems and dma timeouts.

greets, bb

----------

## mark2

I have downloaded 7zip and run it on the Windows Xp machine, but it does not do anything other than the original file. It comes up with the same error that it cannot find the file CXXX.bin even though the executable extracts it when it runs. This is just plain stupid. Since these are completely separate machines, for this file to be unable to run properly I cannot only conclude that the file itself is totally unusable.

I will be out of touch for the next week. If anyone has any further thoughts on this matter, I would be very appreciable.

----------

## mark2

After trying all of the above, I do not know what else there is to try. Since the bin file will not work regardless of the machine, Windows, or Linux, it seems that it is a faulty file and as it is so out of date, I guess I will abandon this one and look for a new scanner to purchase.

Thanks to all for all your help and suggestions. Hope someone else finds the information in this thread useful.

Cheers,

Mark

----------

