Receiving 32 bytes struts via NRF24L01+ causes Arduino error

I built two very simple transmitters using only Arduino Nanos and NRF24L01+ transceivers, library used is RF24Network (GitHub - maniacbug/RF24Network: Network Layer for nRF24L01(+) Radios). I tried some examples and everything worked fine, until I tried to send a 32 bytes struct from one transmitter to the other, that is when I encountered a very strange restarting issue on my receiver.

So I modified the helloworld_tx/rx examples to extend the sending package to 32 bytes, in this case a 32-bytes array. I then have a portion of code at the receiver end to print out this array.

Basically, when the sender transmits the #1 package, the receiver can pick it up smoothly. Problem is when the #2 package is sent, the receiver will print out a portion of first package and restart itself, hence leading to a lost of 2nd package. This then goes on forever for every #odd package is received and #even package is lost.

It is very weird since I believe the NRF24 should be able to handle a 32-bytes struct. The problem disappears once I reduce the struct size to 30 bytes, it seems that there are 2 bytes hidden in my package and I have no idea where they are. Could somebody look my sketches and give me a hint?

Sender:

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>

RF24 radio(9, 10);                    // nRF24L01(+) radio attached using Getting Started board

RF24Network network(radio);           // Network uses that radio

const uint16_t this_node = 00;        // Address of our node in Octal format
const uint16_t other_node = 01;       // Address of the other node in Octal format

const unsigned long interval = 3000;  // ms
double count = 1;

struct payload_t {
  double x[8];
};

void setup(void)
{
  Serial.begin(115200);
  Serial.println("Sender  Start");

  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
  radio.setPayloadSize(32);
}

void loop() {
  network.update();                          // Check the network regularly

  Serial.print("#");
  Serial.print(count, 0);
  Serial.print(" Sending...");
  payload_t payload =
  { count, 1.123456, 2.123456, 3.123456,        // Using the first 2 bytes to store package number
    4.123456, 5.123456, 6.123456, 7.123456
  };

  RF24NetworkHeader header(/*to node*/ other_node);

  bool ok = network.write(header, &payload, sizeof(payload));
  if (ok)
    Serial.println("ok.");
  else
    Serial.println("failed.");
  count++;
  delay(interval);
}

Receiver:

#include <RF24Network.h>
#include <RF24.h>
#include <SPI.h>


RF24 radio(9, 10);                // nRF24L01(+) radio attached using Getting Started board

RF24Network network(radio);       // Network uses that radio
const uint16_t this_node = 01;    // Address of our node in Octal format ( 04,031, etc)
const uint16_t other_node = 00;   // Address of the other node in Octal format

struct payload_t {
  double x[8];
};


void setup(void)
{
  Serial.begin(115200);
  Serial.println("Receiver Start");

  SPI.begin();
  radio.begin();
  network.begin(/*channel*/ 90, /*node address*/ this_node);
  radio.setPayloadSize(32);
}

void loop(void) {
  network.update();                  // Check the network regularly

  while ( network.available() ) {    // Is there anything ready for us?
    RF24NetworkHeader header;        // If so, grab it and print it out
    payload_t payload;
    network.read(header, &payload, sizeof(payload));

    Serial.println("-----------------------");
    Serial.print("Received #");
    Serial.println(payload.x[0], 0);
    for (int i = 1; i < 8; i++) {
      Serial.println(payload.x[i], 6);
    }
  }
}

Print out the sizeof( your structure ) and sizeof( double ). You may be exceeding 32 bytes.

I send 32 byte packets without any problem but have had trouble getting a correct pointer to a structure that the compiler will accept.

If you are using a network header the netto payload is less than 32 byte.
The total maximum is 32.

Arctic_Eddie:
Print out the sizeof( your structure ) and sizeof( double ). You may be exceeding 32 bytes.

The sizes are shown as below:

Size of struct Payload_t = 32
Size of double = 4

So my packet is still within the 32 bytes. This makes sense since a 'double x[8]' should be just 32 bytes, no more no less.

Arctic_Eddie:
I send 32 byte packets without any problem but have had trouble getting a correct pointer to a structure that the compiler will accept.

I use the same pointer as the one used in examples and it passes the compiler so I don't worry about it for now. I start to suspect if the network header consumes the 'missing' 2 bytes. How do you send a 32 byte packet, are you sure your packet size is really 32 or it is actually 30?

Whandall:
If you are using a network header the netto payload is less than 32 byte.
The total maximum is 32.

Are you saying that the network header takes up some payload spaces, which makes my actual available payload less than 32 bytes?

Exactly. The total maximum packet size is 32.

7.3.4 Payload
The payload is the user defined content of the packet. It can be 0 to 32 bytes wide and is transmitted on-air
when it is uploaded to nRF24L01+.

So the library probably cuts the tail off, and you maybe confuse the chip by requesting more than available.
The size of the received data is available, it is wise to check (or use) it.

The MCU can read the length of the received payload by using the R_RX_PL_WID command.
Note: Always check if the packet width reported is 32 bytes or shorter when using the
R_RX_PL_WID command. If its width is longer than 32 bytes then the packet contains errors
and must be discarded. Discard the packet by using the Flush_RX command.

The flushing should be handled by the library.