Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 7 of 7

Thread: FTPClient_Generic Library

  1. #1
    Senior Member
    Join Date
    Jan 2020
    Location
    Toronto, Canada
    Posts
    117

    FTPClient_Generic Library

    FTPClient_Generic Library

    How To Install Using Arduino Library Manager



    Features

    This FTPClient_Generic Library is a simple yet complete FTP Client library for AVR, mega-AVR, Portenta_H7, Teensy, SAM DUE, Arduino SAMD21, Adafruit SAMD21/SAMD51, Adafruit nRF52, ESP32/ESP8266, STM32, RP2040-based, etc. boards using either WiFi or Ethernet.

    Library is based on and modified from:

    1. Leonardo Bispo's ESP32_FTPClient



    Changelog

    Releases v1.0.0

    1. Initial porting and coding to support many more boards, using WiFi or Ethernet



    Debug Terminal Output Samples

    1. FTPClient_DownloadFile on TEENSY 4.0 with W5x00 using Ethernet_Generic Library on SPI0/SPI

    The following is debug terminal output when running example FTPClient_DownloadFile on TEENSY 4.0 with W5x00 using Ethernet_Generic Library on SPI0/SPI.

    The FTP Server is Teensy 4.1 using QNEthernet and FTP_Server_Teensy41 library


    Code:
    Starting FTPClient_DownloadFile on TEENSY 4.0 with W5x00 using Ethernet_Generic Library on SPI0/SPI
    FTPCLIENT_GENERIC v1.0.0
    [EWS] =========== USE_ETHERNET_GENERIC ===========
    [EWS] Default SPI pinout:
    [EWS] MOSI: 11
    [EWS] MISO: 12
    [EWS] SCK: 13
    [EWS] SS: 10
    [EWS] =========================
    [EWS] Board : TEENSY 4.0 , setCsPin: 10
    [ETG] W5100 init, using SS_PIN_DEFAULT = 10 , new ss_pin =  10 , W5100Class::ss_pin =  10
    [ETG] Chip is W5100S
    [ETG] W5100::init: W5100S, SSIZE = 4096
    [EWS] =========================
    [EWS] Currently Used SPI pinout:
    [EWS] MOSI: 11
    [EWS] MISO: 12
    [EWS] SCK: 13
    [EWS] SS: 10
    [EWS] =========================
    Using mac index = 14
    Connected! IP address: 192.168.2.99
    [FTP] Connecting to:  192.168.2.241
    [FTP] Command connected
    [FTP] Send USER =  teensy4x
    [FTP] Send PASSWORD =  ftp_test
    [FTP] Send CWD
    Creating new file helloworld.txt
    [FTP] Send TYPE Type A
    [FTP] Send PASV
    [FTP] outBuf = 227 Entering Passive Mode (4043483328, port 55600)
    [FTP] _dataAddress:  192.168.2.241 , Data port:  55600
    [FTP] Data connection established
    [FTP] Send STOR
    [FTP] Write File
    [FTP] Close File
    [FTP] Send TYPE Type A
    [FTP] Send PASV
    [FTP] outBuf = 227 Entering Passive Mode (4043483328, port 55600)
    [FTP] _dataAddress:  192.168.2.241 , Data port:  55600
    [FTP] Data connection established
    [FTP] Send RETR
    [FTP] Result start
    [FTP] Result:  150-Connected to port 55600
    150 18 bytes to download
    226-File successfully transferred
    226 1 ms, 18 kbytes/s
    [FTP] Result end
    timedRead timeout = 1000
    The file content is: Hi, I'm a new file
    [FTP] Send TYPE Type A
    [FTP] Send PASV
    [FTP] outBuf = 227 Entering Passive Mode (4043483328, port 55600)
    [FTP] _dataAddress:  192.168.2.241 , Data port:  55600
    [FTP] Data connection established
    [FTP] Send MLSD
    [FTP] Result start
    [FTP] Result:  150 Accepted data connection to port 55600
    226-options: -a -l
    226 18 matches total
    [FTP] Result end
    type=file;modify=20220429231446;size=3810; index1.htm
    type=file;modify=19800101000000;size=13; foo.txt
    type=file;modify=20190101003904;size=3714; index2.htm
    type=file;modify=20220429225004;size=3810; index.htm
    type=file;modify=20220409222458;size=10; mydatalog.txt
    type=file;modify=20220313201514;size=4116; edit.htm.gz
    type=file;modify=20220313201514;size=41214; canadaflag_1.png
    type=file;modify=20220313201514;size=8311; canadaflag_2.png
    type=file;modify=20220313201514;size=11156; canadaflag_3.jpg
    type=file;modify=20190101003834;size=1150; favicon.ico
    type=file;modify=20220313201514;size=1971; graphs.js.gz
    type=file;modify=20220429225252;size=8311; canadaflag_2_1.png
    type=file;modify=20220429225138;size=1547; esp_at_wm_lite.txt
    type=file;modify=20190101002054;size=18; helloworld.txt
    type=dir;modify=20190101000020;size=0; mynewdir
    type=dir;modify=20190101001150;size=0; my_new_dir
    type=file;modify=20190101001412;size=51695; octocat.jpg
    type=file;modify=20190101001414;size=11; hello_world.txt
    File size is: 18
    [FTP] Send TYPE Type I
    [FTP] Send PASV
    [FTP] outBuf = 227 Entering Passive Mode (4043483328, port 55600)
    [FTP] _dataAddress:  192.168.2.241 , Data port:  55600
    [FTP] Data connection established
    [FTP] Send RETR
    [FTP] Result start
    [FTP] Result:  150-Connected to port 55600
    150 18 bytes to download
    226 File successfully transferred
    [FTP] Result end
    [FTP] Send TYPE Type I
    [FTP] Send PASV
    [FTP] outBuf = 227 Entering Passive Mode (4043483328, port 55600)
    [FTP] _dataAddress:  192.168.2.241 , Data port:  55600
    [FTP] Data connection established
    [FTP] Send MKD
    [FTP] FTP error:  521 "myNewDir" directory already exists
    [FTP] Send CWD
    [FTP] FTP error:  521 "myNewDir" directory already exists
    [FTP] Send STOR
    [FTP] FTP error:  521 "myNewDir" directory already exists
    [FTP] Writing
    [FTP] FTP error:  521 "myNewDir" directory already exists
    [FTP] Close File
    CloseConnection
    [FTP] Connection closed

  2. #2
    Junior Member
    Join Date
    May 2022
    Posts
    2
    Teensy 4.1 with MagJack Kit

    I have downloaded and used your example: Ethernet > FTPClient_UploadImage

    No changes to the code. it complies without error but im getting the following error on the debug window, any suggestions please..??:

    Code:
    Starting FTPClient_DownloadFile on TEENSY 4.1 with W5x00 using Ethernet_Generic Library on SPI0/SPI
    FTPCLIENT_GENERIC v1.0.0
    [EWS] =========== USE_ETHERNET_GENERIC ===========
    [EWS] Default SPI pinout:
    [EWS] MOSI: 11
    [EWS] MISO: 12
    [EWS] SCK: 13
    [EWS] SS: 10
    [EWS] =========================
    [EWS] Board : TEENSY 4.1 , setCsPin: 10
    [ETG] W5100 init, using SS_PIN_DEFAULT = 10 , new ss_pin =  10 , W5100Class::ss_pin =  10
    [ETG] W5100::init: no chip :-(
    I have successfully run other example Ethernet programs so wiring and hardware is all functioning correctly.

  3. #3
    Senior Member
    Join Date
    Jan 2020
    Location
    Toronto, Canada
    Posts
    117
    Hi,

    It seems that you're using MagJack Kit with either QNEthernet or NativeEthernet. The code you're using is designed for only W5x00.

    I'm sorry the current version v1.0.0 is not supporting QNEthernet or NativeEthernet yet.

    The new release v1.1.0 will be published by today to add the support. Please wait.

  4. #4
    Senior Member
    Join Date
    Jan 2020
    Location
    Toronto, Canada
    Posts
    117
    Hi @xslippy

    The new FTPClient_Generic releases v1.1.0 has just been published.

    Please test and report any issue, using the new examples in QNEthernet

    Be sure to use another Teensy 4.1 with QNEthernet using FTP_Server_Teensy41 library as the server. Modify the Server IP, ftp_user, ftp_pass as necessary.

    I haven't tested the new release v1.1.0 with any other FTP Server yet.

  5. #5
    Junior Member
    Join Date
    May 2022
    Posts
    2
    My setup is running VSFTPD FTP Server on a Raspberry Pi...
    that works fine as i can connect to it from a PC and my Phone, read and write files.

    I only have one Teensy 4.1 and would like it to FTP files to the Pi.

    (With my use case it makes more sense for the Teensy to push new files to the Pi when they become available, rather than the Pi to keep checking for new files and pull them if a new file exists.)

    I have tried your new code and getting the following debug output:

    Code:
    Starting FTPClient_UploadImage on TEENSY 4.1 with using NativeEthernet
    FTPCLIENT_GENERIC v1.1.0
    [EWS] ======== USE_NATIVE_ETHERNET ========
    =========================
    Using mac index = 3
    Connected! IP address: 192.168.1.243
    [FTP] Connecting to:  192.168.1.203
    [FTP] Command connected
    [FTP] Send USER =  pi
    [FTP] Send PASSWORD =  raspberry
    [FTP] Send TYPE Type A
    [FTP] Send PASV
    [FTP] outBuf = 227 Entering Passive Mode (192,168,1,203,238,12).
    
    [FTP] _dataAddress:  192.0.0.0 , Data port:  168
    [FTP] Send CWD
    [FTP] Send MLSD
    [FTP] FTP error:  500 Unknown command.
    
    
    Directory info: 
    Writing octocat.jpg
    [FTP] Send TYPE Type I
    [FTP] FTP error:  500 Unknown command.
    
    [FTP] Send STOR
    [FTP] FTP error:  500 Unknown command.
    
    [FTP] Writing
    [FTP] FTP error:  500 Unknown command.
    
    [FTP] Close File
    Writing hello_world.txt
    [FTP] Send TYPE Type A
    [FTP] FTP error:  500 Unknown command.
    
    [FTP] Send STOR
    [FTP] FTP error:  500 Unknown command.
    
    [FTP] Write File
    [FTP] FTP error:  500 Unknown command.
    
    [FTP] Close File
    [FTP] Connection closed

  6. #6
    Senior Member
    Join Date
    Jan 2020
    Location
    Toronto, Canada
    Posts
    117
    Try the new FTPClient_Generic releases v1.2.0,which is supporting the vsftpd Server using in Linux, Ubuntu, Raspberry Pi, etc. now.


    The following is debug terminal output when running example FTPClient_UploadImage on TEENSY 4.1 with using NativeEthernet, connecting to vsftpd server


    Code:
    Starting FTPClient_UploadImage on TEENSY 4.1 with NativeEthernet
    FTPCLIENT_GENERIC v1.2.0
    [EWS] ======== USE_NATIVE_ETHERNET ========
    [EWS] =====================================
    Using mac index = 6
    Connected! IP address: 192.168.2.105
    [FTP] Connecting to:  192.168.2.112
    [FTP] Command connected
    [FTP] Send USER =  ftp_test
    [FTP] Send PASSWORD =  ftp_test
    [FTP] Send CWD
    [FTP] Send TYPE Type A
    [FTP] Send PASV
    [FTP] outBuf = 227 Entering Passive Mode (192,168,2,112,156,132).
    
    [FTP] Data port:  40068
    [FTP] _dataAddress:  192.168.2.112 , Data port:  40068
    [FTP] Data connection established
    [FTP] Send LIST
    [FTP] Result:  150 Here comes the directory listing.
    NewDir
    hello_world.txt
    helloworld.txt
    octocat.jpg
    Writing octocat.jpg, size = 51695
    [FTP] Send TYPE Type I
    [FTP] Send PASV
    [FTP] outBuf = 226 Directory send OK.
    227 Entering Passive Mode (192,168,2,112,27,30).
    [FTP] outBuf = 227 Entering Passive Mode (192,168,2,112,122,216).
    [FTP] Data port:  31448
    [FTP] _dataAddress:  192.168.2.112 , Data port:  31448
    [FTP] Data connection established
    [FTP] Send STOR
    [FTP] Writing
    [FTP] WriteData: datalen =  51695
    [FTP] Close File
    Writing hello_world.txt
    [FTP] Send TYPE Type A
    [FTP] Send PASV
    [FTP] outBuf = 227 Entering Passive Mode (192,168,2,112,151,205).
    [FTP] Data port:  38861
    [FTP] _dataAddress:  192.168.2.112 , Data port:  38861
    [FTP] Data connection established
    [FTP] Send STOR
    [FTP] Write File
    [FTP] Close File
    [FTP] Connection closed
    @shawn

    Please check why the binary upload for large files only working on NativeEthernet, not QNEthernet yet (some bug, ???).

  7. #7
    Senior Member
    Join Date
    Jan 2020
    Location
    Toronto, Canada
    Posts
    117
    Releases v1.3.0

    1. Fix uploading issue of large files for WiFi, QNEthernet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •