khoih-prog / FTP_Server_Teensy41

FTP Server for Teensy 4.x using SD, LittleFS, etc. with QNEthernet, NativeEthernet, W5x00 with Ethernet_Generic Library or Adafruit Airlift Featherwing using WiFiNINA_Generic Library
GNU General Public License v3.0
6 stars 2 forks source link

file share over FTP #1

Closed MaherDyayn closed 2 years ago

MaherDyayn commented 2 years ago

Hi this is not a issue, but I wondering how to share files from the SD card in the Teensy 4.1 over FTP. From the FTP_Server_SDFAT2.ino example I see it is printing information about file names, sizes etc is there any way to download an entire file from the Teensy SD card using FTP? could you provide a short example? Thanks

khoih-prog commented 2 years ago

This is the FTP Server library, not the FTP Client library.

Try using Filezilla, any FTP client, etc. to download.

It's also easy to write / port the examples. Have a look at other libraries, such as esp32_ftpclient.

You can also post for help on Teensy Forum.

khoih-prog commented 2 years ago

I'm in the process of porting / rewriting the new FTPClient_Generic, to support all boards (including Teensy, Portenta, SAMD, RP2040, etc), using Ethernet, WiFi.

I'll publish the new library within several days.

Some preliminary test results hereafter. The server is Teensy4.1 using QNEthernet and this FTP_Server_Teensy41 library


FTPClient_UploadImage on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library on SPI0/SPI

Starting FTPClient_UploadImage on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library on SPI0/SPI
FTPCLIENT_GENERIC v1.0.0
[EWS] =========== USE_ETHERNET_GENERIC ===========
[EWS] Default SPI pinout:
[EWS] MOSI: 19
[EWS] MISO: 16
[EWS] SCK: 18
[EWS] SS: 17
[EWS] =========================
[EWS] RPIPICO setCsPin: 17
[ETG] W5100 init, using SS_PIN_DEFAULT = 17 , new ss_pin =  10 , W5100Class::ss_pin =  17
[ETG] Chip is W5100S
[ETG] W5100::init: W5100S, SSIZE = 4096
[EWS] =========================
[EWS] Currently Used SPI pinout:
[EWS] MOSI: 19
[EWS] MISO: 16
[EWS] SCK: 18
[EWS] SS: 17
[EWS] =========================
Using mac index = 4
Connected! IP address: 192.168.2.101
[FTP] Connecting to:  192.168.2.241
[FTP] Command connected
[FTP] Send USER =  teensy4x
[FTP] Send PASSWORD =  ftp_test
[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 CWD
[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

Directory info: 
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=20190101023514;Size=18; helloworld.txt

Type=dir;Modify=20190101000020;Size=0; myNewDir

Type=dir;Modify=20190101001150;Size=0; my_new_dir

Type=file;Modify=20190101023748;Size=51695; octocat.jpg

Type=file;Modify=20190101023748;Size=11; hello_world.txt

Writing octocat.jpg
[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 STOR
[FTP] Writing
[FTP] Close File
Writing hello_world.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] Connection closed

FTPClient_DownloadFile on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library on SPI0/SPI

Starting FTPClient_DownloadFile on MBED RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library on SPI0/SPI
FTPCLIENT_GENERIC v1.0.0
[EWS] =========== USE_ETHERNET_GENERIC ===========
[EWS] Default SPI pinout:
[EWS] MOSI: 19
[EWS] MISO: 16
[EWS] SCK: 18
[EWS] SS: 17
[EWS] =========================
[EWS] RPIPICO setCsPin: 17
[ETG] W5100 init, using SS_PIN_DEFAULT = 17 , new ss_pin =  10 , W5100Class::ss_pin =  17
[ETG] Chip is W5100S
[ETG] W5100::init: W5100S, SSIZE = 4096
[EWS] =========================
[EWS] Currently Used SPI pinout:
[EWS] MOSI: 19
[EWS] MISO: 16
[EWS] SCK: 18
[EWS] SS: 17
[EWS] =========================
Using mac index = 19
Connected! IP address: 192.168.2.114
[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

[FTP] Result end
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=20190101024026;size=18; helloworld.txt

type=dir;modify=20190101000020;size=0; mynewdir

type=dir;modify=20190101001150;size=0; my_new_dir

type=file;modify=20190101023928;size=51695; octocat.jpg

type=file;modify=20190101023930;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