Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By swilson
#17412
ReinholdHiller wrote:But it adds up. Every little "Serial.println("debug: blah");" eats another piece of RAM. And how to know when Stack is full? Then you will get random crashes without any chance to debug it...

I think there is need of a solution like F() or PROGMEM...


F() does work. client.write(F());, serial.print(F()); and the like works just fine. I am using them now and combining a lot of lines into one and the webpage loads faster.
User avatar
By andres
#18171
swilson wrote:F() does work. client.write(F());, serial.print(F()); and the like works just fine. I am using them now and combining a lot of lines into one and the webpage loads faster.


??? MMM... Did You give a look at source code?
Code: Select all typedef char* __FlashStringHelper;
//#define F(str)  []() -> const char * { static const char tmp[] ICACHE_RODATA_ATTR = str; return &tmp[0]; }()
#define F(str) str 

This is a Quote of Wstring.h, in "...\core\esp8266". As You can see, F(str) is the same as str, the old one is "//ed", and obviously, if You compile with & without F() You will see no change in code dimension...
User avatar
By andres
#18480
andres wrote:
Code: Select all typedef char* __FlashStringHelper;
//#define F(str)  []() -> const char * { static const char tmp[] ICACHE_RODATA_ATTR = str; return &tmp[0]; }()
#define F(str) str 

This is a Quote of Wstring.h, in "...\core\esp8266". As You can see, F(str) is the same as str, the old one is "//ed", and obviously, if You compile with & without F() You will see no change in code dimension...


Well... :) I've installed new release, 1.6.4-673-g8cd3697, and now the code seems to be changed...

Code: Select all // an abstract class used as a means to proide a unique pointer type
// but really has no body
class __FlashStringHelper;
#define F(string_literal) (reinterpret_cast<const __FlashStringHelper *>(PSTR(string_literal)))
 


Now, using F(), effectively leaves more RAM free, as checked with system_get_free_heap_size()... ;)
User avatar
By Manuel Iglesias
#23767 Hello draco,

I tried your original code and with build 1.6.5-804-g2d340c7 I am getting the attached exception serial console log at run time when entering root directory in browser.

Would you mind to take a look? and point me in the right direction if possible please,

Thank you in advance,
You do not have the required permissions to view the files attached to this post.