Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

added preliminary 'FS_NO_GLOBALS' support #112

Closed
wants to merge 1 commit into from

Conversation

DedeHai
Copy link

@DedeHai DedeHai commented Dec 11, 2016

changes suggested in issue #111

@me-no-dev
Copy link
Owner

maybe should all be defined as fs::File/Dir instead and not use the FS_NO_GLOBALS.
It will not break any functionality and will cliean things a bit :)

@DedeHai
Copy link
Author

DedeHai commented Dec 15, 2016

possible, but won't that break the possibility to use files from the SD card filesystem to be served by the webserver? the fs namespace is used for SPIFFS only afaik. the FS_NO_GLOBALS is used to make the SPIFFS accessible when the SD.h is included in the application.

@me-no-dev
Copy link
Owner

you can not really server SD files from the same handlers currently. Both libs are quite different and differ somewhat in functionality, so you always need to have separate handlers for SD files, or am I wrong here?

@CiTroNaK
Copy link

Thank you guys!

I need to use SD card for storing some data and tried your changes. I have not too much experience, but I found that is not possible to use SD.write() with ESPAsyncWebServer. The file is always empty. It is highly possible, that I have a some error in my code...

You can try it yourself on this project https://github.com/CiTroNaK/RF_REST_Control - SD.write() not work here.

I've made a test project, where I tested SD.write() and it work. You can see it here https://github.com/CiTroNaK/SD_test.

The both project use the same code to store data on SD.

@DedeHai
Copy link
Author

DedeHai commented Jan 19, 2017

@CiTroNaK not sure what you are trying to accomplish. FS_NO_GLOBALS is only for SPIFFS which you are not using so there is no point in defining it.

@CiTroNaK
Copy link

CiTroNaK commented Jan 19, 2017

@DedeHai yes, but...

If I get rid of FS_NO_GLOBALS with your modifications or without them:

Arduino: 1.8.0 (Mac OS X), Vývojová deska: "WeMos D1 R2 & mini, 160 MHz, 921600, 4M (1M SPIFFS)"

In file included from /Users/Petr/Documents/Arduino/libraries/ESPAsyncWebServer/src/ESPAsyncWebServer.h:28:0,
                 from /Users/Petr/Documents/Arduino/RF_REST_Control/RF_REST_Control.ino:29:
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:136:11: error: 'File' is already declared in this scope
 using fs::File;
           ^
/Users/Petr/Documents/Arduino/RF_REST_Control/RF_REST_Control.ino: In function 'void loadDevices()':
RF_REST_Control:113: error: no match for 'operator=' (operand types are 'fs::File' and 'File')
     dataFile = SD.open(SD_FILE, FILE_READ);
              ^
/Users/Petr/Documents/Arduino/RF_REST_Control/RF_REST_Control.ino:113:14: note: candidates are:
In file included from /Users/Petr/Documents/Arduino/libraries/ESPAsyncWebServer/src/ESPAsyncWebServer.h:28:0,
                 from /Users/Petr/Documents/Arduino/RF_REST_Control/RF_REST_Control.ino:29:
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note: fs::File& fs::File::operator=(const fs::File&)
 class File : public Stream
       ^
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note:   no known conversion for argument 1 from 'File' to 'const fs::File&'
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note: fs::File& fs::File::operator=(fs::File&&)
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note:   no known conversion for argument 1 from 'File' to 'fs::File&&'
RF_REST_Control:157: error: no match for 'operator=' (operand types are 'fs::File' and 'File')
     dataFile = SD.open(SD_FILE, FILE_WRITE);
              ^
/Users/Petr/Documents/Arduino/RF_REST_Control/RF_REST_Control.ino:157:14: note: candidates are:
In file included from /Users/Petr/Documents/Arduino/libraries/ESPAsyncWebServer/src/ESPAsyncWebServer.h:28:0,
                 from /Users/Petr/Documents/Arduino/RF_REST_Control/RF_REST_Control.ino:29:
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note: fs::File& fs::File::operator=(const fs::File&)
 class File : public Stream
       ^
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note:   no known conversion for argument 1 from 'File' to 'const fs::File&'
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note: fs::File& fs::File::operator=(fs::File&&)
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note:   no known conversion for argument 1 from 'File' to 'fs::File&&'
/Users/Petr/Documents/Arduino/RF_REST_Control/RF_REST_Control.ino: In function 'void saveDevices()':
RF_REST_Control:164: error: no match for 'operator=' (operand types are 'fs::File' and 'File')
   dataFile = SD.open(SD_FILE, FILE_WRITE);
            ^
/Users/Petr/Documents/Arduino/RF_REST_Control/RF_REST_Control.ino:164:12: note: candidates are:
In file included from /Users/Petr/Documents/Arduino/libraries/ESPAsyncWebServer/src/ESPAsyncWebServer.h:28:0,
                 from /Users/Petr/Documents/Arduino/RF_REST_Control/RF_REST_Control.ino:29:
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note: fs::File& fs::File::operator=(const fs::File&)
 class File : public Stream
       ^
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note:   no known conversion for argument 1 from 'File' to 'const fs::File&'
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note: fs::File& fs::File::operator=(fs::File&&)
/Users/Petr/Documents/Arduino/hardware/esp8266com/esp8266/cores/esp8266/FS.h:48:7: note:   no known conversion for argument 1 from 'File' to 'fs::File&&'
exit status 1
no match for 'operator=' (operand types are 'fs::File' and 'File')

@Matheus-Garbelini
Copy link

Hello, i have a project that works very well by serving files from SD card. But here's the difference: I used sdfat library, that library is veeery fast. After that I edited some files in async server to use always fs::FILE to not conflict and offcourse added FS_NO_GLOBALS in the header, the only problem I have is with async response with callback, but I fear that's not because of the SD library

@me-no-dev
Copy link
Owner

to recap this PR. If you change all to fs::, I will merge this. No need to check if globals are enabled or not.

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

Successfully merging this pull request may close these issues.

4 participants