libftdi-git Archives

Subject: A library to talk to FTDI chips branch, master, updated. v1.0-14-g878f0c6

From: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
To: libftdi-git@xxxxxxxxxxxxxxxxxxxxxxx
Date: Wed, 10 Apr 2013 10:19:23 +0200 (CEST)
The branch, master has been updated
       via  878f0c6a695a969f4f5ada3276e4479feda1d87d (commit)
      from  9e44fc94ea5ffe94cc4eaf8d58f55af41f3cef97 (commit)


- Log -----------------------------------------------------------------
commit 878f0c6a695a969f4f5ada3276e4479feda1d87d
Author: Nathael Pajani <nathael.pajani@xxxxxxx>
Date:   Wed Apr 10 10:19:17 2013 +0200

    Added ftdi_eeprom_set_strings()

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

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

diff --git a/src/ftdi.c b/src/ftdi.c
index 9cf86ea..0a2e0fa 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -2420,6 +2420,52 @@ int ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, 
char * manufacturer,
     }
     return 0;
 }
+
+int ftdi_eeprom_set_strings(struct ftdi_context *ftdi, char * manufacturer,
+                             char * product, char * serial)
+{
+    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) {
+        if (eeprom->manufacturer)
+            free (eeprom->manufacturer);
+        eeprom->manufacturer = malloc(strlen(manufacturer)+1);
+        if (eeprom->manufacturer)
+            strcpy(eeprom->manufacturer, manufacturer);
+    }
+
+    if(product) {
+        if (eeprom->product)
+            free (eeprom->product);
+        eeprom->product = malloc(strlen(product)+1);
+        if (eeprom->product)
+            strcpy(eeprom->product, product);
+    }
+
+    if (serial) {
+        if (eeprom->serial)
+            free (eeprom->serial);
+        eeprom->serial = malloc(strlen(serial)+1);
+        if (eeprom->serial) {
+            strcpy(eeprom->serial, serial);
+            eeprom->use_serial = 1;
+        }
+    }
+    return 0;
+}
+
+
 /*FTD2XX doesn't check for values not fitting in the ACBUS Signal oprtions*/
 void set_ft232h_cbus(struct ftdi_eeprom *eeprom, unsigned char * output)
 {
diff --git a/src/ftdi.h b/src/ftdi.h
index c1d74f1..93f2479 100644
--- a/src/ftdi.h
+++ b/src/ftdi.h
@@ -446,6 +446,8 @@ extern "C"
                              char * manufacturer, int mnf_len,
                              char * description, int desc_len,
                              char * serial, int serial_len);
+    int ftdi_eeprom_set_strings(struct ftdi_context *ftdi, char * manufacturer,
+                             char * product, char * serial);
 
     int ftdi_usb_open(struct ftdi_context *ftdi, int vendor, int product);
     int ftdi_usb_open_desc(struct ftdi_context *ftdi, int vendor, int product,


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.0-14-g878f0c6, libftdi-git <=