Explorar o código

Await echo at the initialization

Echo is seemingly being sent right after the synchronization. Await echo replies starting from the very begin of the communication.
Mateusz Bugdalski %!s(int64=13) %!d(string=hai) anos
pai
achega
38e56bae6c
Modificáronse 1 ficheiros con 2 adicións e 0 borrados
  1. 2 0
      lpc.c

+ 2 - 0
lpc.c

@@ -65,12 +65,14 @@ void lpc_init(struct lpc_device *dev) {
     sprog_error("Synchronization successful\n");
   printf("Synchronized\r\n");
   fflush(stdout);
+  fgets(buf, sizeof(buf), stdin); /* deny echoed line */
   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); /* deny echoed line */
   fgets(buf, sizeof(buf), stdin);
   if(strcmp(buf, "OK\r\n")!=0)
     sprog_error("Expected OK, received '%s'\n", buf);