ESP8266 NONOS SDK – Read SpiFlash size of nested data during runtime

So today I ran into a little bit of a snag, I was trying to copy an unknown amount of data into a buffer and then strcat That into another buffer. However during this I had a slight issue where the unknown data coming in the first buffer even though it fits into the destination buffer once it gets strcat into the 2nd buffer it may not. So I had identify the size of the unknown data, the issue was that I was pulling this data during runtime via SPIflash so I crafted this nice little function below to give me an idea of the size of the data that is in the 2nd buffer then in my main function count down the remaining bytes as I take the data in to the first unknown buffer, then chopping off the rest to prevent the chip from crashing in a buffer overflow.

Leave a comment

Your email address will not be published.