]> jspc29.x-matter.uni-frankfurt.de Git - trbnettools.git/commitdiff
output now stdout, fflush
authorhadaq <hadaq>
Wed, 9 Feb 2011 12:54:49 +0000 (12:54 +0000)
committerhadaq <hadaq>
Wed, 9 Feb 2011 12:54:49 +0000 (12:54 +0000)
libtrbnet/trbflash.c

index 59174521d4528e2e4295e028c1707966e9791f26..fab3c05cef2df52058c21dc04a9035d845f801a9 100644 (file)
@@ -96,7 +96,7 @@ static const char FlashTypeStr[16][32] = {
 
 static FlashType flashType = FLASH_INVALID;
 static uint32_t manId = 0;
-static const char trbflash_version[] = "$Revision: 2.28 $";
+static const char trbflash_version[] = "$Revision: 2.29 $";
 
 static uint32_t mdcFlashSelect = 1;
 
@@ -611,7 +611,6 @@ typedef enum
 static int programImageBuffer(uint16_t trb_address,
                               unsigned int size, PMode mode, int infoPage)
 {
-  int bla = 0;
   unsigned int block;
   int status;
   int errorCtr = 0;
@@ -625,41 +624,44 @@ static int programImageBuffer(uint16_t trb_address,
     char c;
     if ((flashType == FLASH_MDC_OEP_V2) || (flashType == FLASH_MDC_OEP_V3)) {
       if (mdcFlashSelect == 0) {
-        fprintf(stderr,
+        fprintf(stdout,
                 "You decided to reprogram the FlashRom(s) #0 of "
                 "MDC_OEP, the so called 'GoldenImage'. "
                 "Do you really know what you're about to do [N,y]: ");
       }
     } else {
-      fprintf(stderr,
+      fprintf(stdout,
               "You decided to reprogram the FlashRom(s) of "
               "%s, are you sure [N,y]: ", FlashTypeStr[flashType]);
     }
+    fflush(stdout);
 
     c = getc(stdin);
     if (!((c == 'Y') || (c == 'y'))) {
-      fprintf(stderr, "\nAborting on user request\n");
+      fprintf(stdout, "\nAborting on user request\n");
+      fflush(stdout);
       return -1;
     }
   }
 
   if (mode != PMODE_VERIFY) {
-    fprintf(stderr,
+    fprintf(stdout,
             "Programming Endpoint(s) @ Address 0x%04x\n", trb_address);
-    fprintf(stderr,
+    fprintf(stdout,
             "Symbols:\n"
             "  E: Erasing\n"
             "  P: Programming\n" "  @: Success\n" "  .: Skipped\n\n");
   } else {
-    fprintf(stderr, "Verifying Endpoint(s) @ Address 0x%04x\n", trb_address);
-    fprintf(stderr,
+    fprintf(stdout, "Verifying Endpoint(s) @ Address 0x%04x\n", trb_address);
+    fprintf(stdout,
             "Symbols:\n"
             "  V: Verifying\n"
             "  X: Failed (see logfile 'trbflash.log' for details)\n"
             "  @: Success\n" "  .: Skipped\n\n");
   }
-  fprintf(stderr, "Block: 0 1 2 3 4 5 6 7 8 9 A B C D E F");
-
+  fprintf(stdout, "Block: 0 1 2 3 4 5 6 7 8 9 A B C D E F");
+  fflush(stdout);
+  
   errorCtr = 0;
 
   if ((mode != PMODE_VERIFY) && (manId == 0x1520c2)) {
@@ -674,12 +676,14 @@ static int programImageBuffer(uint16_t trb_address,
     int error = 0;
     int writeInfoPage = (block == NUM_BLOCKS - 1) && (infoPage == 1) ? 1 : 0;
     if (block % 16 == 0) {
-      fprintf(stderr, "\n%x      ", block / 16);
+      fprintf(stdout, "\n%x      ", block / 16);
     }
-    fprintf(stderr, ".\b");
-
+    fprintf(stdout, ".\b");
+    fflush(stdout);
+    
     if (!(bytesWritten > 0) && (writeInfoPage == 0)) {
-      fprintf(stderr, ". ");
+      fprintf(stdout, ". ");
+      fflush(stdout);
       continue;
     }
 
@@ -709,7 +713,8 @@ static int programImageBuffer(uint16_t trb_address,
       }
 
       /* Erase block */
-      fprintf(stderr, "E\b");
+      fprintf(stdout, "E\b");
+      fflush(stdout);
       if (sendCommand(trb_address, 0xd8 << 24 | (BLOCK_SIZE * block), 3)
           == -1) {
         fprintf(stderr, "\nError > program: erase block #%d, aborting\n",
@@ -727,7 +732,8 @@ static int programImageBuffer(uint16_t trb_address,
       }
 
       /* Now write pages */
-      fprintf(stderr, "P\b");
+      fprintf(stdout, "P\b");
+      fflush(stdout);
       tmp = bytesWritten;
       for (i = 0, page = (block * BLOCK_SIZE) / PAGE_SIZE;
            (i < (BLOCK_SIZE / PAGE_SIZE)) && (tmp > 0); i++, page++) {
@@ -775,9 +781,9 @@ static int programImageBuffer(uint16_t trb_address,
       }
     } else {
       /* Verify pages */
-      fprintf(stderr, "V\b");
+      fprintf(stdout, "V\b");
+      fflush(stdout);
       tmp = bytesWritten;
-      bla++;
       for (i = 0, page = (block * BLOCK_SIZE) / PAGE_SIZE;
            (i < (BLOCK_SIZE / PAGE_SIZE)) && (tmp > 0); i++, page++) {
         unsigned int endPoint;
@@ -839,10 +845,11 @@ static int programImageBuffer(uint16_t trb_address,
     }
 
     if (error == 0) {
-      fprintf(stderr, "@ ");
+      fprintf(stdout, "@ ");
     } else {
-      fprintf(stderr, "X ");
+      fprintf(stdout, "X ");
     }
+    fflush(stdout);
   }
 
   if ((mode != PMODE_VERIFY) && (manId == 0x1520c2)) {
@@ -854,12 +861,13 @@ static int programImageBuffer(uint16_t trb_address,
   }
 
   if (errorCtr == 0) {
-    fprintf(stderr, "\n\nSuccess\n\n");
+    fprintf(stdout, "\n\nSuccess\n\n");
   } else {
-    fprintf(stderr,
+    fprintf(stdout,
             "\n\n%d Errors have occured, see logFile %s for details\n\n",
             errorCtr, logFileName);
   }
+  fflush(stdout);
 
   return errorCtr == 0 ? 0 : -1;
 }