When you have radio.available() true, you do not necessarily have a full struct of bytes available.
If your struct is 50 bytes ( whatever ) and your radio serial port has received 20 bytes, then radio.available() will
be true and you will attempt to read 50 bytes and there is only 20 bytes received so far and your data will
therefore be wrong in some way.
You need to not attempt to read() the data until it is all there. Or else read the data which you have
and then wait for the rest to arrive.
michinyon:
You need to not attempt to read() the data until it is all there. Or else read the data which you have
and then wait for the rest to arrive.
got any examples on how would i go about doing that?
michinyon:
When you have radio.available() true, you do not necessarily have a full struct of bytes available.
I think you're mistaken about how the RF24 library works. This is not a streaming interface; the radio sends and receives complete packets and returns the whole packet via a single read operation.
michinyon:
When you have radio.available() true, you do not necessarily have a full struct of bytes available.
I think you're mistaken about how the RF24 library works. This is not a streaming interface; the radio sends and receives complete packets and returns the whole packet via a single read operation.
right get that part but how do i tell if the packet is complete so i can read it. or is simply calling radio.read() doing that?
It possibly returns the number of bytes available, or maybe just a true/false, anyway check it out.
Edit, these two functions below tell me that the data is 'payload' size, if the data you put in it is smaller it will be padded upto 'payload' size:
/**
* Get Static Payload Size
*
* @see setPayloadSize()
*
* @return The number of bytes in the payload
*/
uint8_t getPayloadSize(void);
/**
* Get Dynamic Payload Size
*
* For dynamic payloads, this pulls the size of the payload off
* the chip
*
* @return Payload length of last-received dynamic payload
*/
uint8_t getDynamicPayloadSize(void);
The max payload size will be 32 bytes IIRC. Once you fix your string issue you need to make sure a single payload doesn't exceed that or it will be truncated.
When using the RF24Network library it uses 12 bytes for the header so that leaves only 20 bytes for the rest of the payload, something that took a while to realise.
It possibly returns the number of bytes available, or maybe just a true/false, anyway check it out.
Edit, these two functions below tell me that the data is 'payload' size, if the data you put in it is smaller it will be padded upto 'payload' size:
I do not quite understand what your trying to get me to do with the payload size. i define payload size at the size of StructBuff so no matter what size StructBuff is payload is always the size of it.
How ever it seems there might be an "overflow" issue with it given what Tack said.
Unless it auto breaks up the payload and sends them in pieces if that is the case i dont know how the struct on the RX will like that.
this is all new territory for me
michinyon wrote:
Your RX code is also wrong.
When you have radio.available() true, you do not necessarily have a full struct of bytes available.
If your struct is 50 bytes ( whatever ) and your radio serial port has received 20 bytes, then radio.available() will
be true and you will attempt to read 50 bytes and there is only 20 bytes received so far and your data will
therefore be wrong in some way.
You need to not attempt to read() the data until it is all there. Or else read the data which you have
and then wait for the rest to arrive.
and i cheked it comes back true if there is payload. but as Tack pointed out.
The max payload size will be 32 bytes IIRC. Once you fix your string issue you need to make sure a single payload doesn't exceed that or it will be truncated.
When using the RF24Network library it uses 12 bytes for the header so that leaves only 20 bytes for the rest of the payload, something that took a while to realize.
i am going to need to figure out how to break down my block of data to smaller ones so it does not get truncated before i even continue trying to send any more data the 3 floats from my IMU are already to much data at 24 bytes.
tack:
When using the RF24Network library it uses 12 bytes for the header so that leaves only 20 bytes for the rest of the payload, something that took a while to realise.
The library seems to be Maniacbug's RF24 library, which does not have that behaviour. The maximum payload size here is 32 bytes.