From owner-freebsd-usb@FreeBSD.ORG Tue Jan 20 11:06:26 2015 Return-Path: Delivered-To: freebsd-usb@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6B55866B for ; Tue, 20 Jan 2015 11:06:26 +0000 (UTC) Received: from mx0.starion.dk (mx0.starion.dk [93.162.70.34]) by mx1.freebsd.org (Postfix) with ESMTP id 23CC4CD8 for ; Tue, 20 Jan 2015 11:06:25 +0000 (UTC) X-tst: NONE (10.1.1.21) X-tst: NONE (10.1.1.21) Received: from mailstore.starion.info (unknown [10.1.1.21]) by mx0.starion.dk (Postfix) with SMTP id 33ABF2BD9B1; Tue, 20 Jan 2015 12:06:32 +0100 (CET) Received: (nullmailer pid 56208 invoked by uid 1004); Tue, 20 Jan 2015 11:06:32 -0000 Message-ID: <54BE36AC.9050904@uffe.org> Date: Tue, 20 Jan 2015 12:06:20 +0100 From: Uffe Jakobsen User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Hans Petter Selasky , freebsd-usb@freebsd.org Subject: Re: Problem with libusb20_dev_get_port_path() References: <54BD9460.90607@uffe.org> <54BDDB11.3070800@selasky.org> In-Reply-To: <54BDDB11.3070800@selasky.org> Content-Type: text/plain; charset=windows-1252; 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: Tue, 20 Jan 2015 11:06:26 -0000 On 2015-01-20 05:35, Hans Petter Selasky wrote: > On 01/20/15 00:33, Uffe Jakobsen wrote: >> >> I seem to be having a problem with libusb20_dev_get_port_path() >> >> I iterate through all usb devices in the system. >> libusb20_dev_get_port_path() returns 0 for all my usb devices. >> >> Any hints ? >> >> Seen on FreeBSD 10.1 (amd64) with latest patches > > Did you do a: > > libusb20_dev_open() > > first? > yes - without that I get an error (negative return code) Running as root does not change anything (I didn't expect that - but I had to try) Stripped sample code below produces the following output: # ./a.out BEGIN device descriptor: 'ugen0.1: at usbus0' get_port_path: 0 device descriptor: 'ugen2.1: at usbus2' get_port_path: 0 device descriptor: 'ugen1.1: at usbus1' get_port_path: 0 device descriptor: 'ugen4.1: at usbus4' get_port_path: 0 device descriptor: 'ugen3.1: at usbus3' get_port_path: 0 device descriptor: 'ugen3.2: at usbus3' get_port_path: 0 END // // Compile: cc tst.c -lusb // #include #include #include #include #include #include int main(int argc, char** argv) { int rc; struct libusb20_backend* pbe; struct libusb20_device* pdev_curr; struct libusb20_device* pdev_last; uint8_t usb_ports[UINT8_MAX]; char sbuf[FILENAME_MAX]; char *p_str; printf("BEGIN\n"); pbe = libusb20_be_alloc_default(); pdev_curr = pdev_last = NULL; do { pdev_curr = libusb20_be_device_foreach(pbe, pdev_last); if (pdev_curr == NULL) { break; } libusb20_dev_open(pdev_curr, 0); p_str = (char*)libusb20_dev_get_desc(pdev_curr); printf("device descriptor: '%s'\n", p_str); rc = libusb20_dev_get_port_path(pdev_curr, (uint8_t*)&usb_ports, UINT8_MAX); printf("get_port_path: %d\n", rc); printf("\n"); libusb20_dev_close(pdev_curr); pdev_last = pdev_curr; } while (pdev_curr != NULL); libusb20_be_free(pbe); printf("END\n"); return 0; } // // EOF // /Uffe