From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jerry Van Baren Date: Fri, 07 Mar 2008 08:33:46 -0500 Subject: [U-Boot-Users] [PATCH] Add flash programming counter] In-Reply-To: <47D1422A.50703@ge.com> References: <20080306163208.46EF8242FF@gemini.denx.de> <47D02734.3000705@discworld.dascon.de> <47D04779.1070404@ge.com> <47D13CD0.5030905@anagramm.de> <47D1422A.50703@ge.com> Message-ID: <47D1443A.40604@ge.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Jerry Van Baren wrote: > Clemens Koller wrote: [snip] > Here is a revised command line example that autoscales to 50 dots: > > #include > #include > > 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