<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>I was too fast in sending my mail - should have grabbed a coffee first...</div>

<div> </div>

<div>Of course I am not done and don't have a solution yet: I am still missing the link to the SANE_Device (especially its name). I just found the correct USB device using a different solution than I posted before (creating the device name on my own vs. probing all vendor/product-matching devices).</div>

<div> </div>

<div>If I read the backend sources correctly, the backends create the device names. So there is no standardized naming scheme that applies to all SANE devices.</div>

<div> </div>

<div>So I am currently back where I started: still looking for a link between the USB device and SANE device.</div>

<div> </div>

<div>- Sven</div>

<div> </div>

<div>
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><span style="line-height: 1.6em;">Thanks for sharing your thoughts!</span>

<div name="quoted-content">
<div style="font-family: Verdana;font-size: 12.0px;">
<div> </div>

<div>I looked into the sources of libusb and found this:</div>

<div> </div>

<div><span style="line-height: normal;font-family: Verdana , sans-serif , Arial , "Trebuchet MS";font-size: 13.0px;">/** \ingroup dev</span></div>

<div>
<pre style="line-height: normal;"> * Get the number of the bus that a device is connected to.
 * \param dev a device
 * \returns the bus number
 */
uint8_t API_EXPORTED libusb_get_bus_number(libusb_device *dev)
{
        return dev->bus_number;
}

/** \ingroup dev
 * Get the address of the device on the bus it is connected to.
 * \param dev a device
 * \returns the device address
 */
uint8_t API_EXPORTED libusb_get_device_address(libusb_device *dev)
{
        return dev->device_address;
}
</pre>

<div><span style="font-family: Verdana , sans-serif , Arial , "Trebuchet MS";font-size: 13.0px;line-height: 1.6em;">As far as I know there is no way to get the pointer to the libusb_device from SANE(i).</span></div>

<div><span style="font-family: Verdana , sans-serif , Arial , "Trebuchet MS";font-size: 13.0px;line-height: 1.6em;">I played around with </span><span style="font-family: Verdana , sans-serif , Arial , "Trebuchet MS";font-size: 13.0px;line-height: 1.6em;">sanei_usb_control_msg and got (i.e.) the device descriptor, but this does not help me.</span></div>

<div> </div>

<div>But finally I found a solution: I am using sanei_usb_find_devices with the vendor and product I am looking for and check for the correct bus number and address in the attach function. This works, but is highly unefficient as the information is actually already there (sanei_usb.c: 'devices' array) and I do many cycles around it.</div>

<div> </div>

<div>Thank you again for leading me to the solution. :)</div>

<div> </div>

<div>- Sven</div>

<div> </div>
</div>

<div>
<div style="margin: 10.0px 5.0px 5.0px 10.0px;padding: 10.0px 0 10.0px 10.0px;border-left: 2.0px solid rgb(195,217,229);">
<div>dunno if this will help, just thinking out loud (since i've been<br/>
mucking around recently with sane and libusb...)<br/>
<br/>
i presume this isn't a question of just differentiating between<br/>
scanners with different vid/pids, but rather a situation with<br/>
essentially identical scanners in different physical locations. you<br/>
could, if the backend provides it, differentiate by serial number, i<br/>
suppose.<br/>
<br/>
another approach might be to enumerate all the scanners that match the<br/>
vid/pid of your libusb device, then send each one a<br/>
sanei_usb_control_msg and see if the response is what you're looking<br/>
for.<br/>
<br/>
good luck! please post your solution to the list when you come up with it :)<br/>
<br/>
<br/>
<br/>
On Fri, Mar 21, 2014 at 2:48 PM, Sven Harmstorf <svh79@gmx.net> wrote:<br/>
> This is out of my control: my (part of the) application gets called with a<br/>
> libusb_device pointer and asks me to perform a scan.<br/>
><br/>
> - Sven<br/>
><br/>
> On Fri, Mar 21, 2014 at 8:51 AM, Sven Harmstorf <svh79@gmx.net> wrote:<br/>
>> I could create the USB device name ('libusb:000:0000' or 'usb 0x0000<br/>
>> 0x0000') and use sanei_usb_open() to get the device number which is used<br/>
>> by<br/>
>> most sanei_usb functions. But this would also not get me the device name I<br/>
>> need for the public SANE API functions.<br/>
>> Background:<br/>
>><br/>
>> My application receives a scan request (addressed to a libusb_device) and<br/>
>> I<br/>
>> have to process and forward that request to the corresponding SANE_Device.<br/>
>> As there are several identical devices attached via USB and the caller of<br/>
>> my<br/>
>> application does not know anything about SANE, I need the USB bus and<br/>
>> address to identify the correct SANE device. My application only supports<br/>
>> scanners attached via USB, as it will be run on an embedded system which<br/>
>> does not provide any other ports than USB.<br/>
><br/>
> How does your app get the indication of which libusb device to scan from?<br/>
><br/>
> allan<br/>
> --<br/>
> "The truth is an offense, but not a sin"<br/>
><br/>
> --<br/>
> sane-devel mailing list: sane-devel@lists.alioth.debian.org<br/>
> <a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel</a><br/>
> Unsubscribe: Send mail with subject "unsubscribe your_password"<br/>
> to sane-devel-request@lists.alioth.debian.org</div>
</div>
</div>
</div>
-- sane-devel mailing list: sane-devel@lists.alioth.debian.org <a href="http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel" target="_blank">http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel</a> Unsubscribe: Send mail with subject "unsubscribe your_password" to sane-devel-request@lists.alioth.debian.org</div>
</div>
</div></div></body></html>