SANE vs USB scanner on 8.0

View: New views
7 Messages — Rating Filter:   Alert me  

SANE vs USB scanner on 8.0

by Daniel O'Connor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
I'm trying to get a USB scanner to work with FreeBSD 8.0, it did work
with 7.2 via uscanner.

It's an AcerScan 620U and I have the firmware and
modified /usr/local/etc/sane.d/snapscan.conf.

sane-find-scanner sees it, eg
[midget 22:37] ~ >sudo sane-find-scanner  -q
found USB scanner (vendor=0x04a5 [Color], product=0x2060 [ FlatbedScanner 13]) at libusb:/dev/usb:/dev/ugen0.5
found USB scanner (vendor=0x0403 [FTDI], product=0xee18 [MaxStream PKG-U]) at libusb:/dev/usb:/dev/ugen1.2

I have no idea why the FTDI serial device appears there..

However scanimage -L doesn't show the scanner..
[midget 22:40] ~ >sudo env SANE_DEBUG_SNAPSCAN=255 scanimage -v -v -L
[sanei_debug] Setting debug level of snapscan to 255.
[snapscan] sane_snapscan_init
[snapscan] sane_snapscan_init: Snapscan backend version 1.4.53
[snapscan] add_usb_device(libusb:/dev/usb:/dev/ugen0.5)
[snapscan] add_usb_device: Detected (kind of) an USB device
[snapscan] snapscani_usb_open(libusb:/dev/usb:/dev/ugen0.5)
[snapscan] snapscani_mutex_open: could not parse device string: No such file or directory
[snapscan] snapscani_usb_open: Can't get semaphore
[snapscan] add_usb_device: error opening device libusb:/dev/usb:/dev/ugen0.5: Invalid argument
[snapscan] sane_snapscan_get_devices (0x7fffffffe200, 0)

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).
Calling sane_exit
[snapscan] sane_snapscan_exit
scanimage: finished

Anyone have any suggestions?

--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C


signature.asc (195 bytes) Download Attachment

Re: SANE vs USB scanner on 8.0

by Hans Petter Selasky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Monday 28 September 2009 15:10:52 Daniel O'Connor wrote:

> Hi,
> I'm trying to get a USB scanner to work with FreeBSD 8.0, it did work
> with 7.2 via uscanner.
>
> It's an AcerScan 620U and I have the firmware and
> modified /usr/local/etc/sane.d/snapscan.conf.
>
> sane-find-scanner sees it, eg
> [midget 22:37] ~ >sudo sane-find-scanner  -q
> found USB scanner (vendor=0x04a5 [Color], product=0x2060 [ FlatbedScanner
> 13]) at libusb:/dev/usb:/dev/ugen0.5 found USB scanner (vendor=0x0403
> [FTDI], product=0xee18 [MaxStream PKG-U]) at libusb:/dev/usb:/dev/ugen1.2
>
> I have no idea why the FTDI serial device appears there..
>
> However scanimage -L doesn't show the scanner..
> [midget 22:40] ~ >sudo env SANE_DEBUG_SNAPSCAN=255 scanimage -v -v -L
> [sanei_debug] Setting debug level of snapscan to 255.
> [snapscan] sane_snapscan_init
> [snapscan] sane_snapscan_init: Snapscan backend version 1.4.53
> [snapscan] add_usb_device(libusb:/dev/usb:/dev/ugen0.5)
> [snapscan] add_usb_device: Detected (kind of) an USB device
> [snapscan] snapscani_usb_open(libusb:/dev/usb:/dev/ugen0.5)
> [snapscan] snapscani_mutex_open: could not parse device string: No such
> file or directory [snapscan] snapscani_usb_open: Can't get semaphore
> [snapscan] add_usb_device: error opening device
> libusb:/dev/usb:/dev/ugen0.5: Invalid argument [snapscan]
> sane_snapscan_get_devices (0x7fffffffe200, 0)
>
> 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).
> Calling sane_exit
> [snapscan] sane_snapscan_exit
> scanimage: finished
>
> Anyone have any suggestions?

Hi,

Try this patch:

diff -u ./work/sane-backends-1.0.20/backend/snapscan-mutex.c ./snapscan-
mutex.c
--- ./work/sane-backends-1.0.20/backend/snapscan-mutex.c        2008-03-28
21:39:02.000000000 +0100
+++ ./snapscan-mutex.c  2009-09-28 15:33:41.000000000 +0200
@@ -130,7 +130,8 @@
            return 0;
        }
 
-       if (sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2)
+       if ((sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2) &&
+           (sscanf(dev, "libusb:/dev/usb:ugen%d.%d", &busnum, &devnum) != 2))
        {
            DBG (DL_MAJOR_ERROR, "%s: could not parse device string: %s\n",
me, strerror(errno));
            return 0;

If it works, get the patch sent to the sane developers.

--HPS

_______________________________________________
freebsd-usb@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscribe@..."

Re: SANE vs USB scanner on 8.0

by Daniel O'Connor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 28 Sep 2009, Hans Petter Selasky wrote:

> -       if (sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2)
> +       if ((sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2) &&
> +           (sscanf(dev, "libusb:/dev/usb:ugen%d.%d", &busnum,
> &devnum) != 2)) {
>             DBG (DL_MAJOR_ERROR, "%s: could not parse device string:
> %s\n", me, strerror(errno));
>             return 0;
>
> If it works, get the patch sent to the sane developers.

Unfortunately no (I reworked it to match the path it uses) and now it
segfaults. I rebuilt sane with debugging (is there some way to make libtool
not strip on install? It's so tedious manually editing makefiles to remove
-s..) as well as libusb.

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 801b021c0 (LWP 100292)]
0x000000080140e715 in libusb20_dev_open (pdev=0x801b13d00, nTransferMax=32)
    at /usr/src/lib/libusb/libusb20.c:550
550             error = pdev->beMethods->open_device(pdev, nTransferMax);
(gdb) bt
#0  0x000000080140e715 in libusb20_dev_open (pdev=0x801b13d00, nTransferMax=32)
    at /usr/src/lib/libusb/libusb20.c:550
#1  0x0000000801408f15 in usb_open (dev=0x801b1ae00)
    at /usr/src/lib/libusb/libusb20_compat01.c:150
#2  0x000000080065c34f in sanei_usb_open (
    devname=0x801b09380 "libusb:/dev/usb:/dev/ugen0.5", dn=0x7fffffffdc0c)
    at sanei_usb.c:1143
#3  0x00000008025e5ad3 in snapscani_usb_open (
    dev=0x801b09380 "libusb:/dev/usb:/dev/ugen0.5", fdp=0x7fffffffdc0c,
    sense_handler=0x8025df7c0 <sense_handler>, pss=0x0) at snapscan-usb.c:178
#4  0x00000008025eb985 in add_usb_device (
    full_name=0x801b09080 "libusb:/dev/usb:/dev/ugen0.5") at snapscan.c:590
#5  0x000000080065c0ed in sanei_usb_find_devices (vendor=1189, product=8288,
    attach=0x8025eb880 <add_usb_device>) at sanei_usb.c:1091
#6  0x000000080065bb3e in sanei_usb_attach_matching_devices (name=0x7fffffffdcc1 "",
    attach=0x8025eb880 <add_usb_device>) at sanei_usb.c:965
#7  0x00000008025ebdac in sane_snapscan_init (version_code=0x7fffffffe0f8,
    authorize=0x401b50 <auth_callback>) at snapscan.c:735
#8  0x000000080066579b in init (be=0x801b0da00) at dll.c:613
#9  0x000000080066621b in sane_dll_get_devices (device_list=0x7fffffffea00,
---Type <return> to continue, or q <return> to quit---
    local_only=0) at dll.c:1034
#10 0x0000000800658bbb in sane_get_devices (dl=0x7fffffffea00, local=0) at dll-s.c:17
#11 0x0000000000405a11 in main (argc=4, argv=0x7fffffffeb30) at scanimage.c:1771
(gdb) print *pdev
$1 = {ddesc = {LIBUSB20_DEVICE_DESC_FORMAT = 0x0, bLength = 0 '\0',
    bDescriptorType = 0 '\0', bcdUSB = 0, bDeviceClass = 0 '\0',
    bDeviceSubClass = 0 '\0', bDeviceProtocol = 0 '\0', bMaxPacketSize0 = 0 '\0',
    idVendor = 0, idProduct = 0, bcdDevice = 0, iManufacturer = 0 '\0',
    iProduct = 0 '\0', iSerialNumber = 0 '\0', bNumConfigurations = 0 '\0'},
  session_data = {session_data = 0, tv = {tv_sec = 0, tv_nsec = 0}, plugtime = 0},
  dev_entry = {tqe_next = 0x0, tqe_prev = 0x0}, methods = 0x0, beMethods = 0x0,
  pTransfer = 0x801b48500, privBeData = 0x0, privLuData = 0x0,
  claimed_interface = 0 '\0', file = 0, file_ctrl = 0, debug = 0, nTransfer = 32,
  bus_number = 0 '\0', device_address = 0 '\0', usb_mode = 0 '\0',
  usb_speed = 0 '\0', is_opened = 0 '\0', usb_desc = '\0' <repeats 95 times>}
(gdb) up
#1  0x0000000801408f15 in usb_open (dev=0x801b1ae00)
    at /usr/src/lib/libusb/libusb20_compat01.c:150
150             err = libusb20_dev_open(dev->dev, 16 * 2);
(gdb) print *dev
$2 = {next = 0x0, prev = 0x0, filename = "/dev/ugen0.5", '\0' <repeats 1012 times>,
  bus = 0x801510020, descriptor = {bLength = 18 '\022', bDescriptorType = 1 '\001',
    bcdUSB = 256, bDeviceClass = 255 'ÿ', bDeviceSubClass = 255 'ÿ',
    bDeviceProtocol = 255 'ÿ', bMaxPacketSize0 = 8 '\b', idVendor = 1189,
    idProduct = 8288, bcdDevice = 256, iManufacturer = 1 '\001',
    iProduct = 2 '\002', iSerialNumber = 0 '\0', bNumConfigurations = 1 '\001'},
  config = 0x801b23280, dev = 0x801b13d00, devnum = 0 '\0', num_children = 0 '\0',
  children = 0x0}
(gdb) print dev->dev
$3 = (void *) 0x801b13d00
(gdb) up
#2  0x000000080065c34f in sanei_usb_open (
    devname=0x801b09380 "libusb:/dev/usb:/dev/ugen0.5", dn=0x7fffffffdc0c)
    at sanei_usb.c:1143
1143          devices[devcount].libusb_handle =
(gdb) list
1138    #ifdef HAVE_LIBUSB
1139          struct usb_device *dev;
1140          struct usb_interface_descriptor *interface;
1141          int result, num;
1142
1143          devices[devcount].libusb_handle =
1144            usb_open (devices[devcount].libusb_device);
1145          if (!devices[devcount].libusb_handle)
1146            {
1147              SANE_Status status = SANE_STATUS_INVAL;
(gdb) print *devices[devcount].libusb_device
$4 = {next = 0x0, prev = 0x0, filename = "/dev/ugen0.5", '\0' <repeats 1012 times>,
  bus = 0x801510020, descriptor = {bLength = 18 '\022', bDescriptorType = 1 '\001',
    bcdUSB = 256, bDeviceClass = 255 'ÿ', bDeviceSubClass = 255 'ÿ',
    bDeviceProtocol = 255 'ÿ', bMaxPacketSize0 = 8 '\b', idVendor = 1189,
    idProduct = 8288, bcdDevice = 256, iManufacturer = 1 '\001',
    iProduct = 2 '\002', iSerialNumber = 0 '\0', bNumConfigurations = 1 '\001'},
  config = 0x801b23280, dev = 0x801b13d00, devnum = 0 '\0', num_children = 0 '\0',
  children = 0x0}

--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C


signature.asc (195 bytes) Download Attachment

Re: SANE vs USB scanner on 8.0

by Daniel O'Connor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, 30 Sep 2009, Daniel O'Connor wrote:

> On Mon, 28 Sep 2009, Hans Petter Selasky wrote:
> > -       if (sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2)
> > +       if ((sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2) &&
> > +           (sscanf(dev, "libusb:/dev/usb:ugen%d.%d", &busnum,
> > &devnum) != 2)) {
> >             DBG (DL_MAJOR_ERROR, "%s: could not parse device
> > string: %s\n", me, strerror(errno));
> >             return 0;
> >
> > If it works, get the patch sent to the sane developers.
>
> Unfortunately no (I reworked it to match the path it uses) and now it
> segfaults. I rebuilt sane with debugging (is there some way to make
> libtool not strip on install? It's so tedious manually editing
> makefiles to remove -s..) as well as libusb.
Have you had a chance to look at this? :)

Thanks.

PS I'm not subscribed to usb@ so perhaps I missed a reply.

--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C


signature.asc (195 bytes) Download Attachment

Re: SANE vs USB scanner on 8.0

by Hans Petter Selasky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 29 October 2009 04:55:53 Daniel O'Connor wrote:

> On Wed, 30 Sep 2009, Daniel O'Connor wrote:
> > On Mon, 28 Sep 2009, Hans Petter Selasky wrote:
> > > -       if (sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2)
> > > +       if ((sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2) &&
> > > +           (sscanf(dev, "libusb:/dev/usb:ugen%d.%d", &busnum,
> > > &devnum) != 2)) {
> > >             DBG (DL_MAJOR_ERROR, "%s: could not parse device
> > > string: %s\n", me, strerror(errno));
> > >             return 0;
> > >
> > > If it works, get the patch sent to the sane developers.
> >
> > Unfortunately no (I reworked it to match the path it uses) and now it
> > segfaults. I rebuilt sane with debugging (is there some way to make
> > libtool not strip on install? It's so tedious manually editing
> > makefiles to remove -s..) as well as libusb.
>
> Have you had a chance to look at this? :)
>
> Thanks.
>
> PS I'm not subscribed to usb@ so perhaps I missed a reply.

No. Please file a bug-report on the sane mailing list.

--HPS
_______________________________________________
freebsd-usb@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscribe@..."

Re: SANE vs USB scanner on 8.0

by Daniel O'Connor-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 29 Oct 2009, Hans Petter Selasky wrote:

> On Thursday 29 October 2009 04:55:53 Daniel O'Connor wrote:
> > On Wed, 30 Sep 2009, Daniel O'Connor wrote:
> > > On Mon, 28 Sep 2009, Hans Petter Selasky wrote:
> > > > -       if (sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2)
> > > > +       if ((sscanf(dev, "libusb:%d:%d", &busnum, &devnum) !=
> > > > 2) && +           (sscanf(dev, "libusb:/dev/usb:ugen%d.%d",
> > > > &busnum, &devnum) != 2)) {
> > > >             DBG (DL_MAJOR_ERROR, "%s: could not parse device
> > > > string: %s\n", me, strerror(errno));
> > > >             return 0;
> > > >
> > > > If it works, get the patch sent to the sane developers.
> > >
> > > Unfortunately no (I reworked it to match the path it uses) and
> > > now it segfaults. I rebuilt sane with debugging (is there some
> > > way to make libtool not strip on install? It's so tedious
> > > manually editing makefiles to remove -s..) as well as libusb.
> >
> > Have you had a chance to look at this? :)
> >
> > Thanks.
> >
> > PS I'm not subscribed to usb@ so perhaps I missed a reply.
>
> No. Please file a bug-report on the sane mailing list.
Hmm, but isn't the crash in libusb?

(I understand that it may be possible that sane is using libusb badly
however!)

--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C


signature.asc (195 bytes) Download Attachment

Re: SANE vs USB scanner on 8.0

by Hans Petter Selasky :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thursday 29 October 2009 13:43:23 Daniel O'Connor wrote:

> On Thu, 29 Oct 2009, Hans Petter Selasky wrote:
> > On Thursday 29 October 2009 04:55:53 Daniel O'Connor wrote:
> > > On Wed, 30 Sep 2009, Daniel O'Connor wrote:
> > > > On Mon, 28 Sep 2009, Hans Petter Selasky wrote:
> > > > > -       if (sscanf(dev, "libusb:%d:%d", &busnum, &devnum) != 2)
> > > > > +       if ((sscanf(dev, "libusb:%d:%d", &busnum, &devnum) !=
> > > > > 2) && +           (sscanf(dev, "libusb:/dev/usb:ugen%d.%d",
> > > > > &busnum, &devnum) != 2)) {
> > > > >             DBG (DL_MAJOR_ERROR, "%s: could not parse device
> > > > > string: %s\n", me, strerror(errno));
> > > > >             return 0;
> > > > >
> > > > > If it works, get the patch sent to the sane developers.
> > > >
> > > > Unfortunately no (I reworked it to match the path it uses) and
> > > > now it segfaults. I rebuilt sane with debugging (is there some
> > > > way to make libtool not strip on install? It's so tedious
> > > > manually editing makefiles to remove -s..) as well as libusb.
> > >
> > > Have you had a chance to look at this? :)
> > >
> > > Thanks.
> > >
> > > PS I'm not subscribed to usb@ so perhaps I missed a reply.
> >
> > No. Please file a bug-report on the sane mailing list.
>
> Hmm, but isn't the crash in libusb?
>
> (I understand that it may be possible that sane is using libusb badly
> however!)

I think it is some freed' libusb memory structure pointers which are passed
into libusb. There was a similar issue fixed in another sane USB driver
recently.

Existing drivers have some assumptions about that after a USB bus scan that
the device nodes are still existing for already existing devices returned in
previous scans, which is not true for LibUSB under FreeBSD.

The libUSB device pointer usage in sane needs to be audited. Probably it is
best to figure out where the following functions are called:

 usb_find_busses() usb_find_devices() usb_device()
     usb_get_busses()

And carefully check how the libusb device handle pointers are updated.

--HPS

_______________________________________________
freebsd-usb@... mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscribe@..."