mardi 30 juillet 2019

Size limits on stringstream for embedded

Keen to use stringstream on an STM32 for handling data that gets sent over various UART connections to radio modules (wifi, BLE, Zigbee, etc). I am running FreeRTOS, if that matters. Very concerned about the dynamic memory allocation in the STL lib causing unhandled overflows (I have to have "-fno-exceptions"). I can handle buffer overruns myself in a simple writer method, so that isn't an issue, but I want to be certain that the stringstream never tries to increase it's memory beyond a pre-set limit.

Currently I just use char* buffers, but, I want to find a better solution.

I want to be able to do something like this.

#include <sstream>      // std::stringstream

class Wifi
{
public:
    std::stringstream* ss;

    Wifi()
    {
        ss.set_max_size(1024); // 1kB
    }
};

TIA

Aucun commentaire:

Enregistrer un commentaire