X-Git-Url: http://developer.intra2net.com/git/?p=libftdi;a=blobdiff_plain;f=src%2Fftdi.c;h=5ffad8fd2d4156ba0529e8b2ccebd54d42b7c649;hp=409e2940bf06853d08866219be6cd8181c4c3321;hb=802a949e535f479b694ee04d49c071900314ce91;hpb=74e8e79d4e311001d0f890cdf0219d84b58bb70a diff --git a/src/ftdi.c b/src/ftdi.c index 409e294..5ffad8f 100644 --- a/src/ftdi.c +++ b/src/ftdi.c @@ -2180,18 +2180,25 @@ int ftdi_set_error_char(struct ftdi_context *ftdi, /** Init eeprom with default values. \param ftdi pointer to ftdi_context - + \param manufacturer String to use as Manufacturer + \param product String to use as Product description + \param serial String to use as Serial number description + + \retval 0: all fine + \retval -1: No struct ftdi_context + \retval -2: No struct ftdi_eeprom */ -void ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, char * manufacturer, +int ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, char * manufacturer, char * product, char * serial) { struct ftdi_eeprom *eeprom; if (ftdi == NULL) - return; + ftdi_error_return(-1, "No struct ftdi_context"); + if (ftdi->eeprom == NULL) - return; + ftdi_error_return(-2,"No struct ftdi_eeprom"); eeprom = ftdi->eeprom; memset(eeprom, 0, sizeof(struct ftdi_eeprom)); @@ -2251,6 +2258,7 @@ void ftdi_eeprom_initdefaults(struct ftdi_context *ftdi, char * manufacturer, } else eeprom->size = -1; + return 0; } /** @@ -2319,7 +2327,7 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) size_check -= serial_size*2; /* Space for the string type and pointer bytes */ - size_check -= -6; + size_check -= -9; // eeprom size exceeded? if (size_check < 0) @@ -2453,6 +2461,13 @@ int ftdi_eeprom_build(struct ftdi_context *ftdi) output[i & k] = eeprom->serial[j], i++; output[i & k] = 0x00, i++; } + output[i & k] = 0x02; /* as seen when written with FTD2XX */ + i++; + output[i & k] = 0x03; /* as seen when written with FTD2XX */ + i++; + output[i & k] = eeprom->is_not_pnp; /* as seen when written with FTD2XX */ + i++; + output[0x13] = serial_size*2 + 2; /* Fixme: ftd2xx seems to append 0x02, 0x03 and 0x01 for PnP = 0 or 0x00 else */ @@ -2886,6 +2901,7 @@ int ftdi_eeprom_decode(struct ftdi_context *ftdi, int verbose) fprintf(stdout, "Pull IO pins low during suspend\n"); if(eeprom->remote_wakeup) fprintf(stdout, "Enable Remote Wake Up\n"); + fprintf(stdout, "PNP: %d\n",(eeprom->is_not_pnp)?0:1); if (ftdi->type >= TYPE_2232C) fprintf(stdout,"Channel A has Mode %s%s%s\n", channel_mode[eeprom->channel_a_type],