From owner-freebsd-usb@FreeBSD.ORG Mon Sep 15 11:43:48 2014 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0F4D222B for ; Mon, 15 Sep 2014 11:43:48 +0000 (UTC) Received: from mail-lb0-x22b.google.com (mail-lb0-x22b.google.com [IPv6:2a00:1450:4010:c04::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8C20C77D for ; Mon, 15 Sep 2014 11:43:47 +0000 (UTC) Received: by mail-lb0-f171.google.com with SMTP id 10so4280904lbg.2 for ; Mon, 15 Sep 2014 04:43:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=PmQwaxOHZyWNggNgSPrKuoplYT5kapsDq7OL/D2nq0o=; b=Z3eugdu1LAnNeRwezUFKMJ8Yf4DUSmWLXA+vAH/E9JSORnuF8Itnv8cTURYJj/ZuhG ey0XwKUapcn55XVPoUQ7KMOw937wFwvVnqwcg4wCHpyqiQJ9GaXkxYa4he15LPW+Isyt betOSCb+NFy+mA5814d4WjiRRzV/3FsjJptArKb/DoBwuwl8qmSMSTyuZmIWOzHcKFrp i1AgEr/0HlaEWCv26nq3xgLzQZbCMYzEvjsayHX234CcCgUkAcdTwlFIfW6Py6grTUl1 vd4gDIVyJpo+862sDmt6qUOdVpV8vp7MR1cQzOb5ZyjEwn8n64zlk13Dc3gYE7OSHUzt hmMw== X-Received: by 10.152.115.232 with SMTP id jr8mr8931173lab.69.1410781425312; Mon, 15 Sep 2014 04:43:45 -0700 (PDT) Received: from [172.29.2.131] (altimet-gw.cs2.dp.wnet.ua. [217.20.178.249]) by mx.google.com with ESMTPSA id u8sm1817125lbb.25.2014.09.15.04.43.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Sep 2014 04:43:44 -0700 (PDT) Message-ID: <5416D0E8.3030806@gmail.com> Date: Mon, 15 Sep 2014 14:43:36 +0300 From: Vitaly Magerya User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.0 MIME-Version: 1.0 To: freebsd-usb@freebsd.org Subject: How to obtain the "ugen" that corresponds to an "ums", "uep" or "uhid"? Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-usb@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: FreeBSD support for USB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Sep 2014 11:43:48 -0000 Hi, folks. Is there a way to obtain the name of an ugen device that corresponds to a particular ums/uep/uhid device? 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.
dump_device_desc The question is how should the script obtain these and
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
number in the "devaddr" variable, but the correct number is nowhere to be found. So, again, given an ums/uep/uhid device name (and, possibly
number), how should one fine what to pass into usbconfig's "ugen.
" parameter? (This question is triggered by the discussion in PR 183478 [1]). [1] https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=183478