usage(const char *argv0)
{
fprintf(stderr,
- "Usage: %s [tions...] \n"
+ "Usage: %s [options...] \n"
"Test streaming read from FT2232H\n"
- "[-P string] only look for product with given string"
- "[-n] don't check for special block structure"
+ "[-P string] only look for product with given string\n"
+ "[-n] don't check for special block structure\n"
"\n"
"If some filename is given, write data read to that file\n"
"Progess information is printed each second\n"
"\n"
"Options:\n"
"\n"
- "Copyright (C) 2009 Micah Dowty <micah@navi.cx>\n",
+ "Copyright (C) 2009 Micah Dowty <micah@navi.cx>\n"
"Adapted for use with libftdi (C) 2010 Uwe Bonnes <bon@elektron.ikp.physik.tu-darmstadt.de>\n",
argv0);
exit(1);
if (start && (num != start +0x4000))
{
uint32_t delta = ((num-start)/0x4000)-1;
- fprintf(stderr, "Skip %7d blocks from 0x%08x to 0x%08x at blocks %10ld \n",
- delta, start -0x4000, num, blocks);
+ fprintf(stderr, "Skip %7d blocks from 0x%08x to 0x%08x at blocks %10llu\n",
+ delta, start -0x4000, num, (unsigned long long)blocks);
n_err++;
skips += delta;
}
if (start && (num != start +0x4000))
{
uint32_t delta = ((num-start)/0x4000)-1;
- fprintf(stderr, "Skip %7d blocks from 0x%08x to 0x%08x at blocks %10ld \n",
- delta, start -0x4000, num, blocks);
+ fprintf(stderr, "Skip %7d blocks from 0x%08x to 0x%08x at blocks %10llu\n",
+ delta, start -0x4000, num, (unsigned long long) blocks);
n_err++;
skips += delta;
}
if (ftdi_set_interface(&ftdic, INTERFACE_A) < 0)
{
fprintf(stderr, "ftdi_set_interface failed\n");
+ ftdi_deinit(&ftdic);
return EXIT_FAILURE;
}
if (ftdi_usb_open_desc(&ftdic, 0x0403, 0x6010, descstring, NULL) < 0)
{
fprintf(stderr,"Can't open ftdi device: %s\n",ftdi_get_error_string(&ftdic));
+ ftdi_deinit(&ftdic);
return EXIT_FAILURE;
}
if(ftdi_set_latency_timer(&ftdic, 2))
{
fprintf(stderr,"Can't set latency, Error %s\n",ftdi_get_error_string(&ftdic));
+ ftdi_usb_close(&ftdic);
+ ftdi_deinit(&ftdic);
return EXIT_FAILURE;
}
if (ftdi_set_bitmode(&ftdic, 0xff, BITMODE_RESET) < 0)
{
fprintf(stderr,"Can't set synchronous fifo mode, Error %s\n",ftdi_get_error_string(&ftdic));
+ ftdi_usb_close(&ftdic);
+ ftdi_deinit(&ftdic);
return EXIT_FAILURE;
}
ftdi_usb_close(&ftdic);
if ((outputFile = fopen(outfile,"r")) == 0)
{
fprintf(stderr,"Can't open logfile %s, Error %s\n", outfile, strerror(errno));
+ ftdi_usb_close(&ftdic);
+ ftdi_deinit(&ftdic);
return EXIT_FAILURE;
}
check_outfile(descstring);
fclose(outputFile);
}
else if (check)
- fprintf(stderr,"%d errors of %ld blocks (%Le), %d (%Le) blocks skipped\n",
- n_err, blocks, (long double)n_err/(long double) blocks,
+ fprintf(stderr,"%d errors of %llu blocks (%Le), %d (%Le) blocks skipped\n",
+ n_err, (unsigned long long) blocks, (long double)n_err/(long double) blocks,
skips, (long double)skips/(long double) blocks);
exit (0);
}
{
if(n_shown < 30)
{
- fprintf(stderr, "Skip %7d blocks from 0x%08x to 0x%08x at blocks %10ld \n",
- (nread-start)/0x4000, start -0x4000, nread, blocks);
+ fprintf(stderr, "Skip %7d blocks from 0x%08x to 0x%08x at blocks %10llu \n",
+ (nread-start)/0x4000, start -0x4000, nread, (unsigned long long) blocks);
n_shown ++;
}
n_errors++;
pc = pa;
}
if(n_errors)
- fprintf(stderr, "%d blocks wrong from %ld blocks read\n",
- n_errors, blocks);
+ fprintf(stderr, "%d blocks wrong from %llu blocks read\n",
+ n_errors, (unsigned long long) blocks);
else
- fprintf(stderr, "%ld blocks all fine\n",blocks);
+ fprintf(stderr, "%llu blocks all fine\n", (unsigned long long) blocks);
}
}