[U-Boot-Users] [PATCH] Add flash programming counter]

Jerry Van Baren
2008-03-07T13:33:46Z

Jerry Van Baren wrote:
> Clemens Koller wrote:

[snip]

> Here is a revised command line example that autoscales to 50 dots:
>
> #include <stdio.h>
> #include <unistd.h>
>
> int main(int argc, char *argv[])
> {
> int k;
> int cnt;
> int scale;
>
> if(sscanf(argv[1], "%d", &cnt) != 1) {
> fprintf(stderr, "sscanf() failed\n");
> return 0;
> } else {
>
> scale = (cnt >= 50) ? cnt / 50 : 1;

Oops, the above line should be:
scale = (cnt >= 50) ? (cnt +49) / 50 : 1;

>
> #ifdef ONELINEBAR
> printf("%*c\r", (cnt + scale - 1) / scale, '|');
> #else
> printf("%*c\n", (cnt + scale - 1) / scale, 'v');
> #endif
> fflush(stdout);
>
> for(k = 0; k < cnt; k++) {
> if ((k % scale) == 0) {
> usleep(100000);
> putchar('.');
> fflush(stdout);
> }
> }
> printf("\n");
> }
> return 0;
> }

Forgot to test the (50*n)-1 corner case for n > 0. :-P

gvb