Subject: Has anybody got a CanoScan N1240U USB Scanner working with NetBSD?
To: None <current-users@netbsd.org>
From: Duncan McEwan <duncan@mcs.vuw.ac.nz>
List: current-users
Date: 01/06/2003 17:53:24
I sent the following message to netbsd-users a couple of days before Christmas,
but didn't get any replies.  It may be that was a bad time to send a message,
but I thought that perhaps none of the usb guru's read netbsd-users so I might
have more luck here.

One thing I forgot to mention in my original message was that I was trying this
on a 1.6D kernel dating from July 2002.  But I've subsequently tried it on a
1.6K kernel compiled in mid December.

Any hints greatly appreciated.

--- original message follows ---

I'm experimenting with the above scanner model to see if I can get it to
work with the sane pkgsrc package (sane-backends-1.0.9).

According to documentation on the sane web pages this scanner is not supported
by 1.0.9 ...

... BUT(!) ...

following a chain of links through various web pages eventually got me to
http://www.gjaeger.de/scanner/plustek.html and that page says that this scanner
is "mostly working" as of the 0.45TEST4 release of the Plustek backend.

So I followed the instructions on that page for updating the plustek backend
distributed with sane-backends-1.0.9 from whatever it was to 0.45TEST5
(basically just unpack the tar archive plustek-0.45-TEST5.tar.gz into the
toplevel of the sane-backends directory and recompile).

The sane-find-scanner command reports the following

| found USB scanner (vendor=0x04a9, product=0x220e) at libusb:/dev/usb0:/dev/ugen0
|   # A USB device was detected. This program can't be sure if it's really
|   # a scanner. If it is your scanner, it may or may not be supported by
|   # SANE. Try scanimage -L and read the backend's manpage.

But despite trying various options in /usr/pkg/etc/sane.d/plustek.conf I
haven't been able to get scanimage to find the scanner.

Setting the SANE_DEBUG_PLUSTEK and SANE_DEBUG_DLL environment variable to 12
(as recommended for debugging by the above web page) and
SANE_DEBUG_SANEI_LM983X to 16 and running the scanimage command produces too
much output to post here but I've extracted out what I *think* are relevant
parts below...

| ...
| [dll] load: searching backend `plustek' in `/usr/pkg/lib/sane'
| [dll] load: trying to load `/usr/pkg/lib/sane/libsane-plustek.so.1'
| [dll] load: dlopen()ing `/usr/pkg/lib/sane/libsane-plustek.so.1'
| [dll] init: initializing backend `plustek'
| [sanei_debug] Setting debug level of plustek to 12.
| [plustek] Plustek backend V0.45-TEST5, part of sane-backends 1.0.9
| [plustek] ># Plustek-SANE Backend configuration file<
| [plustek] ># For use with Plustek parallel-port scanners and<
| [plustek] ># LM9831/2/3 based USB scanners<
| [plustek] >#<
| ...
| [plustek] >[usb] 0x04a9 0x220e<
| [plustek] next device is a USB device (0x04A9-0x220E)
| [plustek] next device is an USB device
| [plustek] >device auto<
| [plustek] Decoding device name >auto<
| [plustek] ><
| ...
| [plustek] usbDev_open(auto,0x04A9-0x220E)
| [plustek] Found device at >libusb:/dev/usb0:/dev/ugen0<
| [plustek] Vendor ID=0x04A9, Product ID=0x220E
| [plustek] usbio_DetectLM983x
| [sanei_lm983x] sanei_lm983x_write: fd=0, reg=7, len=1, increment=0
| [sanei_lm983x] sanei_lm983x_write: succeeded
| [sanei_lm983x] sanei_lm983x_write: fd=0, reg=8, len=1, increment=0
| [sanei_lm983x] sanei_lm983x_write: succeeded
| [sanei_lm983x] sanei_lm983x_read: fd=0, reg=7, len=1, increment=0
| [sanei_lm983x] sanei_lm983x_read: writing command: 01 07 00 01

Then it pauses for 30 seconds (according to "ps", blocked on wchan "ugenrb")
before continuing with:

| [plustek] UIO error
| [plustek] This is not a LM9831 or LM9832 chip based scanner.
| [plustek] open failed: -1
| [dll] init: backend `plustek' is version 1.0.0
| ...
| scanimage: no SANE devices found

I did a ktrace of the scanimage to see what it was doing immediately before
and after it was blocked and found the following:

|  17372 scanimage CALL  open(0xbfbfc47c,0x2,0x1)
|  17372 scanimage NAMI  "/dev/ugen0.02"
|  17372 scanimage RET   open -1 errno 6 Device not configured
|  17372 scanimage CALL  open(0xbfbfc47c,0,0xbfbfc498)
|  17372 scanimage NAMI  "/dev/ugen0.02"
|  17372 scanimage RET   open 5
|  17372 scanimage CALL  ioctl(0x5,_IOW('U',0x72,0x4),0xbfbfc4f0)
|  17372 scanimage RET   ioctl 0
|  17372 scanimage CALL  ioctl(0x5,_IOW('U',0x71,0x4),0xbfbfc4c8)
|  17372 scanimage RET   ioctl 0
|  17372 scanimage CALL  read(0x5,0xbfbfc597,0x1)
|  ...
|  17372 scanimage RET   read -1 errno 60 Connection timed out

Unfortunately I don't know enough about usb to know why something (presumably
libusb?) was trying to read from /dev/ugen0.02 or whether that was the right
thing to be doing or why it should fail...

The only other potentially useful bit of information that I can think to
include here is the output from "usbdevs -v -d", which is:

| Controller /dev/usb0:
| addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), \
| Intel(0x8086), rev 1.00
|   uhub0
|  port 1 addr 2: full speed, power 500 mA, config 1, CanoScan(0x220e), \
| Canon(0x04a9), rev 1.00
|    ugen0
|  port 2 powered
| Controller /dev/usb1:
| addr 1: full speed, self powered, config 1, UHCI root hub(0x0000), \
| Intel(0x8086), rev 1.00
|   uhub1
|  port 1 powered
|  port 2 powered

Any advice on getting this scanner working will be greatfully accepted!

Thanks,

Duncan