From 609bc2f0ab684c0345113aecfefd71c0bbcb1e05 Mon Sep 17 00:00:00 2001 From: TMRh20 Date: Mon, 11 Apr 2016 19:40:28 -0600 Subject: [PATCH] Fix alignment/padding issues non-linux devices #78 Per #88 When receiving fragmented payloads, padding was not being added to the frame on non-linux devices, but subtracted during reads. - Remove padding altogether from AVR devices (#defined ARDUINO_ARCH_AVR) - Add padding to received, fragmented payloads on non-AVR, non-Linux devices (for 32-bit devices like ESP8266) May have affected https://github.com/TMRh20/RF24Mesh/issues/71 --- RF24Network.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/RF24Network.cpp b/RF24Network.cpp index 440d9f7f..292b25db 100644 --- a/RF24Network.cpp +++ b/RF24Network.cpp @@ -515,6 +515,11 @@ IF_SERIAL_DEBUG_FRAGMENTATION_L2(for(int i=0; i< frag_queue.message_size;i++){ S memcpy(next_frame,&frag_queue,10); memcpy(next_frame+10,frag_queue.message_buffer,frag_queue.message_size); next_frame += (10+frag_queue.message_size); + #if !defined(ARDUINO_ARCH_AVR) + if(uint8_t padding = (frag_queue.message_size+10)%4){ + next_frame += 4 - padding; + } + #endif IF_SERIAL_DEBUG_FRAGMENTATION( printf_P(PSTR("enq size %d\n"),frag_queue.message_size); ); return true; }else{ @@ -551,10 +556,11 @@ IF_SERIAL_DEBUG_FRAGMENTATION_L2(for(int i=0; i< frag_queue.message_size;i++){ S //IF_SERIAL_DEBUG_FRAGMENTATION( for(int i=0; i