Fixed. Combined with the previous minor
comment change. I changed the name of the function name from
ftdi_open_bus_port to ftdi_open_bus_addr.
--- 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 1/2] 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
From 2ab0e69d2e8bbc36207d3bf7c6fabba2ab95abfd Mon Sep 17 00:00:00
2001
From: Maxwell Dreytser
<admin@xxxxxxxxx>
Date: Thu, 11 May 2017 01:14:39 -0400
Subject: [PATCH 2/2] Change ftdi_open_bus_port to
ftdi_open_bus_addr, since
libusb_get_port_number is not always unique.
---
src/ftdi.c | 8 ++++----
src/ftdi.h | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/ftdi.c b/src/ftdi.c
index ac8f18a..175befc 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -825,11 +825,11 @@ int ftdi_usb_open_desc_index(struct
ftdi_context *ftdi, int vendor, int product,
}
/**
- Opens the device at a given USB bus and port.
+ Opens the device at a given USB bus and device address.
\param ftdi pointer to ftdi_context
\param bus Bus number
- \param port Port number
+ \param addr Device address
\retval 0: all fine
\retval -1: usb_find_busses() failed
@@ -845,7 +845,7 @@ int ftdi_usb_open_desc_index(struct
ftdi_context *ftdi, int vendor, int product,
\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)
+int ftdi_usb_open_bus_addr(struct ftdi_context *ftdi, uint8_t
bus, uint8_t addr)
{
libusb_device *dev;
libusb_device **devs;
@@ -859,7 +859,7 @@ int ftdi_usb_open_bus_port(struct ftdi_context
*ftdi, uint8_t bus, uint8_t port)
while ((dev = devs[i++]) != NULL)
{
- if (libusb_get_bus_number(dev) == bus &&
libusb_get_port_number(dev) == port)
+ if (libusb_get_bus_number(dev) == bus &&
libusb_get_device_address(dev) == addr)
{
int res;
res = ftdi_usb_open_dev(ftdi, dev);
diff --git a/src/ftdi.h b/src/ftdi.h
index 5927c48..de02adf 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -502,7 +502,7 @@ extern "C"
const char* description, const char*
serial);
int ftdi_usb_open_desc_index(struct ftdi_context *ftdi, int
vendor, int product,
const char* description, const
char* serial, unsigned int index);
- int ftdi_usb_open_bus_port(struct ftdi_context *ftdi, uint8_t
bus, uint8_t port);
+ int ftdi_usb_open_bus_addr(struct ftdi_context *ftdi, uint8_t
bus, uint8_t addr);
int ftdi_usb_open_dev(struct ftdi_context *ftdi, struct
libusb_device *dev);
int ftdi_usb_open_string(struct ftdi_context *ftdi, const
char* description);
--
2.9.3
--- End PATCH ---
On 05/11/2017 12:38 AM, Maxwell Dreytser wrote: