Date: Tue, 20 Jan 2015 12:06:20 +0100 From: Uffe Jakobsen <uffe@uffe.org> To: Hans Petter Selasky <hps@selasky.org>, freebsd-usb@freebsd.org Subject: Re: Problem with libusb20_dev_get_port_path() Message-ID: <54BE36AC.9050904@uffe.org> In-Reply-To: <54BDDB11.3070800@selasky.org> References: <54BD9460.90607@uffe.org> <54BDDB11.3070800@selasky.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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: <UHCI root HUB Intel> at usbus0' get_port_path: 0 device descriptor: 'ugen2.1: <UHCI root HUB Intel> at usbus2' get_port_path: 0 device descriptor: 'ugen1.1: <UHCI root HUB Intel> at usbus1' get_port_path: 0 device descriptor: 'ugen4.1: <EHCI root HUB Intel> at usbus4' get_port_path: 0 device descriptor: 'ugen3.1: <UHCI root HUB Intel> at usbus3' get_port_path: 0 device descriptor: 'ugen3.2: <USB CAT5 vendor 0x0d3d> at usbus3' get_port_path: 0 END // // Compile: cc tst.c -lusb // #include <unistd.h> #include <stdint.h> #include <stdlib.h> #include <limits.h> #include <stdio.h> #include <libusb20.h> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?54BE36AC.9050904>