Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By danbicks
#26044 Martin,

Hi Buddy, I have modified the snip you sent and get the following error when I compile. Any ideas why the min function is causing this issue? PS: Spiffs.begin is called in setup of the sketch.

error:

C:\ARDUINO\arduino-1.6.5\arduino-1.6.5-r2\portable\packages\esp8266\hardware\esp8266\1.6.5-1044-g170995a\cores\esp8266/Arduino.h:252:18: error: expected unqualified-id before '(' token
#define min(a,b) ((a)<(b)?(a):(b))
^
SPIFFS_MOD.ino:14:27: note: in expansion of macro 'min'
Error compiling.

New routine:

void ShowLargeFile()
{
File f = SPIFFS.open("/Config.cfg", "r");
if (!f) {
Serial.println("Can't open Config.cfg !\r\n");
}
else {
char buf[1024];
int siz = f.size();
while(siz > 0) {
size_t len = std::min((int)(sizeof(buf) - 1), siz);
f.read((uint8_t *)buf, len);
buf[len] = 0;
Serial.println(buf);
siz -= sizeof(buf) - 1;
}
f.close();
}

}



cheers Dans
User avatar
By danbicks
#26074 Thanks Martin,

I will give this a try. Having lots of fun with this, I have been able to connect and download data from a server.
Sometimes the file if not found on the server is filled with HTTP i.e. file requested on server is not there, I will need to add some form of parsing to check that the downloaded file content is correct and not an error thrown by the server, otherwise going good, still so much to learn about spiffs.

Cheers buddy

Dans
User avatar
By march_seven
#34278
martinayotte wrote:You can also rely on f.fileSize() and do a while loop, so it will work with any file sizes ... ;)




hi do you know how to config the spiffs when init?