[sane-devel] USB problems with SANE on MacOS

Umberto Cerrato umbertocerrato at outlook.it
Sun Apr 28 09:23:46 BST 2019

Hi Oliver,

Finally I see some macOS users around…

I’m really glad you have found a solution. It’s a while “we” not-expert Macintosh users cannot use sane-backends anymore. (We used to use Mattias Ellert pkgs…)

Anyway I cannot help you, I would though.

I would like to try this patch, how can I do?

Another thing: since the Mac recognize the USB Scanner already, would it be possible to utilize the default macOS library for handling usb devices? So configuring sane-backends with this instead of libusb. I’m just asking. I tried searching something, I found old Apple Developer articles about it – e.g. https://developer.apple.com/library/archive/documentation/DeviceDrivers/Conceptual/USBBook/USBIntro/USBIntro.html#//apple_ref/doc/uid/TP40002643-TPXREF101

As a Mac enthusiast I would really like something “native”. (Hope you understand what I mean)


I sent it again since I didn’t made “reply to all” (mailing list too).
Have a nice day.

> Il giorno 26 apr 2019, alle ore 19:56, Oliver Schwartz <Oliver.Schwartz at gmx.de> ha scritto:
> Hi all,
> I dived into scanning with SANE on MacOS using homebrew in the last few days.
> Back in 2017 two problems were reported ( https://alioth-lists.debian.net/pipermail/sane-devel/2017-July/035508.html ) : The first one, old dependencies on libusb-compat was resolved in homebrew. The second one, sanei_usb barking at unconfigured devices, was not addressed as far as I can see and in fact the same problem bit me when using the snapscan backend.
> I did some googling and found this remark from the libusb-devel mailing list: ( https://sourceforge.net/p/libusb/mailman/message/27491908/ )
>> … OS X won't 
>> automatically configure a device if its descriptors are 
>> vendor-specific (meaning that the device must be configured through 
>> libusb).  But Linux will.
> Looking at the code in sanei_usb.c, libusb_scan_devices() ignores devices that are not configured. sanei_usb_open() returns SANE_STATUS_INVAL when the device is not configured. If it is configured, it is actually configured again.
> I made a crude patch that just continues execution for non-configured devices (this is against sane-backends-1.0.27):
> diff --git a/sanei/sanei_usb.c b/sanei/sanei_usb.c
> index e4b23dc..294c64b 100644
> --- a/sanei/sanei_usb.c
> +++ b/sanei/sanei_usb.c
> @@ -936,7 +936,7 @@ static void libusb_scan_devices(void)
> 	  DBG (1,
> 	       "%s: device 0x%04x/0x%04x at %03d:%03d is not configured\n", __func__,
> 	       vid, pid, busno, address);
> -	  continue;
> +	  /* continue; */
> 	}
>       ret = libusb_get_config_descriptor (dev, 0, &config0);
> @@ -1640,7 +1640,7 @@ sanei_usb_open (SANE_String_Const devname, SANE_Int * dn)
>       if (config == 0)
> 	{
> 	  DBG (1, "sanei_usb_open: device `%s' not configured?\n", devname);
> -	  return SANE_STATUS_INVAL;
> +	  /*return SANE_STATUS_INVAL; */
> 	}
>       result = libusb_get_device_descriptor (dev, &desc);
> This works for me and I can now use scanimage on MacOS with my scanner. However, this is hardly the final solution. Can someone with more knowledge on USB comment on this? Is the check for non-configured devices really useful when the device is actually configured later? Should this check only be removed on MacOS? Are there any side effects to be expected?
> Kind regards,
> Oliver
> -- 
> sane-devel mailing list: sane-devel at alioth-lists.debian.net
> https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/sane-devel
> Unsubscribe: Send mail with subject "unsubscribe your_password"
>             to sane-devel-request at lists.alioth.debian.org

More information about the sane-devel mailing list