You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 20, 2025. It is now read-only.
I'm a newbie in C so it ist possible or likely? that I'm total wrong. In this case be patient and correct me.
According to the readme I have created a web server (see code below). It sends an HTML page 'loremipsum.h" via ( server.on("/" ... ) at startup, which is stored in flash as suggested. Normally everything worked fine. In some cases the whole HTML page was not sent, but only the last few bytes.
I was able to attribute this to a lack of memory:
Let's say the HTML page is about 5kb (which is less than the 14kb mentioned in the readme). Now we have a program in RAM that consumes so much memory that the remaining available memory is almost equal to the size of the HTML page. From now on, despite of the use of send_p, only parts of the flash are sent.
I have the impression that send_p uses the RAM to send the content of the flash.
Overall, this reminds me on the behavior of .printf_P and similar compared to .write. Where the former copies the content from flash into ram before sending it and the latter writes directly from flash using no or significantly less ram.
I can reproduce this with the following code. Fill in the appropriate Values for SSID and password.
Search for the line: int remainingMemory = 5200;
Set remainingMemory to values bigger than the size of the html-page. Compile and upload. Look in a browser for the page. You should see a 'lorem Ipsum' html-page.
Repeat this by decreasing the amount of ramainingMemory. At some point when remaingMemory nears the size of loremipsum.h the html page will nor be load correctly. If you decrease further on you reach a point where the ESP crashes and restart an crash again and again and again …
big-html-test.ino:
#include<Arduino.h>#include<ESP8266WiFi.h>#include<ESPAsyncTCP.h>#include<ESPAsyncWebServer.h>#include<SoftwareSerial.h>#include"loremipsum.h"AsyncWebServerserver(80);
intremainingMemory=7000; // 5200;constchar*ssid=// Your WiFi SSIDconstchar*password=// Your WiFi Password// Set your Static IP addressIPAddresslocal_IP(192, 168, 178, 67);
// Set your Gateway IP addressIPAddressgateway(192, 168, 178, 1);
IPAddresssubnet(255, 255, 0, 0);
IPAddressprimaryDNS(8, 8, 8, 8); // optionalIPAddresssecondaryDNS(8, 8, 4, 4); // optionalvoidsetup() {
Serial.begin(115200);
// Configures static IP addressif (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {
Serial.println("STA Failed to configure");
}
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
if (WiFi.waitForConnectResult() !=WL_CONNECTED) {
Serial.printf("WiFi Failed!\n");
return;
}
Serial.println(" ");
Serial.println("IP Address: ");
Serial.println(WiFi.localIP());
server.on("/", HTTP_GET, [](AsyncWebServerRequest*request) {
request->send_P(200, "text/html", index_html);
});
char*buffer= (char*)malloc(ESP.getFreeHeap() -remainingMemory);
memset(buffer, 'A', (ESP.getFreeHeap() -remainingMemory));
buffer[(ESP.getFreeHeap() -remainingMemory-1)] ='\0';
Serial.println(buffer);
//Serial.begin(115200);server.begin();
Serial.print("\navailable Memory: ");
Serial.println(ESP.getFreeHeap());
}
voidloop() {
// put your main code here, to run repeatedly:
}
(I've tried to attach the following. no chance.)
loremipsum.h
const char index_html[] PROGMEM = R"rawliteral(
<!DOCTYPE html><htmllang="us"><head><metacharset="UTF-8"><metaname="viewport" content="width=device-width, initial-scale=1.0"></head><body><div><h1> Lorem ipsum … </h1><p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. </p><p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. </p><p>Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. </p><p>Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. </p><p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis. </p><p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat. </p><p>Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. </p><p>Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto … </p></body></html>
)rawliteral";
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Board: NodeMCU 1.0 ESP12E module
IDE: Arduino2 Version: 2.3.2
I'm a newbie in C so it ist possible or likely? that I'm total wrong. In this case be patient and correct me.
According to the readme I have created a web server (see code below). It sends an HTML page 'loremipsum.h" via ( server.on("/" ... ) at startup, which is stored in flash as suggested. Normally everything worked fine. In some cases the whole HTML page was not sent, but only the last few bytes.
I was able to attribute this to a lack of memory:
Let's say the HTML page is about 5kb (which is less than the 14kb mentioned in the readme). Now we have a program in RAM that consumes so much memory that the remaining available memory is almost equal to the size of the HTML page. From now on, despite of the use of send_p, only parts of the flash are sent.
I have the impression that send_p uses the RAM to send the content of the flash.
Overall, this reminds me on the behavior of .printf_P and similar compared to .write. Where the former copies the content from flash into ram before sending it and the latter writes directly from flash using no or significantly less ram.
I can reproduce this with the following code. Fill in the appropriate Values for SSID and password.
Search for the line: int remainingMemory = 5200;
Set remainingMemory to values bigger than the size of the html-page. Compile and upload. Look in a browser for the page. You should see a 'lorem Ipsum' html-page.
Repeat this by decreasing the amount of ramainingMemory. At some point when remaingMemory nears the size of loremipsum.h the html page will nor be load correctly. If you decrease further on you reach a point where the ESP crashes and restart an crash again and again and again …
big-html-test.ino:
(I've tried to attach the following. no chance.)
loremipsum.h
The text was updated successfully, but these errors were encountered: