Update Copyright to 2017, switch download URLs to HTTPS
[libftdi] / examples / eeprom.c
index e947c00..247589a 100644 (file)
@@ -30,7 +30,8 @@ int read_decode_eeprom(struct ftdi_context *ftdi)
     ftdi_get_eeprom_value(ftdi, CHIP_SIZE, & value);
     if (value <0)
     {
-        fprintf(stderr, "No EEPROM found\n");
+        fprintf(stderr, "No EEPROM found or EEPROM empty\n");
+        fprintf(stderr, "On empty EEPROM, use -w option to write default values\n");
         return -1;
     }
     fprintf(stderr, "Chip type %d ftdi_eeprom_size: %d\n", ftdi->type, value);
@@ -169,7 +170,20 @@ int main(int argc, char **argv)
             retval = EXIT_SUCCESS;
             goto do_deinit;
         }
-        f = ftdi_usb_open_dev(ftdi,  devlist[0].dev);
+        else if (res == 1)
+        {
+            f = ftdi_usb_open_dev(ftdi,  devlist[0].dev);
+            if (f<0)
+            {
+                fprintf(stderr, "Unable to open device %d: (%s)",
+                        i, ftdi_get_error_string(ftdi));
+            }
+        }
+        else
+        {
+            fprintf(stderr, "No devices found\n");
+            f = 0;
+        }
         ftdi_list_free(&devlist);
     }
     else