String Class recommended on embedded systems?

09 Mar 2015

Hello,

I'm working on a data logging project and the text parsing aspect of it is getting more and more complicated. I'm jumping through hoops to avoid using std:string out of fear of its overhead and that it will slow down my logger. Is this founded? I guess the answer is to try it and see, but it could take a good bit of time to go down that road only to find it breaks everything.

I'm using an LPC4088 logging a bunch of sensors, and writing to an LCD and SD card at 10hz. I have plenty of free Flash and RAM (i'm using under 20% of each)

Should I be afraid of the String class?

09 Mar 2015

Is that including the 32MB SDRAM of that board? It has more RAM than all other mbed boards combined :D.

Anyway String alone will make many of the small MCUs run out of memory, and be a significant overhead on the others. However the LPC4088 isn't exactly low on resources. So not only do you have alot of space left, also relative to the total size using string has alot smaller impact.

I don't know exactly about the computing resources taken by string, but I assume thats also significantly more. However if it comes down to logging some sensors and writing some things at 10Hz then it should be no problem whatsoever. And the LPC4088 might be kind overkill ;).

So from what you describe I don't imagine you will run into issues. But of course if you do decide that you need to use another 70% of your flash, and that it does need to calculate Pi up to 1000 decimals 500 times per second, then String will be a bad choice. So I would say it depends on what your system needs to do exactly.

10 Mar 2015

I have a RC transmitter with a Mbed 1768. It iswritten in C++, with some very usefull objects: vectors and strings.
For the human interface the strings are a real pleasure compared with the C programming.
The real time loop run at 100Hz , does not use many strings, I can not comment about the performance.
The overhead is memory . I measure the available RAM (a loop with malloc().
...go with string !

13 Mar 2015

Thanks all.

Yes, the LPC4088 is a beast, i'm hoping it can hide all my mistakes :P I actually want it for the LCD controller which I hope to get running some day.

Anyway, it sounds like its certainly worth a shot. I think the bottleneck in my system write now is the I2C character LCD controller anyway.

Thanks again, Dan