Debug Serial para programa resetar o buffer quando houver tamanhos errados na mensagem

Dependencies:   pulga-lorawan-drv PingPong-P2P-ClickButtonToWork-SX1272

Revision:
12:d0ca7c3c8962
Parent:
7:37dc9ce68914
Child:
13:d01f36389be1
--- a/serial.cpp	Tue Apr 13 18:22:27 2021 +0000
+++ b/serial.cpp	Wed Apr 14 00:29:26 2021 +0000
@@ -72,15 +72,23 @@
     i = 0;
     j = rd_index;
     msg_incompleta = 1;
-
+    int lenght = circ_buffer[j+1];
+    
     while (i < buf_len)
     {
-        if (circ_buffer[j] == '>')
+       /* if (circ_buffer[j] == '>')
+        {
+            ///encontrou final de cmd
+            msg_incompleta = 0;
+            break;
+        }*/
+        if (j == lenght+1 && circ_buffer[j] == '>')
         {
             ///encontrou final de cmd
             msg_incompleta = 0;
             break;
         }
+        
         j++;
         i++;
 
@@ -122,7 +130,7 @@
             break;
         }
 
-        if (circ_buffer[rd_index] == '>')
+        if (j == lenght+1 && circ_buffer[rd_index] == '>')
         {
             ///encontrou final de cmd
             break;