X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=src%2Fftdi.c;h=6d0163f20968c7ffa4f1091454ebb56f266b018f;hp=b26b6555e9732783593dd7c4c9844e1b3915181c;hb=efc843050e8d0eaef34cef36db7c4acfec7830ff;hpb=8080d2ceab3809d25d5bc6799dce499e068308d8 diff --git a/src/ftdi.c b/src/ftdi.c index b26b655..6d0163f 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -2506,9 +2506,6 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, unsigned char *buf, int size) eeprom_size = 0x80; eeprom = ftdi->eeprom; - // Addr 00: High current IO - eeprom->high_current = (buf[0x02] & HIGH_CURRENT_DRIVE); - // Addr 02: Vendor ID eeprom->vendor_id = buf[0x02] + (buf[0x03] << 8); @@ -2574,19 +2571,58 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, unsigned char *buf, int size) // Addr 0E: Offset of the manufacturer string + 0x80, calculated later // Addr 0F: Length of manufacturer string manufacturer_size = buf[0x0F]/2; - if (manufacturer_size > 0) eeprom->manufacturer = malloc(manufacturer_size); + if (manufacturer_size > 0) + { + eeprom->manufacturer = malloc(manufacturer_size); + if (eeprom->manufacturer) + { + // Decode manufacturer + i = buf[0x0E]; // offset + for (j=0;jmanufacturer[j] = buf[2*j+i+2]; + } + eeprom->manufacturer[j] = '\0'; + } + } else eeprom->manufacturer = NULL; // Addr 10: Offset of the product string + 0x80, calculated later // Addr 11: Length of product string product_size = buf[0x11]/2; - if (product_size > 0) eeprom->product = malloc(product_size); + if (product_size > 0) + { + eeprom->product = malloc(product_size); + if(eeprom->product) + { + // Decode product name + i = buf[0x10]; // offset + for (j=0;jproduct[j] = buf[2*j+i+2]; + } + eeprom->product[j] = '\0'; + } + } else eeprom->product = NULL; // Addr 12: Offset of the serial string + 0x80, calculated later // Addr 13: Length of serial string serial_size = buf[0x13]/2; - if (serial_size > 0) eeprom->serial = malloc(serial_size); + if (serial_size > 0) + { + eeprom->serial = malloc(serial_size); + if(eeprom->serial) + { + // Decode serial + i = buf[0x12]; // offset + for (j=0;jserial[j] = buf[2*j+i+2]; + } + eeprom->serial[j] = '\0'; + } + } else eeprom->serial = NULL; // Addr 14: CBUS function: CBUS0, CBUS1 @@ -2602,30 +2638,6 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, unsigned char *buf, int size) for (j=0; j<5; j++) eeprom->cbus_function[j] = 0; } - // Decode manufacturer - i = buf[0x0E] & 0x7f; // offset - for (j=0;jmanufacturer[j] = buf[2*j+i+2]; - } - eeprom->manufacturer[j] = '\0'; - - // Decode product name - i = buf[0x10] & 0x7f; // offset - for (j=0;jproduct[j] = buf[2*j+i+2]; - } - eeprom->product[j] = '\0'; - - // Decode serial - i = buf[0x12] & 0x7f; // offset - for (j=0;jserial[j] = buf[2*j+i+2]; - } - eeprom->serial[j] = '\0'; - // verify checksum checksum = 0xAAAA;