From c8d5685b022156705aefda26d96574449d466e43 Mon Sep 17 00:00:00 2001 From: Alaeddine WESLATI Date: Sat, 27 Jul 2013 10:54:44 +0200 Subject: [PATCH] bugfixes related to size and buffers --- drivers/at86rf231/at86rf231_tx.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/at86rf231/at86rf231_tx.c b/drivers/at86rf231/at86rf231_tx.c index f141bedac3..7635e6fde7 100644 --- a/drivers/at86rf231/at86rf231_tx.c +++ b/drivers/at86rf231/at86rf231_tx.c @@ -36,20 +36,20 @@ int16_t at86rf231_send(at86rf231_packet_t *packet) sequenz_nr += 1; // calculate size of the frame (payload + FCS) */ - packet->length = get_802154_hdr_len(&packet->frame) + packet->frame.payload_len + 2; + packet->length = get_802154_hdr_len(&packet->frame) + packet->frame.payload_len + 1; if(packet->length > AT86RF231_MAX_PKT_LENGTH) { return -1; } // FCS is added in hardware - uint8_t pkt[packet->length-2]; + uint8_t pkt[packet->length]; /* generate pkt */ at86rf231_gen_pkt(pkt, packet); // transmit packet - at86rf231_xmit(pkt, packet->length-2); + at86rf231_xmit(pkt, packet->length); } static void at86rf231_xmit(uint8_t *data, uint8_t length) @@ -92,12 +92,13 @@ static void at86rf231_gen_pkt(uint8_t *buf, at86rf231_packet_t *packet) index = init_802154_frame(&packet->frame, &buf[1]); // add length for at86rf231 - buf[0] = packet->length; + buf[0] = packet->length+1; index++; + offset = index; - while(index < packet->length-2) { - buf[index] = packet->frame.payload[index-offset]; + while(index < packet->length) { + buf[index] = packet->frame.payload[index-offset+1]; index += 1; }