ESP8266 NodeMCU, SD CARD & SimpleFtpServer

Home Forums esp8266 ESP8266 NodeMCU, SD CARD & SimpleFtpServer

Viewing 6 reply threads
  • Author
    Posts
    • #30833
      BrunoPicard
      Participant

        Hello from France,

        First of all, thanks to Renzo for all his work.
        I have adapted one of Renzo’s examples (Arduino_esp32_SD) to transfer files via FTP between an SD CARD and my PC. When I upload files to the SD CARD, everything works perfectly. However, if I download files from the SD CARD to the PC, the file is created in the destination directory, but it’s empty.
        I use the SD / ESP8266WiFi / SimpleFTPServer libraries.
        I’ve tried this with several FTP clients and files of different sizes: the target file is always empty.
        I should add that I read the file on the SD CARD with this code:

        File config_SD = SD.open("config.txt","r"); 
         if (!config_SD.available()) {
              while (config_SD.available()){
                  Serial.println(config_SD.readStringUntil('\n')); 
              }
          }
         config_SD.close(); 
        

        Could you please give me a hint?
        Thank you and have a nice day.
        Bruno

        • This topic was modified 1 year, 3 months ago by BrunoPicard.
        • This topic was modified 1 year, 3 months ago by BrunoPicard.
      • #30844
        Renzo Mischianti
        Keymaster

          Hi,
          You have set the filezilla whit the correct parameter?
          Bye Renzo

        • #30850
          BrunoPicard
          Participant

            Hi Renzo,
            Thanks for the feedback 🙂
            Filezilla is well configured: upload to SD CARD works perfectly. It’s the same using WinFTP.
            With the same settings, FTP works with another project that uses flash memory storage.

            The only changes to Arduino_esp32_SD.ino are :

            #include <WiFi.h>
            becomes
            #include <ESP8266WiFi.h>

            and

            SPI.begin(14, 12, 15, 13); //SCK, MISO, MOSI,SS
            if (SD.begin(13, SPI)) {

            becomes

            #define CS_PIN D8 
            [...]
            if (SD.begin(CS_PIN )) {
            • This reply was modified 1 year, 3 months ago by BrunoPicard.
            • This reply was modified 1 year, 3 months ago by BrunoPicard.
            • This reply was modified 1 year, 3 months ago by BrunoPicard.
            • This reply was modified 1 year, 3 months ago by BrunoPicard.
            • This reply was modified 1 year, 3 months ago by BrunoPicard.
          • #30866
            BrunoPicard
            Participant

              Hi,

              I traced the code and found out why the file is empty. The file.read() function always returns nb=0. Now I just need to find out why…

              boolean FtpServer::doRetrieve()
              {
              if (data.connected())
              {
              	int16_t nb = file.readBytes(buf, FTP_BUF_SIZE);
                      if (nb > 0)
              [...]
              
            • #30867
              BrunoPicard
              Participant

                I can confirm that this is a bug in the SimpleFtpServer librairy, so there’s no need to check the FTP client settings.

              • #30871
                Renzo Mischianti
                Keymaster

                  Hi, the stream.readBytes must return the number of bytes read, as the documentation specifies, so I think it’s an ESP core temporary bug.
                  But I check better next.
                  Thanks for your feedback, RM

                • #30873
                  BrunoPicard
                  Participant

                    Hi, This is not a core bug.

                Viewing 6 reply threads
                • You must be logged in to reply to this topic.
                Exit mobile version