How to obtain the "ugen" that corresponds to an "ums", "uep" or "uhid"?

Hans Petter Selasky hps at selasky.org
Mon Sep 15 12:07:29 UTC 2014


On 09/15/14 13:43, Vitaly Magerya wrote:
> Hi, folks. Is there a way to obtain the name of an ugen device that
> corresponds to a particular ums/uep/uhid device?

Hi,

Have you tried:

usbconfig show_ifdrv

> The situation I'm working with is this: there's a (custom) DEVD
> rule that executes a script when any new "ums" or "uhid" device is
> created. This script has access to the device name (and any other
> info DEVD provides), and needs to figure out manufacturer name,
> product name and ID numbers of this device. To do that, it parses
> the output of this command:
>
>      usbconfig -d ugen<unit>.<address> dump_device_desc
>
> The question is how should the script obtain these <unit> and
> <address> numbers?
>
> Now, when a new device is attached DEVD receives a message like this:
>
>      +uhid0 at bus=1 hubaddr=1 port=3 devaddr=2 interface=0
>      vendor=0x0079 product=0x0011 devclass=0x00 devsubclass=0x00
>      sernum="" release=0x0106 mode=host intclass=0x03 intsubclass=0x00
>      intprotocol=0x00  on uhub0
>
>      (The correct ugen for this device happens to be ugen3.2).
>
> ... or a message like this:
>
>      +ums0 at bus=0 hubaddr=2 port=2 devaddr=3 interface=1
>      vendor=0x046d product=0xc52b devclass=0x00 devsubclass=0x00
>      sernum="" release=0x1201 mode=host intclass=0x03 intsubclass=0x01
>      intprotocol=0x02  on uhub3
>
>      (In this case the correct ugen is ugen0.3).
>
> It seems that we have the correct <address> number in the "devaddr"
> variable, but the correct <unit> number is nowhere to be found.
>

That might be a bug. We can easily add a unit=%d argument to the devd 
events, if not already there.

> So, again, given an ums/uep/uhid device name (and, possibly
> <address> number), how should one fine what to pass into
> usbconfig's "ugen<unit>.<address>" parameter?
>
> (This question is triggered by the discussion in PR 183478 [1]).
>
> [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=183478

--HPS



More information about the freebsd-usb mailing list