Re: Feedback for portable libusb code

2018-02-11 Thread Romain Tartière
On Sun, Feb 11, 2018 at 09:02:36PM +0100, Hans Petter Selasky wrote:
> Can you run "ldd" on your binaries to see they really are using the 
> libusb you installed?

Sure:

λ ldd /usr/local/bin/pulseview| grep usb
libusb.so.3 => /usr/lib/libusb.so.3 (0x80581a000)
λ ll -rt /usr/lib | tail
-r--r--r--  1 root  wheel 98360 Dec  9 13:12 snmp_pf.so.6
lrwxr-xr-x  1 root  wheel12 Dec  9 13:12 snmp_pf.so@ -> snmp_pf.so.6
-r--r--r--  1 root  wheel 42288 Dec  9 13:12 snmp_netgraph.so.6
lrwxr-xr-x  1 root  wheel18 Dec  9 13:12 snmp_netgraph.so@ -> 
snmp_netgraph.so.6
-r--r--r--  1 root  wheel280512 Dec  9 13:12 snmp_wlan.so.6
lrwxr-xr-x  1 root  wheel14 Dec  9 13:12 snmp_wlan.so@ -> snmp_wlan.so.6
-r--r--r--  1 root  wheel138210 Feb  5 15:52 libusb.a
-r--r--r--  1 root  wheel149832 Feb  5 15:52 libusb_p.a
-r--r--r--  1 root  wheel 88144 Feb  5 15:52 libusb.so.3
lrwxr-xr-x  1 root  wheel11 Feb  5 15:52 libusb.so@ -> libusb.so.3


-- 
Romain Tartière http://romain.blogreen.org/
pgp: 8234 9A78 E7C0 B807 0B59  80FF BA4D 1D95 5112 336F (ID: 0x5112336F)
(plain text =non-HTML= PGP/GPG encrypted/signed e-mail much appreciated)


signature.asc
Description: PGP signature


Re: Feedback for portable libusb code

2018-02-11 Thread Hans Petter Selasky

On 02/05/18 16:35, Romain Tartière wrote:

Hi!

On Mon, Jan 29, 2018 at 08:10:06PM +0100, Hans Petter Selasky wrote:

Does the attached patch for FreeBSD's libusb solve your issue?


I have just patched, build and installed libusb.  I removed the
libusb_open() / libusb_close() calls from usb_get_port_path() in
libsigrok and tested.
https://github.com/sigrokproject/libsigrok/blob/a9010323ddf4e479663e871386c05db05ea3522e/src/usb.c#L473-L491


Unfortunately, the problem is still present.  On the first enumeration,
libusb_get_port_numbers() returns 3 and the firmware is send to the
device successfully.  Then, when lbsigrok attempt to re-enumerate
devices, libusb_get_port_numbers() returns -12
(LIBUSB_ERROR_NOT_SUPPORTED).



I am sure that the firmware is sent successfully because usbconfig(8)
shows the following when I plug the device:
| ugen0.10:  at usbus0, cfg=0 md=HOST spd=HIGH 
(480Mbps) pwr=ON (100mA)
and after the enumeration failure, I can see this instead:
| ugen0.10:  at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON 
(100mA)



Can you run "ldd" on your binaries to see they really are using the 
libusb you installed?


--HPS
___
freebsd-usb@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"


Re: Feedback for portable libusb code

2018-02-05 Thread Romain Tartière
Hi!

On Mon, Jan 29, 2018 at 08:10:06PM +0100, Hans Petter Selasky wrote:
> Does the attached patch for FreeBSD's libusb solve your issue?

I have just patched, build and installed libusb.  I removed the
libusb_open() / libusb_close() calls from usb_get_port_path() in
libsigrok and tested.
https://github.com/sigrokproject/libsigrok/blob/a9010323ddf4e479663e871386c05db05ea3522e/src/usb.c#L473-L491


Unfortunately, the problem is still present.  On the first enumeration,
libusb_get_port_numbers() returns 3 and the firmware is send to the
device successfully.  Then, when lbsigrok attempt to re-enumerate
devices, libusb_get_port_numbers() returns -12
(LIBUSB_ERROR_NOT_SUPPORTED).



I am sure that the firmware is sent successfully because usbconfig(8)
shows the following when I plug the device:
| ugen0.10:  at usbus0, cfg=0 md=HOST spd=HIGH 
(480Mbps) pwr=ON (100mA)
and after the enumeration failure, I can see this instead:
| ugen0.10:  at usbus0, cfg=0 md=HOST spd=HIGH (480Mbps) pwr=ON 
(100mA)


Regards,
Romain

-- 
Romain Tartière http://romain.blogreen.org/
pgp: 8234 9A78 E7C0 B807 0B59  80FF BA4D 1D95 5112 336F (ID: 0x5112336F)
(plain text =non-HTML= PGP/GPG encrypted/signed e-mail much appreciated)


signature.asc
Description: PGP signature


Re: Feedback for portable libusb code

2018-02-01 Thread Romain Tartière
Hi

On Mon, Jan 29, 2018 at 08:10:06PM +0100, Hans Petter Selasky wrote:
> Does the attached patch for FreeBSD's libusb solve your issue?

Unfortunately, I could not test this before leaving home.  I will be
back in a few days, feel free to come back to me if you have no news
from me in one week.

Regards,
Romain
-- 
Romain Tartière   http://people.FreeBSD.org/~romain/
pgp: 8234 9A78 E7C0 B807 0B59  80FF BA4D 1D95 5112 336F (ID: 0x5112336F)
(plain text =non-HTML= PGP/GPG encrypted/signed e-mail much appreciated)


signature.asc
Description: PGP signature


Re: Feedback for portable libusb code

2018-01-29 Thread Hans Petter Selasky

On 01/29/18 19:44, Romain Tartière wrote:

Hello!

FreeBSD's libusb allows userland programs to access USB devices in a way
similar to GNU/Linux with it's libusb.

However, there are some differences between these implementations.  I
recently diagnosed an issue in sigrok, provided a patch, but the
maintainer is having some questions and I am not sure about the best way
to address them.

If someone with more USB insight could give a look to this GitHub issue,
that would be awesome !

Basically, the usb_get_port_path() calls libusb_open() before (and
libusb_close() after) libusb_get_port_numbers() because this is required
on FreeBSD:
https://github.com/sigrokproject/libsigrok/blob/a9010323ddf4e479663e871386c05db05ea3522e/src/usb.c#L478-L491

However, calling libusb_open() twice fails…

The issue is here:
https://github.com/sigrokproject/libsigrok/pull/6


Hi,

Does the attached patch for FreeBSD's libusb solve your issue?

--HPS
Index: libusb20_int.h
===
--- libusb20_int.h	(revision 328435)
+++ libusb20_int.h	(working copy)
@@ -237,8 +237,12 @@
 	uint8_t	is_opened;
 	uint8_t parent_address;
 	uint8_t parent_port;
+	uint8_t port_level;
 
 	char	usb_desc[96];
+
+#define	LIBUSB20_DEVICE_PORT_PATH_MAX	32
+	uint8_t port_path[LIBUSB20_DEVICE_PORT_PATH_MAX];
 };
 
 extern const struct libusb20_backend_methods libusb20_ugen20_backend;
Index: libusb20_ugen20.c
===
--- libusb20_ugen20.c	(revision 328435)
+++ libusb20_ugen20.c	(working copy)
@@ -136,6 +136,7 @@
 	const char *tmp = id;
 	struct usb_device_descriptor ddesc;
 	struct usb_device_info devinfo;
+	struct usb_device_port_path udpp;
 	uint32_t plugtime;
 	char buf[64];
 	int f;
@@ -219,6 +220,21 @@
 	pdev->device_address, devinfo.udi_vendor,
 	devinfo.udi_product, pdev->bus_number);
 
+	/* get parent port path */
+
+	if (ioctl(f, IOUSB(USB_GET_DEV_PORT_PATH), )) {
+		error = LIBUSB20_ERROR_OTHER;
+		goto done;
+	}
+
+	if (udpp.udp_port_level > LIBUSB20_DEVICE_PORT_PATH_MAX) {
+		error = LIBUSB20_ERROR_OVERFLOW;
+		goto done;
+	}
+
+	memcpy(pdev->port_path, udpp.udp_port_no, udpp.udp_port_level);
+	pdev->port_level = udpp.udp_port_level;
+
 	error = 0;
 done:
 	close(f);
@@ -653,17 +669,13 @@
 static int
 ugen20_get_port_path(struct libusb20_device *pdev, uint8_t *buf, uint8_t bufsize)
 {
-	struct usb_device_port_path udpp;
 
-	if (ioctl(pdev->file_ctrl, IOUSB(USB_GET_DEV_PORT_PATH), ))
-		return (LIBUSB20_ERROR_OTHER);
-
-	if (udpp.udp_port_level > bufsize)
+	if (pdev->port_level > bufsize)
 		return (LIBUSB20_ERROR_OVERFLOW);
 
-	memcpy(buf, udpp.udp_port_no, udpp.udp_port_level);
+	memcpy(buf, pdev->port_path, pdev->port_level);
 
-	return (udpp.udp_port_level);	/* success */
+	return (pdev->port_level);	/* success */
 }
 
 static int
___
freebsd-usb@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-usb
To unsubscribe, send any mail to "freebsd-usb-unsubscr...@freebsd.org"