Author: Paul_R
Date: 2008-09-17 12:31:16 +0200 (Wed, 17 Sep 2008)
New Revision: 1867
Modified:
firmware/tuxup/trunk/bootloader.c
Log:
* Fixed the hashes in the progress bar.
(from prod version at rev 897)
Modified: firmware/tuxup/trunk/bootloader.c
===================================================================
--- firmware/tuxup/trunk/bootloader.c 2008-09-17 10:24:55 UTC (rev 1866)
+++ firmware/tuxup/trunk/bootloader.c 2008-09-17 10:31:16 UTC (rev 1867)
@@ -46,9 +46,9 @@
bool HID;
-static float line_nb;
static float step;
static float progress = 0;
+static int hashes;
/* Debug commands */
//#define keybreak() {puts("Press return to read feedback"); getchar();}
@@ -71,8 +71,7 @@
#ifndef WIN32
static bool wait_status(unsigned char value, int timeout);
#endif
-static void compute_progress_bar(float line_nb);
-
+static void compute_progress_bar(const char *filename);
typedef uint32_t FILE_Addr_t;
typedef uint32_t FILE_SegmentLen_t;
typedef unsigned FILE_LineNum_t;
@@ -399,10 +398,11 @@
{
if ((ret) && (data_buffer[0] == 0xF0) && (data_buffer[1] == 0))
{
- while ((counter >= progress))
+ while (counter >= progress && hashes <= 60)
{
printf("#");
progress += step;
+ hashes++;
}
fflush (stdout);
sleep(0.05);
@@ -418,10 +418,11 @@
{
if ((ret == 64) && (data_buffer[0] == 0xF0) && (data_buffer[1] == 0))
{
- while ((counter >= progress))
+ while (counter >= progress && hashes <= 60)
{
printf("#");
progress += step;
+ hashes++;
}
fflush (stdout);
return TRUE;
@@ -671,12 +672,7 @@
}
/* Nb of line */
- line_nb = 0;
- while (fgets(line, sizeof(line), fs) != NULL)
- line_nb++;
-
- compute_progress_bar(line_nb);
- fs = fopen(fileName, "rt");
+ compute_progress_bar(fileName);
while (fgets(line, sizeof(line), fs) != NULL)
{
@@ -741,6 +737,7 @@
counter = 0;
progress = 0;
+ hashes = 0;
if (HID)
{
@@ -866,10 +863,20 @@
* This progress bar display 60 "#"
* \todo Find a better way to now the number of packet.
*/
-static void compute_progress_bar(float line_nb)
+static void compute_progress_bar(const char *filename)
{
- line_nb = (line_nb / 4);
- if (line_nb<1)
- line_nb = 1;
- step = (line_nb / 60);
+ FILE *fs = NULL;
+ char line[100];
+ int char_cnt = 0;
+
+ if ((fs = fopen(filename, "r")) == NULL)
+ return;
+
+ while (fgets(line, sizeof(line), fs) != NULL)
+ /* 13 bytes are not data to be programmed */
+ char_cnt += strlen(line) - 13;
+ fclose(fs);
+
+ /* 2 chars per byte, 64 bytes per frame, 60 hashes to print */
+ step = (char_cnt / (2 * 64.0 * 60.0));
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn