Modbus

Parents 7c955a1d39e8
Children 5b6407edfe8e
fix bug with receive buffer handling. Was causing data corruption during communication errors with long frames.
  • +6 -3
    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) {