Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 72 additions & 26 deletions fujprog.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,10 @@ static const char *serial = NULL; /* FTDI serial to support more than one device
static int input_type = TYPE_UNSPECIFIED; /* specify type of input */
static int terminal; /* terminal emulation mode */
static int reload; /* send break to reset f32c */
static int quiet; /* suppress standard messages */
static int quiet = 0; /* suppress standard messages */
static int progress_dots = 0; /* show progress dots */
static int progress_dot_val = 1; /* used to keep track of current percentage summary progress, see progress_dot_inc; percent complete = (progress_dot_val * progress_dot_inc) */
static int progress_dot_inc = 10; /* show progress dot percentage summary in these increments (e.g. a value of 10 to show at 10%, 20%, etc) */
char *svf_name; /* SVF output name */
static int txfu_ms; /* txt file upload character delay (ms) */
static int tx_binary; /* send in raw (0) or binary (1) format */
Expand Down Expand Up @@ -619,28 +622,45 @@ set_port_mode(int mode)

/* Run only if not in identify mode */
if (!opt_info) {
/* Blink status LED by deactivating CBUS pulldown pin */
if (need_led_blink) {
need_led_blink = 0;
led_state ^= USB_CBUS_LED;
if (!quiet && progress_perc < 100) {
if (!display_log) {
fprintf(stderr, "\r");
fprintf(stderr, "Programming: %d%% %c ",
progress_perc, statc[blinker_phase]);
fflush(stderr);
} else {
display_counter++;
if (display_counter >= display_log) {
display_counter=0;
fprintf(stderr, "Programming: %d%%\n",
progress_perc);
/* Blink status LED by deactivating CBUS pulldown pin */
if (need_led_blink) {
need_led_blink = 0;
led_state ^= USB_CBUS_LED;
if (progress_perc < 100) {
if (progress_dots) {
// printing progress dots ....
fprintf(stderr, ".");
if ( progress_perc >= (progress_dot_val * progress_dot_inc) ) {
fprintf(stderr, " %d%% Complete.\n",
progress_perc);
progress_dot_val++;
}
fflush(stderr);
}
else {
if (!quiet) {
if (!display_log) {
// this is the default screen output with / \ - animation chars on one line
fprintf(stderr, "\r");
fprintf(stderr, "Programming: %d%% %c ",
progress_perc, statc[blinker_phase]);
fflush(stderr);
}
else {
// this will print a new log line for each loop here (can be somewhat verbose)
display_counter++;
if (display_counter >= display_log) {
display_counter = 0;
fprintf(stderr, "Programming: %d%%\n",
progress_perc);
fflush(stderr);
}
}
}
}
}
blinker_phase = (blinker_phase + 1) & 0x3;
}
blinker_phase = (blinker_phase + 1) & 0x3;
}
}

#ifdef WIN32
Expand Down Expand Up @@ -768,7 +788,7 @@ setup_usb(void)
return (-1);
}

if (!quiet)
if (!quiet || progress_dots)
printf("Using USB cable: %s\n", hmp->cable_path);

res = FT_SetBaudRate(ftHandle, USB_BAUDS);
Expand Down Expand Up @@ -3030,7 +3050,10 @@ usage(void)
printf(" -h This help message\n");
printf(" -l X Display messages in log fashion every <X> times\n");
printf(" -S serial Select FTDI by serial to support multiple boards\n");
printf(" -q Suppress messages\n");
printf(" -q Suppress messages, but show progress with dots\n");
printf(" -q[n] Suppress messages, but show progress with dots\n");
printf(" and completion update every [n] percent (no space after q).\n");
printf(" -Q Suppress messages, no progress dots\n");

if (terminal) {
printf("\n Terminal emulation mode commands:\n");
Expand Down Expand Up @@ -3165,16 +3188,25 @@ prog(char *fname, int target, int debug)

tend = ms_uptime();
if (res == 0) {
if (!quiet) {
if (!quiet || progress_dots) {
if (!display_log)
fprintf(stderr, "\r");

// if we are showing progress dots, we don't want the "Programming" text to stomp on top of them
if (progress_dots) {
fprintf(stderr, "\n");
}

fprintf(stderr, "Programming: 100%% ");
fprintf(stderr, "\nCompleted in %.2f seconds.\n",
(tend - tstart) / 1000.0);
fflush(stderr);
}
} else
}
else {
fprintf(stderr, "\nFailed.\n");

fflush(stderr);
}
return (res);
}

Expand Down Expand Up @@ -4448,9 +4480,9 @@ main(int argc, char *argv[])
force_prog=0;

#ifndef USE_PPI
#define OPTS "Vqtdzhij:l:T:b:p:x:p:P:a:e:f:D:rs:S:"
#define OPTS "VQtdzhij:l:T:b:p:x:p:P:a:e:f:D:rs:S:q::?"
#else
#define OPTS "Vqtdzhij:l:T:b:p:x:p:P:a:e:f:D:rs:S:c:"
#define OPTS "VQtdzhij:l:T:b:p:x:p:P:a:e:f:D:rs:S:c:q::?"
#endif
while ((c = getopt(argc, argv, OPTS)) != -1) {
switch (c) {
Expand Down Expand Up @@ -4547,7 +4579,21 @@ main(int argc, char *argv[])
serial = optarg;
break;
case 'q':
if (optarg != NULL) {
progress_dot_inc = atoi(optarg); // when the [q] parameter [n] is an integer, show "Completed Pecentage" every [n] percent*.
if (progress_dot_inc == 0) {
progress_dot_inc = 100; // we'll assume zero, or non-numbers, won't show increments
}
}
else {
progress_dot_inc = 100; // no interim completion increments markers
}
quiet = 1;
progress_dots = 1;
break;
case 'Q':
quiet = 1;
progress_dots = 0;
break;
case 'r':
reload = 1;
Expand Down