]> jspc29.x-matter.uni-frankfurt.de Git - avr.git/commitdiff
DCDC MDC Converter Board: 0x00d1 answer fixed
authorOle Artz <ole.artz@t-online.de>
Thu, 30 Jun 2022 12:57:05 +0000 (14:57 +0200)
committerOle Artz <ole.artz@t-online.de>
Thu, 30 Jun 2022 12:57:05 +0000 (14:57 +0200)
atmega32u4/dcdc_mdc/main.c

index a203613e0f4c9dc821433cc193515b93962b8a00..74690dbb2abbd969843d5369db59f004b3998eaf 100644 (file)
@@ -90,7 +90,7 @@
 uint16_t time;
 
 uint8_t rxcnt = 0, txpoint = 0;
-uint8_t rxbuf[11];
+uint8_t rxbuf[15];
 uint8_t txbuf[12];
 uint16_t adc[16]; // raw values from ADC
 uint16_t V_in = 0;
@@ -328,9 +328,7 @@ void getdata(uint8_t buf) {
       txbuf[length + 2] = 0;
       send_answer_buf(txbuf);
       rxcnt = 0;
-    } else if (rxcnt == 11 && is_my_address(10)) {
-      // message is for this uC
-//    } else if (is_my_address(10)) { //answer 0x00d1 works with this line
+    } else if (rxcnt == 11 && is_my_address(10)) {// message with correct length is for this uC
 
       if (rxbuf[0] == 'W') {
         // write
@@ -483,10 +481,11 @@ void getdata(uint8_t buf) {
         }
       }
     }
-    if (rxcnt >= 11 || buf == '\n' || buf == '\r') {
-      rxcnt = 0;
-    }
   }
+  if (rxcnt >= 11 || buf == '\n' || buf == '\r') {
+    rxcnt = 0;
+  }
+
 }