libftdi Archives

Subject: Re: PATCH: Add a ftdi_usb_open_bus_port function.

From: Maxwell Dreytser <admin@xxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Date: Thu, 11 May 2017 00:38:10 -0400

Gotcha. I didn't read the libusb docs before answering. I'll submit a patch in a sec.

Maxwell.


On 05/11/2017 12:33 AM, Fahrzin Hemmati wrote:
No, the bus number and device number (device_address) match the currently-connected device uniquely, and the bus number + port_numbers match the port on which the device is connected (stable across reconnects). The bus number and port_number is unique only if you don't use any USB hubs (and there are none internal to your system). If there are hubs, then you need port_numbers


Farz Hemmati |  Self-Driving Systems Testing and Tools Lead |  fahhem@xxxxxxxxxx |  650-253-8944


On Wed, May 10, 2017 at 9:25 PM, Maxwell Dreytser <admin@xxxxxxxxx> wrote:

Oh, so the bus number and port number are not enough to uniquely identify a device?

Maxwell.


On 05/04/2017 05:57 AM, Fahrzin Hemmati wrote:
Maxwell,

I think I found a discrepancy between our implementations that is going to be problematic. In yours, you use libusb_get_port_number, but I use libusb_get_device_address.

It looks like libusb_get_port_number returns the last digit of libusb_get_port_numbers, which is something like 1,3,1,1 so port_number is just 1. This allows conflicts since port_number isn't unique, despite what the documentation implies. The bus_number + device_address is the unique combination required.

On my Linux machines, device_address matches the sysfs node devnum (and bus_number is busnum), while port_number matches the path: /sys/bus/usb/devices/<bus_number>-<port_numbers>/{busnum,devnum}
I don't know how much this changes between systems, though, so I can't speak to whether this will be the case with your machines.

What do you think?


Farz Hemmati |  Self-Driving Systems Testing and Tools Lead |  fahhem@xxxxxxxxxx |  650-253-8944


On Fri, Apr 21, 2017 at 9:56 AM, Maxwell Dreytser <admin@xxxxxxxxx> wrote:
Hi Thomas,

All is fine. Just noticed a minor problem in the comments. Return code -12 was not mentioned in "ftdi_usb_open_desc_index" as well as the new "ftdi_usb_open_bus_port".

Maxwell.

--- Begin PATCH ---

From 66ae37ad943976401a54d3ff409634d332206d67 Mon Sep 17 00:00:00 2001
From: Maxwell Dreytser <admin@xxxxxxxxx>
Date: Fri, 21 Apr 2017 12:48:42 -0400
Subject: [PATCH] Minor comment fix.

---
 src/ftdi.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/ftdi.c b/src/ftdi.c
index c26ab72..ac8f18a 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -750,6 +750,7 @@ int ftdi_usb_open_desc(struct ftdi_context *ftdi, int vendor, int product,
     \retval -9: get serial number failed
     \retval -10: unable to close device
     \retval -11: ftdi context invalid
+    \retval -12: libusb_get_device_list() failed
 */
 int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int vendor, int product,
                              const char* description, const char* serial, unsigned int index)
@@ -842,6 +843,7 @@ int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int vendor, int product,
     \retval -9: get serial number failed
     \retval -10: unable to close device
     \retval -11: ftdi context invalid
+    \retval -12: libusb_get_device_list() failed
 */
 int ftdi_usb_open_bus_port(struct ftdi_context *ftdi, uint8_t bus, uint8_t port)
 {
--
2.9.3

--- End Patch ---



On 04/21/2017 12:04 PM, Thomas Jarosch wrote:
Hi Maxwell,

On Monday, 10 April 2017 04:43:24 CEST Maxwell Dreytser wrote:
Nice to know that this is actually useful! I had a similar situation in
my work.
patch has been applied, thanks!

The long code lines were mangled by our mail client,
I had to apply the patch manually.

Please double check everything is still correct in git.

Cheers,
Thomas



--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@developer.intra2net.com   



libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@developer.intra2net.com





libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@developer.intra2net.com





libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx





libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx


Current Thread