-
Hello everyone, I have been trying to create a simple communication between 5 (RFM95W) modules but I am transmitting big messages between two of them. With that in mind to avoid having issues with memory I dont want to store the content of messages bigger than 50 characters to some of the modules. Is there any way I can discard a message after using "getPacketLength" method to find the packet length? If I use "readData" method can I somehow make it to read the data and clear the fifo without giving it a pointer to store the message? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
If you take a look at the source you'll see that you only get what you ask for and the rest is automagically cleared. So just ask for one byte, get one byte and discard. |
Beta Was this translation helpful? Give feedback.
-
@polys96 this is basically the default behavior - as @HeadBoffin pointed out, you only get the the number of bytes you specify in I would like to point out though that your use case seems slightly odd. Of course, I don't know the context, but I don't think it will help you much with memory usage (program memory? data memory?) to be storing 50 bytes of each message, since the maximum packet length is 255 bytes anyway - unless each device keeps some log of past messages... |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your clarifications! |
Beta Was this translation helpful? Give feedback.
@polys96 this is basically the default behavior - as @HeadBoffin pointed out, you only get the the number of bytes you specify in
readData
, anything above that limit is discarded. So if you callreadData(buffer, 50)
you will never get more than 50 bytes. However, you always have to provide a large enough memory buffer where the received data is to be stored.I would like to point out though that your use case seems slightly odd. Of course, I don't know the context, but I don't think it will help you much with memory usage (program memory? data memory?) to be storing 50 bytes of each message, since the maximum packet length is 255 bytes anyway - unless each device keeps some log of past me…