From a9e506d3d75e2d2061ff5fa428c84c686dc04700 Mon Sep 17 00:00:00 2001 From: masierra Date: Fri, 4 Mar 2016 10:42:42 -0800 Subject: [PATCH] set middle_len for transfers without buffer blocks to 0 --- src/canard.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/canard.c b/src/canard.c index cdb4c166..756fbd6e 100644 --- a/src/canard.c +++ b/src/canard.c @@ -290,12 +290,18 @@ void canardHandleRxFrame(CanardInstance* ins, const CanardCANFrame* frame, uint6 } else { + uint16_t middle_len = 0; + // for transfers without buffer_blocks + if (rxstate->buffer_blocks != NULL) + { + middle_len = rxstate->payload_len - CANARD_RX_PAYLOAD_HEAD_SIZE; + } CanardRxTransfer rxtransfer = { .timestamp_usec = timestamp_usec, .payload_head = rxstate->buffer_head, .payload_middle = rxstate->buffer_blocks, .payload_tail = frame->data, - .middle_len = rxstate->payload_len - CANARD_RX_PAYLOAD_HEAD_SIZE, + .middle_len = middle_len, .payload_len = rxstate->payload_len + frame->data_len - 1, .data_type_id = data_type_id, .transfer_type = transfer_type,