Allow to search for all FTDI standard VID/PID by passing VID:PID 0:0
to ftdi_usb_find_all
--
Uwe Bonnes bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Institut fuer Kernphysik Schlossgartenstrasse 9 64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
>From 8a66bb5818162f8d1f528ac2cd56818f70df3f52 Mon Sep 17 00:00:00 2001
From: Uwe Bonnes <bon@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 Jun 2011 17:00:48 +0200
Subject: Allow to search for all FTDI standard VID/PID
---
examples/find_all.c | 2 +-
src/ftdi.c | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/examples/find_all.c b/examples/find_all.c
index 2f3b4e2..5ad40be 100644
--- a/examples/find_all.c
+++ b/examples/find_all.c
@@ -23,7 +23,7 @@ int main(void)
return EXIT_FAILURE;
}
- if ((ret = ftdi_usb_find_all(&ftdic, &devlist, 0x0403, 0x6010)) < 0)
+ if ((ret = ftdi_usb_find_all(&ftdic, &devlist, NULL, NULL)) < 0)
{
fprintf(stderr, "ftdi_usb_find_all failed: %d (%s)\n", ret,
ftdi_get_error_string(&ftdic));
retval = EXIT_FAILURE;
diff --git a/src/ftdi.c b/src/ftdi.c
index 57730d9..4dc47bd 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -257,8 +257,10 @@ void ftdi_set_usbdev (struct ftdi_context *ftdi,
libusb_device_handle *usb)
/**
- Finds all ftdi devices on the usb bus. Creates a new ftdi_device_list which
- needs to be deallocated by ftdi_list_free() after use.
+ Finds all ftdi devices with given VID:PID on the usb bus. Creates a new
+ ftdi_device_list which needs to be deallocated by ftdi_list_free() after
+ use. With VID:PID 0:0, search for the default devices
+ (0x403:0x6001, 0x403:0x6010, 0x403:0x6011, 0x403:0x6014)
\param ftdi pointer to ftdi_context
\param devlist Pointer where to store list of found devices
@@ -291,7 +293,9 @@ int ftdi_usb_find_all(struct ftdi_context *ftdi, struct
ftdi_device_list **devli
if (libusb_get_device_descriptor(dev, &desc) < 0)
ftdi_error_return_free_device_list(-6,
"libusb_get_device_descriptor() failed", devs);
- if (desc.idVendor == vendor && desc.idProduct == product)
+ if ((vendor != 0 && product != 0 && desc.idVendor == vendor &&
desc.idProduct == product) ||
+ ((desc.idVendor == 0x403) && (desc.idProduct == 0x6001 ||
desc.idProduct == 0x6010
+ || desc.idProduct == 0x6011 ||
desc.idProduct == 0x6014)))
{
*curdev = (struct ftdi_device_list*)malloc(sizeof(struct
ftdi_device_list));
if (!*curdev)
--
1.7.3.4
--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx
|