libftdi-git Archives

Subject: A library to talk to FTDI chips branch, master, updated. v1.3-2-g1a3cb7f

From: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
To: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 15 Jun 2016 16:59:17 +0200 (CEST)
The branch, master has been updated
       via  1a3cb7f83149a08e3d463d7d24d50499b035a149 (commit)
      from  6f9f969dc7e359296e562ee9731081cefaf06b20 (commit)


- Log -----------------------------------------------------------------
commit 1a3cb7f83149a08e3d463d7d24d50499b035a149
Author: Yegor Yefremov <yegorslists@xxxxxxxxxxxxxx>
Date:   Fri Jun 10 13:58:32 2016 +0200

    Make ftdi_read_eeprom_location() endianess independent
    
    Read 16-bit integer as two byte array and combine these two bytes
    to unsigned short.

-----------------------------------------------------------------------

Summary of changes:
 src/ftdi.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index f5d263c..fdf93fe 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -4195,12 +4195,16 @@ int ftdi_set_eeprom_user_data(struct ftdi_context 
*ftdi, const char * buf, int s
 */
 int ftdi_read_eeprom_location (struct ftdi_context *ftdi, int eeprom_addr, 
unsigned short *eeprom_val)
 {
+    unsigned char buf[2];
+
     if (ftdi == NULL || ftdi->usb_dev == NULL)
         ftdi_error_return(-2, "USB device unavailable");
 
-    if (libusb_control_transfer(ftdi->usb_dev, FTDI_DEVICE_IN_REQTYPE, 
SIO_READ_EEPROM_REQUEST, 0, eeprom_addr, (unsigned char *)eeprom_val, 2, 
ftdi->usb_read_timeout) != 2)
+    if (libusb_control_transfer(ftdi->usb_dev, FTDI_DEVICE_IN_REQTYPE, 
SIO_READ_EEPROM_REQUEST, 0, eeprom_addr, buf, 2, ftdi->usb_read_timeout) != 2)
         ftdi_error_return(-1, "reading eeprom failed");
 
+    *eeprom_val = (0xff & buf[0]) | (buf[1] << 8);
+
     return 0;
 }
 


hooks/post-receive
-- 
A library to talk to FTDI chips

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

Current Thread
  • A library to talk to FTDI chips branch, master, updated. v1.3-2-g1a3cb7f, libftdi-git <=