[英]FTP client on ethernet shield arduino
I want to do a project in which the data are saved on the SD card, and then use the ethernet shield these data are sent to an ftp server, using an FTP client arduino. 我想做一个将数据保存在SD卡上的项目,然后使用以太网屏蔽将这些数据发送到使用FTP客户端arduino的ftp服务器。 the server i have a free hosting.
服务器,我有一个免费的托管。
Here is the data server from ftptest: 这是ftptest中的数据服务器:
Status: Resolving address of cba.pl Status: Connecting to 95.211.144.68 Warning: The entered address does not resolve to an IPv6 address. Status: Connected, waiting for welcome message... Reply: 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- Reply: 220-You are user number 57 of 200 allowed. Reply: 220-Local time is now 16:30. Server port: 21. Reply: 220-This is a private system - No anonymous login Reply: 220-IPv6 connections are also welcome on this server. Reply: 220 You will be disconnected after 5 minutes of inactivity. Command: CLNT https://ftptest.net on behalf of 2a02:a311:c020:3200:c10d:18e1:36a5:8e2 Reply: 530 You aren't logged in Command: AUTH TLS Reply: 234 AUTH TLS OK. Status: Performing TLS handshake... Status: TLS handshake successful, verifying certificate... Status: Received 2 certificates from server. Status: cert[0]: subject='CN=www.cba.pl' issuer='C=US,O=Let\27s Encrypt,CN=Let\27s Encrypt Authority X3' Status: cert[1]: subject='C=US,O=Let\27s Encrypt,CN=Let\27s Encrypt Authority X3' issuer='O=Digital Signature Trust Co.,CN=DST Root CA X3' Command: USER wsalkowski Reply: 331 User wsalkowski OK. Password required Command: PASS ******** Reply: 230-Your bandwidth usage is restricted Reply: 230-OK. Current restricted directory is / Reply: 230 Max allowed filesize is 10485760 bytes Command: SYST Reply: 215 UNIX Type: L8 Command: FEAT Reply: 211-Extensions supported: Reply: EPRT Reply: IDLE Reply: MDTM Reply: SIZE Reply: MFMT Reply: REST STREAM Reply: MLST type*;size*;sizd*;modify*;UNIX.mode*;UNIX.uid*;UNIX.gid*;unique*; Reply: MLSD Reply: AUTH TLS Reply: PBSZ Reply: PROT Reply: UTF8 Reply: TVFS Reply: ESTA Reply: PASV Reply: EPSV Reply: SPSV Reply: ESTP Reply: 211 End. Command: PBSZ 0 Reply: 200 PBSZ=0 Command: PROT P Reply: 200 Data protection level set to "private" Command: PWD Reply: 257 "/" is your current location Status: Current path is / Command: TYPE I Reply: 200 TYPE is now 8-bit binary Command: PASV Reply: 227 Entering Passive Mode (95,211,144,68,218,36) Command: MLSD Status: Data connection established, performing TLS handshake... Reply: 150 Accepted data connection Status: TLS handshake successful, verifying certificate... Status: Received 2 certificates from server. Status: cert[0]: subject='CN=www.cba.pl' issuer='C=US,O=Let\27s Encrypt,CN=Let\27s Encrypt Authority X3' Status: cert[1]: subject='C=US,O=Let\27s Encrypt,CN=Let\27s Encrypt Authority X3' issuer='O=Digital Signature Trust Co.,CN=DST Root CA X3' Status: TLS session of transfer connection has been resumed. Listing: type=cdir;sizd=4096;modify=20160501192730;UNIX.mode=0755;UNIX.uid=0;UNIX.gid=0;unique=803g16f353ca; . Listing: type=pdir;sizd=4096;modify=20160501192730;UNIX.mode=0755;UNIX.uid=0;UNIX.gid=0;unique=803g16f353ca; .. Listing: type=dir;sizd=4096;modify=20161031125022;UNIX.mode=0700;UNIX.uid=1098695;UNIX.gid=33;unique=803g2259f68; wsalkowski.cba.pl Reply: 226-Options: -a -l Reply: 226 3 matches total Status: Success Results Your server is working and assorted routers/firewalls have been correctly configured for explicit FTP over TLS as performed by this test. However there have been warnings about compatibility issues, not all users will be able to use your server. For maximum compatibility, consider resolving these warnings.
here results from serial monitor arduino ide 这是串行监视器arduino ide的结果
Ready. Press f or r kkksdsSD opened Command connected 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220-You are user number 52 of 200 allowed. 220-Local time is now 15:32. Server port: 21. 220-This is a private system - No anonymous login 220-IPv6 connections are also welcome on this server. 220 You will be disconnected after 5 minutes of inactivity. 331 User wsalkowski OK. Password required 230-Your bandwidth usage is restricted 230-OK. Current restricted directory is / 230 Max allowed filesize is 10485760 bytes 215 UNIX Type: L8 227 Entering Passive Mode (95,211,144,65,208,115) Data port: 53363 Data connected 553 Can't open that file: No such file or directory 221-Goodbye. You uploaded 0 and downloaded 0 kbytes. 221 Logout. Command disconnected SD closed FTP FAIL SD opened Command connected 220---------- Welcome to Pure-FTPd [privsep] [TLS] ---------- 220-You are user number 53 of 200 allowed. 220-Local time is now 15:32. Server port: 21. 220-This is a private system - No anonymous login 220-IPv6 connections are also welcome on this server. 220 You will be disconnected after 5 minutes of inactivity. 331 User wsalkowski OK. Password required 230-Your bandwidth usage is restricted 230-OK. Current restricted directory is / 230 Max allowed filesize is 10485760 bytes 215 UNIX Type: L8 227 Entering Passive Mode (95,211,144,65,208,248) Data port: 53496 Data connected 553 Can't open that file: No such file or directory 221-Goodbye. You uploaded 0 and downloaded 0 kbytes. 221 Logout. Command disconnected SD closed FTP FAIL
and here code arduino (the code i have from http://playground.arduino.cc/Code/FTP ) 这里是代码arduino(我从http://playground.arduino.cc/Code/FTP获得的代码)
/* FTP passive client for IDE v1.0.1 and w5100/w5200 Posted October 2012 by SurferTim Modified 6 June 2015 by SurferTim */ #include #include #include // comment out next line to write to SD from FTP server #define FTPWRITE // this must be unique byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x67 } ; // change to your network settings IPAddress ip( 192, 168, 0, 25 ); IPAddress gateway( 192, 168, 0, 1 ); IPAddress subnet( 255, 255, 255, 0 ); // change to your server IPAddress server( 95, 211, 144, 65); EthernetClient client; EthernetClient dclient; char outBuf[128]; char outCount; // change fileName to your file (8.3 format!) char fileName[13] = "POMIARY.txt"; void setup() { Serial.begin(9600); digitalWrite(10,HIGH); if(SD.begin(4) == 0) { Serial.println(F("SD init fail")); } Ethernet.begin(mac, ip, gateway, gateway, subnet); digitalWrite(10,HIGH); delay(2000); Serial.println(F("Ready. Press f or r")); } void loop() { byte inChar; inChar = Serial.read(); if(inChar == 'f') { if(doFTP()) Serial.println(F("FTP OK")); else Serial.println(F("FTP FAIL")); } if(inChar == 'r') { readSD(); } } File fh; byte doFTP() { #ifdef FTPWRITE fh = SD.open(fileName,FILE_READ); #else SD.remove(fileName); fh = SD.open(fileName,FILE_WRITE); #endif if(!fh) { Serial.println(F("SD open fail")); return 0; } #ifndef FTPWRITE if(!fh.seek(0)) { Serial.println(F("Rewind fail")); fh.close(); return 0; } #endif Serial.println(F("SD opened")); if (client.connect(server,21)) { Serial.println(F("Command connected")); } else { fh.close(); Serial.println(F("Command connection failed")); return 0; } if(!eRcv()) return 0; // Change to your user and password client.write("USER wsalkowski\r\n"); if(!eRcv()) return 0; client.write("PASS pass\r\n"); if(!eRcv()) return 0; client.write("SYST\r\n"); if(!eRcv()) return 0; client.write("PASV\r\n"); if(!eRcv()) return 0; char *tStr = strtok(outBuf,"(,"); int array_pasv[6]; for ( int i = 0; i 63) { dclient.write(clientBuf,64); clientCount = 0; } } if(clientCount > 0) dclient.write(clientBuf,clientCount); #else while(dclient.connected()) { while(dclient.available()) { char c = dclient.read(); fh.write(c); Serial.write(c); } } #endif dclient.stop(); Serial.println(F("Data disconnected")); if(!eRcv()) return 0; client.println(F("QUIT")); if(!eRcv()) return 0; client.stop(); Serial.println(F("Command disconnected")); fh.close(); Serial.println(F("SD closed")); return 1; } byte eRcv() { byte respCode; byte thisByte; while(!client.available()) delay(1); respCode = client.peek(); outCount = 0; while(client.available()) { thisByte = client.read(); Serial.write(thisByte); if(outCount = '4') { efail(); return 0; } return 1; } void efail() { byte thisByte = 0; client.println(F("QUIT")); while(!client.available()) delay(1); while(client.available()) { thisByte = client.read(); Serial.write(thisByte); } client.stop(); Serial.println(F("Command disconnected")); fh.close(); Serial.println(F("SD closed")); } void readSD() { fh = SD.open(fileName,FILE_READ); if(!fh) { Serial.println(F("SD open fail")); return; } while(fh.available()) { Serial.write(fh.read()); } fh.close(); }
If someone tells me what can go and what i am doing wrong ? 如果有人告诉我可以做什么,我做错了什么?
i can throw files using filezilla, but only to the folder wsalkowski.cba.pl 我可以使用filezilla扔文件,但只能扔到文件夹wsalkowski.cba.pl
whether the problem is lack of access to the path /wsalkowski.cba.pl from the ftp client arduino? 问题是否在于无法从ftp客户端arduino访问路径/wsalkowski.cba.pl? That is, the file with the default sd card is thrown to the root folder /, which does not have permission chmod?
即,将具有默认sd卡的文件扔到根目录/中,该目录没有chmod权限?
please help me , and sorry to my english 请帮助我,对不起我的英语
Let's try to change your FTP server. 让我们尝试更改您的FTP服务器。 It's could be problem in server if you log into your FTP.
如果您登录FTP,则可能是服务器中的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.