- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.3k
Closed
Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: [ESP-12]
- Core Version: [2.7.1]
- Development Env: [Arduino IDE]
- Operating System: [MacOS]
Settings in IDE
- Module: [Nodemcu]
- Flash Size: [4MB]
- lwip Variant: [v2 Lower Memory]
- Reset Method: [nodemcu]
- Flash Frequency: [40Mhz]
- CPU Frequency: [80Mhz]
- Upload Using: [SERIAL]
- Upload Speed: [115200]
Problem Description
I have a project that uses the SPIFFS system, but now I have been informed that this system will be discontinued. So I switched to LittleFS.
However when doing this I have a problem with the SEEK function!
When using the function it is not working as expected!
I still don't understand what is happening, because it advances infinitely ...
Below I put 2 examples, one using SPIFFS and then LittleFS.
I don't know if this change affects other things.
- I need to know how to fix this seek problem
- I need to know if the switch to LittleFS affects other features or if it's just SEEK
//PROBLEM!!!
#include <LittleFS.h>
void setup() {
  LittleFS.begin();
  Serial.begin(19200);
  LittleFS.remove("/devices.cfg");
  File file;
  file = LittleFS.open("/devices.cfg", "a");
  file.println("Test");
  file.println("Test");
  file.println("Test");
  file.println("Test");
  file.println("Test");
  file.close();
}
void loop() {
    File file;
    file = LittleFS.open("/devices.cfg", "r+");
    
    uint16_t quantLinhas = 0;
    uint32_t auxiliar = 0;
    
    while (file.seek((uint32_t)auxiliar, SeekSet))
    {
        yield();       
        ESP.wdtFeed(); 
        if (file.peek() == '\r')
        {
            quantLinhas++;
        }
        auxiliar++;
        Serial.println(auxiliar);
    }
    Serial.print("END:");
    Serial.println(quantLinhas);
    file.close();
    delay(1000);
  
  }INCREMENT FOREVER...
//GOOD!!!
#include <FS.h>//SPIFFS
void setup() {
  SPIFFS.begin();
  Serial.begin(19200);
  SPIFFS.remove("/devices.cfg");
  File file;
  file = SPIFFS.open("/devices.cfg", "a");
  file.println("Test");
  file.println("Test");
  file.println("Test");
  file.println("Test");
  file.println("Test");
  file.close();
}
// the loop function runs over and over again forever
void loop() {
    File file;
    file = SPIFFS.open("/devices.cfg", "r+");
    
    uint16_t quantLinhas = 0;
    uint32_t auxiliar = 0;
    
    while (file.seek((uint32_t)auxiliar, SeekSet))
    {
        yield();       
        ESP.wdtFeed(); 
        if (file.peek() == '\r')
        {
            quantLinhas++;
        }
        auxiliar++;
        Serial.println(auxiliar);
    }
    Serial.print("END:");
    Serial.println(quantLinhas);
    file.close();
    delay(1000);
  
  }Metadata
Metadata
Assignees
Labels
No labels

