Hi,
Attached is a patch to libsigrok to FreeBSD specific problems in
function usb_get_port_path() (file src/usb.c)
Affected devices that currently does not work on FreeBSD:
fx2lafw, saleae-logic16, zeroplus-logic-cube, hantek-dso, testo and
victor-dmm (and maybe more)
[PATCH] Fix FreeBSD issue with libusb_get_port_numbers()
Currently (as of date 20150122) an ioctl problem within the
FreeBSD kernel is preventing libusb_get_port_numbers() from working.
Hence calls to libusb_get_port_numbers() will always return 0.
This makes it impossible to establish a physical path the the usb device.
This problem has existed "forever" -
meaning that libusb_get_port_numbers() have never worked.
A fix is committed to FreeBSD "current" head -
and will later be merged (MFC'ed) to maintenance branches.
See: https://svnweb.freebsd.org/base?view=revision&revision=277417
Additionally FreeBSD requires that devices prior to calling
libusb_get_port_numbers() have been opened with libusb_open().
The patch is "forwards-compatible".
Currently it acts specificly to libusb_get_port_numbers()
currently returning 0 on FreeBSD.
In these situations it constructs an artificial path to the device.
When FreeBSD kernels appears with proper working ioctl
supporting libusb_get_port_numbers() the code will construct
proper physical paths for newer kernels - while still generating
articicial physical paths for older defective kernels.
/Uffe
>From 3d1aed4af172bdc79c02e23c5b9c490e5de2f0e1 Mon Sep 17 00:00:00 2001
From: Uffe Jakobsen <[email protected]>
Date: Thu, 22 Jan 2015 01:11:22 +0100
Subject: [PATCH] Fix FreeBSD issue with libusb_get_port_numbers()
Currently (as of date 20150122) an ioctl problem within the
FreeBSD kernel is preventing libusb_get_port_numbers() from working.
Hence calls to libusb_get_port_numbers() will always return 0.
This makes it impossible to establish a physical path the the usb device.
This problem has existed "forever" -
meaning that libusb_get_port_numbers() have never worked.
A fix is committed to FreeBSD "current" head -
and will later be merged (MFC'ed) to maintenance branches.
See: https://svnweb.freebsd.org/base?view=revision&revision=277417
Additionally FreeBSD requires that devices prior to calling
libusb_get_port_numbers() have been opened with libusb_open().
The patch is "forwards-compatible".
Currently it acts specificly to libusb_get_port_numbers()
currently returning 0 on FreeBSD.
In these situations it constructs an artificial path to the device.
When FreeBSD kernels appears with proper working ioctl
supporting libusb_get_port_numbers() the code will construct
proper physical paths for newer kernels - while still generating
articicial physical paths for older defective kernels.
---
src/usb.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/usb.c b/src/usb.c
index 8bdb8d6..bc28c5c 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -276,10 +276,30 @@ SR_PRIV int usb_get_port_path(libusb_device *dev, char *path, int path_len)
uint8_t port_numbers[8];
int i, n, len;
+// FreeBSD requires that devices prior to calling libusb_get_port_numbers()
+// have been opened with libusb_open().
+#ifdef __FreeBSD__
+ struct libusb_device_handle* devh;
+ libusb_open(dev, &devh);
+#endif
n = libusb_get_port_numbers(dev, port_numbers, sizeof(port_numbers));
+#ifdef __FreeBSD__
+ libusb_close(devh);
+#endif
+// Workaround FreeBSD libusb_get_port_numbers() returning 0
if (n < 1)
+#ifdef __FreeBSD__
+ {
+ if (n == 0) {
+ port_numbers[0] = libusb_get_device_address(dev);
+ } else {
+#endif
return SR_ERR;
+#ifdef __FreeBSD__
+ }
+ }
+#endif
len = snprintf(path, path_len, "usb/%d-%d",
libusb_get_bus_number(dev), port_numbers[0]);
--
2.2.2
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel