fix bug with receive buffer handling. Was causing data corruption during communication errors with long frames.
authormjsousa <msousa@fe.up.pt>
Wed, 02 Jun 2021 09:23:13 +0100
changeset 13 6f6451e78531
parent 11 7c955a1d39e8
child 14 5b6407edfe8e
fix bug with receive buffer handling. Was causing data corruption during communication errors with long frames.
mb_ds_util.h
--- a/mb_ds_util.h	Mon Jun 01 14:28:49 2020 +0100
+++ b/mb_ds_util.h	Wed Jun 02 09:23:13 2021 +0100
@@ -122,9 +122,12 @@
 }
 
 static inline u8 *lb_normalize(lb_buf_t *buf) {
-  return (u8 *)memmove(buf->data,
-                       buf->data + buf->data_start,
-                       buf->data_end - buf->data_start);
+  u8 *ptr = (u8 *)memmove(buf->data,
+                          buf->data + buf->data_start,
+                          buf->data_end - buf->data_start);
+  buf->data_end -= buf->data_start;
+  buf->data_start = 0;
+  return ptr;
 }
 
 static inline u8 *lb_data(lb_buf_t *buf) {