-->
Page 2 of 3

Re: String PROGMEM not working with Serial.println(F("xyz"))

PostPosted: Thu Sep 17, 2015 11:33 am
by brutzler
Hi,
talking about String-objects:
crashing without serial output.
Try this:
Code: Select allconst String html_page2 PROGMEM = "Teststring";

void setup() {
}

void loop() {
}


Crashing on my ESP-12E

Re: String PROGMEM not working with Serial.println(F("xyz"))

PostPosted: Thu Sep 17, 2015 11:36 am
by martinayotte
Same things apply here.
String class isn't PROGMEM aware, so it will try to do a memcpy() instead of memcpy_P(), this is why the crash occurs ...

Re: String PROGMEM not working with Serial.println(F("xyz"))

PostPosted: Fri Sep 18, 2015 1:53 am
by igrr
Code: Select allconst String html_page2 PROGMEM = "Teststring";

Actually this won't work for a more basic reason — you try to place a non-POD type into read-only memory. String class is initialized by its constructor, so when constructor tries to copy "Teststring" into the string, it causes an exception, because this String instance is in read-only memory segment.
You should use PROGMEM only for POD types or arrays of POD types.

Re: String PROGMEM not working with Serial.println(F("xyz"))

PostPosted: Sun Sep 20, 2015 3:18 am
by brutzler
OK,
nerver heard about POD. But I am no C/C++ expert. Far away from this :(
But I think you wanted me to say, that I only can put Char-arrays in PROGMEM and not String-objects.
Is this only on ESP or is this causing problems on a "normal UNO" too?

For me, I will then go the way to use String-objects without PROGMEM for my HTML-Page. Two reasons:
- enough SRAM on the ESP :D
- can use replace() to insert e.g. actual-values into my HTML-code before sending over WiFi.