[PATCH] Enable searching for FTDI devices with either a VID or PID of zero

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[PATCH] Enable searching for FTDI devices with either a VID or PID of zero

Forest Crossman
This change makes it possible to detect FTDI clone chips that have been
"bricked" by the FTDI Windows driver (PID set to zero)

Signed-off-by: Forest Crossman <[hidden email]>
---
 src/ftdi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index bad338d..32b3817 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -328,9 +328,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 (((vendor != 0 && product != 0) &&
+        if (((vendor || product) &&
                 desc.idVendor == vendor && desc.idProduct == product) ||
-                ((vendor == 0 && product == 0) &&
+                (!(vendor || product) &&
                  (desc.idVendor == 0x403) && (desc.idProduct == 0x6001 || desc.idProduct == 0x6010
                                               || desc.idProduct == 0x6011 || desc.idProduct == 0x6014)))
         {
--
2.1.2


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Enable searching for FTDI devices with either a VID or PID of zero

Thomas Jarosch
Hi Forest,

thanks for the patch. Comments below:

On Friday, 31. October 2014 13:17:16 Forest Crossman wrote:
> @@ -328,9 +328,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 (((vendor != 0 && product != 0) &&
> +        if (((vendor || product) &&
>                  desc.idVendor == vendor && desc.idProduct == product) ||

that part is fine by me. That should allow us
to find devices with the famous zero PID.

> -                ((vendor == 0 && product == 0) &&
> +                (!(vendor || product) &&
>                   (desc.idVendor == 0x403) && (desc.idProduct == 0x6001 ||

I currently don't see the reason why this part of the code was changed?
Can't we keep the current logic (which is easier to read)? Am I missing something?

Cheers,
Thomas


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Enable searching for FTDI devices with either a VID or PID of zero

Forest Crossman

>> -                ((vendor == 0 && product == 0) &&
>> +                (!(vendor || product) &&
>>                   (desc.idVendor == 0x403) && (desc.idProduct == 0x6001 ||

> I currently don't see the reason why this part of the code was changed?

Oh, I really only changed that to stay consistent with the other change--it's functionally equivalent.

--
Forest Crossman

On Wed, Nov 5, 2014 at 9:38 AM, Thomas Jarosch <[hidden email]> wrote:
Hi Forest,

thanks for the patch. Comments below:

On Friday, 31. October 2014 13:17:16 Forest Crossman wrote:
> @@ -328,9 +328,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 (((vendor != 0 && product != 0) &&
> +        if (((vendor || product) &&
>                  desc.idVendor == vendor && desc.idProduct == product) ||

that part is fine by me. That should allow us
to find devices with the famous zero PID.
Can't we keep the current logic (which is easier to read)? Am I missing something?

Cheers,
Thomas




libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [PATCH] Enable searching for FTDI devices with either a VID or PID of zero

Thomas Jarosch
On 11/05/2014 10:28 PM, Forest Crossman wrote:
>
>>> -                ((vendor == 0 && product == 0) &&
>>> +                (!(vendor || product) &&
>>>                   (desc.idVendor == 0x403) && (desc.idProduct == 0x6001 ||
>
>> I currently don't see the reason why this part of the code was changed?
>
> Oh, I really only changed that to stay consistent with the other change--it's functionally equivalent.

alright, I've applied the patch as is. Thanks!

Cheers,
Thomas


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to [hidden email]  

Loading...