libftdi Archives

Subject: Re: Reading Chip ID

From: Thomas Jarosch <thomas.jarosch@xxxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: Peter Holik <peter@xxxxxxxx>
Date: Sat, 14 Mar 2009 23:20:50 +0100
Hello Matthias,

Matthias Richter wrote:
The ftdi_read_chipid() function results sometimes in a different value compared to the FTID_GetDeviceChipID() from the FTDI drivers (Linux or Windows). The problem is in the two lines

           b = b << 8 | b >> 8;
           a = (a << 16) | b;

because the first line not only swap low and high byte of b, but also shifts bit 8-15 of b to bit 16-23, and this may destroy the value of (a << 16) in the next line. Masking b like a = (a << 16) | (b & 0xffff) fix this, but should this really fixed, because of making ftdi_read_chipid() incompatible to older versions of libftdi?

Thanks for pointing that out. If the two functions now output the
same value for both libraries, then it should be fixed in libftdi.

I'll also ask Peter Holik about it as he contributed
the ftdi_read_chipid() code.

Care to send a patch, preferably in "git format-patch" style?

Cheers,
Thomas

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