libftdi-git Archives

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

From: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
To: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 22 Feb 2017 10:02:03 +0100 (CET)
The branch, master has been updated
       via  c9eeb2f12fe5632bab5b35766c1b6261e591872a (commit)
      from  9f2b912eceaab315474c9987ae77b2aa3bea13a5 (commit)


- Log -----------------------------------------------------------------
commit c9eeb2f12fe5632bab5b35766c1b6261e591872a
Author: Adam Malinowski <amalinowski75@xxxxxxxxx>
Date:   Thu Feb 16 15:17:14 2017 +0100

    Add new function ftdi_eeprom_get_strings()
    
    This function adds possibility of reading EEPROM strings:
    manufacturer, product and serial number.

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

Summary of changes:
 src/ftdi.c |   41 +++++++++++++++++++++++++++++++++++++++++
 src/ftdi.h |    5 +++++
 2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/src/ftdi.c b/src/ftdi.c
index b87aa1c..777733a 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -2596,6 +2596,47 @@ int ftdi_eeprom_set_strings(struct ftdi_context *ftdi, 
char * manufacturer,
     return 0;
 }
 
+int ftdi_eeprom_get_strings(struct ftdi_context *ftdi,
+                            char *manufacturer, int mnf_len,
+                            char *product, int prod_len,
+                            char *serial, int serial_len)
+{
+    struct ftdi_eeprom *eeprom;
+
+    if (ftdi == NULL)
+        ftdi_error_return(-1, "No struct ftdi_context");
+
+    if (ftdi->eeprom == NULL)
+        ftdi_error_return(-2,"No struct ftdi_eeprom");
+
+    eeprom = ftdi->eeprom;
+
+    if (ftdi->usb_dev == NULL)
+        ftdi_error_return(-3, "No connected device or device not yet opened");
+
+    if (manufacturer)
+    {
+        strncpy(manufacturer, eeprom->manufacturer, mnf_len);
+        if (mnf_len > 0)
+            manufacturer[mnf_len - 1] = '\0';
+    }
+
+    if (product)
+    {
+        strncpy(product, eeprom->product, prod_len);
+        if (prod_len > 0)
+            product[prod_len - 1] = '\0';
+    }
+
+    if (serial)
+    {
+        strncpy(serial, eeprom->serial, serial_len);
+        if (serial_len > 0)
+            serial[serial_len - 1] = '\0';
+    }
+
+    return 0;
+}
 
 /*FTD2XX doesn't check for values not fitting in the ACBUS Signal options*/
 void set_ft232h_cbus(struct ftdi_eeprom *eeprom, unsigned char * output)
diff --git a/src/ftdi.h b/src/ftdi.h
index bb66c53..e307824 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -489,6 +489,11 @@ extern "C"
                               char *manufacturer, int mnf_len,
                               char *description, int desc_len,
                               char *serial, int serial_len);
+
+    int ftdi_eeprom_get_strings(struct ftdi_context *ftdi,
+                                char *manufacturer, int mnf_len,
+                                char *product, int prod_len,
+                                char *serial, int serial_len);
     int ftdi_eeprom_set_strings(struct ftdi_context *ftdi, char * manufacturer,
                                 char * product, char * serial);
 


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-13-gc9eeb2f, libftdi-git <=