以太网屏蔽arduino上的FTP客户端

以太网屏蔽arduino上的FTP客户端,ftp,arduino,server,client,Ftp,Arduino,Server,Client,我想做一个项目,其中数据保存在SD卡上,然后使用以太网屏蔽,使用ftp客户端arduino将这些数据发送到ftp服务器。服务器我有一个免费的主机 以下是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:

我想做一个项目,其中数据保存在SD卡上,然后使用以太网屏蔽,使用ftp客户端arduino将这些数据发送到ftp服务器。服务器我有一个免费的主机

以下是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. 状态:cba.pl的解析地址 状态:连接到95.211.144.68 警告:输入的地址未解析为IPv6地址。 状态:已连接,正在等待欢迎消息。。。 回复:220------欢迎来到Pure FTPd[privsep][TLS]---------- 回复:220您是允许的200个用户中的57个。 答复:220当地时间现在是16:30。服务器端口:21。 回复:220这是一个私人系统-没有匿名登录 答复:此服务器上也欢迎220-IPv6连接。 回复:220您将在不活动5分钟后断开连接。 命令:CLNThttps://ftptest.net 代表2a02:a311:c020:3200:c10d:18e1:36a5:8e2 回复:530您没有登录 命令:AUTH TLS 回复:234认证TLS正常。 状态:正在执行TLS握手。。。 状态:TLS握手成功,正在验证证书。。。 状态:从服务器收到2个证书。 状态:cert[0]:subject='CN=www.cba.pl'issuer='C=US,O=Let\27s Encrypt,CN=Let\27s Encrypt Authority X3' 状态:cert[1]:subject='C=US,O=Let\27s Encrypt,CN=Let\27s Encrypt Authority X3'发卡机构='O=Digital Signature Trust Co.,CN=DST Root CA X3' 命令:用户wsalkowski 回复:331用户wsalkowski OK。需要密码 命令:通过******** 答复:230您的带宽使用受到限制 答复:230-OK。当前受限目录为/ 答复:230允许的最大文件大小为10485760字节 命令:SYST 答复:215 UNIX类型:L8 指挥:专长 答复:支持211个扩展: 答复:EPRT 答复:闲置 答复:MDTM 答复:尺寸 答复:MFMT 回复:REST-STREAM 答复:MLST型*;大小*;尺寸*;修改*;UNIX.mode*;UNIX.uid*;UNIX.gid*;独特*; 答复:MLSD 答复:AUTH TLS 答复:PBSZ 答复:PROT 答复:UTF8 答复:TVFS 答复:ESTA 答复:PASV 答复:EPSV 答复:SPSV 答复:ESTP 答复:完。 命令:PBSZ 0 答复:200PBSZ=0 命令:protp 答复:200数据保护级别设置为“专用” 命令:PWD 回复:257“/”是您的当前位置 状态:当前路径为/ 命令:I型 回复:200类型现在是8位二进制 命令:PASV 回复:227进入被动模式(95211144,68218,36) 命令:MLSD 状态:数据连接已建立,正在执行TLS握手。。。 回复:150接受数据连接 状态:TLS握手成功,正在验证证书。。。 状态:从服务器收到2个证书。 状态:cert[0]:subject='CN=www.cba.pl'issuer='C=US,O=Let\27s Encrypt,CN=Let\27s Encrypt Authority X3' 状态:cert[1]:subject='C=US,O=Let\27s Encrypt,CN=Let\27s Encrypt Authority X3'发卡机构='O=Digital Signature Trust Co.,CN=DST Root CA X3' 状态:传输连接的TLS会话已恢复。 清单:type=cdir;sizd=4096;修改=20160501192730;UNIX.mode=0755;UNIX.uid=0;UNIX.gid=0;唯一=803g16f353ca。 清单:type=pdir;sizd=4096;修改=20160501192730;UNIX.mode=0755;UNIX.uid=0;UNIX.gid=0;唯一=803g16f353ca。。 清单:type=dir;sizd=4096;修改=2016103112522;UNIX.mode=0700;UNIX.uid=1098695;UNIX.gid=33;唯一=803g2259f68;wsalkowski.cba.pl 答复:226个选项:-a-l 答复:共2263场 状态:成功 结果 您的服务器正在工作,并且按照此测试的执行,已为TLS上的显式FTP正确配置了各种路由器/防火墙。但是,有关于兼容性问题的警告,并非所有用户都能使用您的服务器。 为了达到最大兼容性,请考虑解决这些警告。 这里是串行监视器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 准备好的按f或r kkksdsSD开放 命令连接 220------欢迎来到纯FTPd[privsep][TLS]---------- 220您是允许的200个用户中的52个。 当地时间现在是15:32。服务器端口:21。 220这是一个私有系统-无匿名登录 此服务器上也欢迎220-IPv6连接。 220不活动5分钟后,您将断开连接。 331用户wsalkowski正常。需要密码 230您的带宽使用受到限制 230-好的。当前受限目录为/ 230允许的最大文件大小为10485760字节 215 UNIX类型:L8 227进入被动模式(95211144,65208115) 数据端口:53363 数据连接 553无法打开该文件:没有这样的文件或目录 再见。您上载了0并下载了0 KB。 221注销。 命令断开 SD关闭 FTP失败 SD开放 命令连接 220------欢迎来到纯FTPd[privsep][TLS]---------- 220您是允许的200个用户中的53个。 当地时间现在是15:32。服务器端口:21。 220这是一个私有系统-无匿名登录 此服务器上也欢迎220-IPv6连接。 220不活动5分钟后,您将断开连接。 331用户wsalkowski正常。需要密码 230您的带宽使用受到限制 230-好的。当前受限目录为/ 230允许的最大文件大小为10485760字节 215 UNIX类型:L8 227进入被动模式(95211144,65208248) 数据端口:53496 数据连接 553无法打开该文件:没有这样的文件或目录 再见。您上载了0并下载了0 KB。 221注销。 命令断开 SD关闭 FTP失败 这里是代码arduino(我从中获得的代码)

/* 用于IDE v1.0.1和w5100/w5200的FTP被动客户端 由SurferTim于2012年10月发布 由SurferTim于2015年6月6日修改 */ #包括 #包括 #包括 //注释掉要从FTP服务器写入SD的下一行 #定义FTPWRIT /* 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(); }