On 2012.07.16 20:09, Alan Stern wrote:
> The device address is the actual value used on the USB bus to identify
> the device.  It is a 7-bit number, and it can take on any value from 0
> to 127.  However 0 is reserved for newly-connected devices; by the time
> a device has been enumerated its address will be > 0.
>
> The device number is the value used by the operating system or other
> software to identify the device.  Valid ranges will depend on the
> operating system.  Quite often it is the same as the device address,
> but not always.

Ah OK. Still not clear as to whether having Linux assign 1 to root hubs 
means that USB device addresses on the bus, for non newly connected 
devices, will start at 2, or at 1... From your USB-3 statement below, it 
seems that the OS rather than the HCD gets to decide what number goes on 
the bus, though Linux might just decrement the number before sending it 
on the bus.

On Windows, the value we use to set the libusbx device number, since I 
guess what matters to us here is what we should probably call "libusbx 
device number", is supposed to be the actual USB device address (for non 
root hubs). We basically pick the DeviceAddress field from 
USB_NODE_CONNECTION_INFORMATION_EX [1] (which, strangely enough, is set 
by Microsoft as an unsigned short...).

But with Windows not providing an OS device number (that I'm aware of) 
and other libusbx platforms using that number instead of the device 
address, we may still want to try to harmonize things. As far as I could 
see, OS-X and Linux seem to follow the same approach (though the bus 
numbering on OS-X is pretty wild). No idea about *BSD.

On the other hand, given that we can offer no guarantee that the libusbx 
device numbers will always be consistent, maybe providing our users with 
an expectation that they can rely on those may not be such a good idea...

> (In USB-3, for example, addresses are assigned
> automatically by the host controller hardware and not revealed to the
> operating system.  Consequently the OS has to make up a device number,
> which bears no relation to the device address.)

That's also good to know. I have to check how that translates to 
Windows. I guess the USB 3.0 driver makes up a device address for 
USB_NODE_CONNECTION_INFORMATION_EX.

> Getting back to the original question...  Root hubs do not have device
> addresses at all, because packets on the USB bus are never addressed to
> the root hub.  No packet sent by the host is meant for the root hub,
> whereas every packet sent by an external device is (again, with a few
> special exceptions in USB-3); either way there's no need for a root-hub
> address.

OK, then that means we probably can't get any descriptors for root hubs 
(at least in outside of the potential USB 3 exceptions, should they apply).

> However root hubs do have device numbers.  The value depends on the
> operating system.  In Linux the root hub's device number is always 1;
> In Windows the value currently used by libusbx is always 255.  The
> actual value is rather arbitrary, since it never appears on the USB
> bus.

OK. Since we have no OS device number to speak of on Windows, and since 
we have to choose anyway, we may want to try to bring it closer to what 
Linux does by using 1 for root hubs as well, and just increment the 
number we pick for configured devices.

Regards,

/Pete


[1] 
http://msdn.microsoft.com/en-us/library/windows/hardware/ff540094%28v=vs.85%29.aspx

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to