ソースを参照

Flush stdout

Flush stdout after writing to it
Mateusz Bugdalski 13 年 前
コミット
5a7fc21b1e
1 ファイル変更3 行追加0 行削除
  1. 3 0
      lpc.c

+ 3 - 0
lpc.c

@@ -64,11 +64,13 @@ void lpc_init(struct lpc_device *dev) {
   if(strcmp(buf, "Synchronized\r\n")==0)
     sprog_error("Synchronization successful\n");
   printf("Synchronized\r\n");
+  fflush(stdout);
   fgets(buf, sizeof(buf), stdin);
   if(strcmp(buf, "OK\r\n")!=0)
     sprog_error("Expected OK, received '%s'\n", buf);
   sprog_error("Sending clock frequency\n");
   printf("12000\r\n");
+  fflush(stdout);
   fgets(buf, sizeof(buf), stdin);
   if(strcmp(buf, "OK\r\n")!=0)
     sprog_error("Expected OK, received '%s'\n", buf);
@@ -83,6 +85,7 @@ int lpc_command(char *text, ...) {
   va_list l;
   va_start(l, text);
   vprintf(text, l);
+  fflush(stdout);
   fgets(buf, sizeof(buf), stdin); /* deny echoed line */
   if(scanf("%d\r\n", &res)<1)
     return -1;