[sane-devel] canon lide 20 + mac os x + usb
Tue, 1 Jul 2003 10:53:15 +0200
On Tue, Jul 01, 2003 at 10:16:52AM +0200, Tobias Ernst wrote:
> I have compiled and installed libusb from CVS (28 June 2003), and after no
> success with the release version of sane I also installed sane from CVS
> (30 June 2003).
> sane-find-scanner does find the scanner:
> found USB scanner (vendor=0x04a9, product=0x220d) at libusb:001:002
sane-find-scanner also uses libusb.
> however as soon as I enable debugging to find out why, it DOES find the
> $ SANE_DEBUG_SANEI_USB=5 scanimage -L 2>/dev/null
> device `plustek:libusb:001:002' is a Canon N670U/N676U/LiDE20 USB
> flatbed scanner
> Further analysis reveals that SANE_DEBUG_SANEI_USB is the "culprit". As
> soon as it is set to 5 or any higher value, the scanner is found, while as
> long as it is 4 or lower, the scanner is not found. SANE_DEBUG and other
> environment variables do not matter.
> To me, this looks like a buffer overflow or a timing issue in sanei_usb.
If it's really the change from 4 to 5 I'd rather suspect the following
line in sanei_usb.c:
if (DBG_LEVEL > 4)
Try to comment out the if clause so usb_set_debug is always called.
Does it work without debugging in that case? If yes, I'd rather
suspect a problem in libusb.
I haven't heard about similar problems on MacOS X, however.
> I decided to continue anyway, but with no success:
> $ SANE_DEBUG_SANEI_USB=255 SANE_DEBUG=255 SANE_DEBUG_PLUSTEK=255
> scanimage 2>lide20-osx.log
> # SANE data follows
> 248 150
> After that, the process stops. I.e., the plustek backend gets loaded and
> starts to do something, but fails as soon as actual data should be
> I am attaching lide20-osx.log, maybe someone can make some sense out of it.
[plustek] reader_process started
[plustek] reader_process:starting to READ data (111600 bytes)
[sanei_usb] sanei_usb_write_bulk: trying to write 4 bytes
[sanei_usb] 0000: 01 02 00 01 ................
Converting ep address to pipeRef.
ep_to_pipeRef: an error occurred getting pipe information on pipe 1
ep_to_pipeRef: An unknown error occured
[sanei_usb] sanei_usb_write_bulk: write failed: No such file or directory
USB error: usb_clear_halt: error clearing pipe stall
The plustek backend uses fork() to create its reader process. That
doesn't work on MacOS X. To be exact, it's not possible to access the
already open USB device from the child process. This can only be fixed
when MacOS X starts to use file descriptors for accessing USB devives.
Maybe it'd also work if SANE on MacOS X therads were used instead of a
new process? Check the archive of sane-devel for discussions on this