Skip to content

Problem in FS after updating the core #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
lucasromeiro opened this issue May 15, 2019 · 12 comments
Closed

Problem in FS after updating the core #148

lucasromeiro opened this issue May 15, 2019 · 12 comments

Comments

@lucasromeiro
Copy link

Hello, I'm using PlatformIO in its latest version.
I have now updated to use the Arduino 2.5.1 core to use ESP8266 12-F and now my code does not compile anymore!
Accuses error in FS.
I do not understand why. It worked before updating.
I can not find the problem.
Can someone help me?

Captura de Tela 2019-05-15 às 09 19 37

Captura de Tela 2019-05-15 às 09 20 33

Thank you

@lucasromeiro
Copy link
Author

core 2.4.2 work fine:
platform = [email protected]

core 2.5.1 don't work:
platform = espressif8266

why??

@ivankravets
Copy link
Member

Unification of SPIFFS and SD, into single compatible FS, File, and Dir objects

See esp8266/Arduino#5525

@earlephilhower do you have any migrating guide?

@earlephilhower
Copy link
Contributor

There is no migration. They are compatible AFAIK and per many other users and the original SD.h examples, even.

@ivankravets
Copy link
Member

@lucasromeiro could you share a simple project to reproduce this issue?

@lucasromeiro
Copy link
Author

@lucasromeiro could you share a simple project to reproduce this issue?

Sure!

#include "Arduino.h"
#include <ESP8266WiFi.h>
#include <FS.h> //Biblioteca responsável por criar o Sistema de manipulação de arquivos

void setup() {
SPIFFS.begin(); //Inicializa sistema de arquivos
}

void loop() {

File carregaArquivos = SPIFFS.open("/log.txt", "a");
char charState = '1';
carregaArquivos.write(charState);
carregaArquivos.close();
}

Captura de Tela 2019-05-15 às 15 26 03

@earlephilhower
Copy link
Contributor

fs::write takes a pointer and length, or a c-string, or a String, not a char.

@lucasromeiro
Copy link
Author

fs::write takes a pointer and length, or a c-string, or a String, not a char.

If I use String it also does not work!
String charState = "1";

@lucasromeiro
Copy link
Author

I do not understand why this worked in the previous version and now it does not work.

@earlephilhower
Copy link
Contributor

Actually, I think I see the issue.

FS::File never had a File::write(char) method, but it did have a File::write(uint8_t) method. Print(the superclass of File) never supported Print::write(char).

So in the old versions you were getting silent conversions of char->uint8_t (I think you'll get a warning if you go strict enough).

Now, since your call doesn't match any exactly, it is using the template which is for writing Stream children, only.

@earlephilhower
Copy link
Contributor

Try the change in esp8266/Arduino#6101 . I'm not sure if it will break anything else, but it re-enabled the usage.

@lucasromeiro
Copy link
Author

Actually, I think I see the issue.

FS::File never had a File::write(char) method, but it did have a File::write(uint8_t) method. Print(the superclass of File) never supported Print::write(char).

So in the old versions you were getting silent conversions of char->uint8_t (I think you'll get a warning if you go strict enough).

Now, since your call doesn't match any exactly, it is using the template which is for writing Stream children, only.

Got it, so if I switch char to uint8_t it should work the same, right?
I'll try.

@lucasromeiro
Copy link
Author

Actually, I think I see the issue.

FS::File never had a File::write(char) method, but it did have a File::write(uint8_t) method. Print(the superclass of File) never supported Print::write(char).

So in the old versions you were getting silent conversions of char->uint8_t (I think you'll get a warning if you go strict enough).

Now, since your call doesn't match any exactly, it is using the template which is for writing Stream children, only.

Its work!

uint8_t charState = '1';

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants