Manage SD files remotely from PC.

Hello,

I have the Mega2560 and ethernet shield Wiznet W5100 with SD.

I need manager the files remotely from PC with WindowsXP.
I need to store files for my arduino played.

I thought a library search: FTP server to Arduino.
autentication, tcp/ip, simple, fast and secure.
But, I Not find "Arduino FTP Server"

It is very large and complicated make the FTP Server program for Arduino?

Then I want to know another way to save files remotely from the PC.

I think arduino file server.

In the latter case I want to know how to do it via USB cable.

I appreciate any related information.

riphet:
But, I Not find "Arduino FTP Server"

Google says that somebody here is working on an Arduino 'Tiny FTP Server' which seems like the sort of thing you're after. There's no firmware there but hints that it is / will be published in a separate article. As long as your network adapter is capable of supporting two simultaneous TCP connections I don't see any reason why you couldn't write your own FTP server - the protocol isn't especially complex.

I try to do something, but not advanced for port 21.

I've checked and can not find the source of the problem.

My arduino ethernet shield does NOT respond with port 21.

server.available() not working, not responding (specifically with port 21).

This blocked port 21? Port 21 is restricted? I not have idea.
this case: How I can unlock and use this port?

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

// User configurable variables
byte mac[] = { 
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte useDhcp = true;
IPAddress deviceIp (192, 168,   1, 177); // Only if useDhcp is false
IPAddress gatewayIp(192, 168,   1, 254); // Only if useDhcp is false
IPAddress dnsIp    (192, 168,   1, 254); // Only if useDhcp is false
IPAddress subnet   (255, 255, 255,   0); // Only if useDhcp is false

unsigned int serverPort = 21;

EthernetServer server(serverPort); // Declare server object


void setup()
{
  Serial.begin(9600);

  // disable w5100 SPI while setting up SD
  pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);

  if(SD.begin(4) == 0)    // set up SD
    Serial.println("SD failed");
  else
    Serial.println("SD ok");

  // Start network
  if(useDhcp)
    { Ethernet.begin(mac); }
  else
    { Ethernet.begin(mac, deviceIp, dnsIp, gatewayIp, subnet); }

  digitalWrite(10,HIGH);    // disable w5100 SPI
  delay(1000);    // takes a second for the w5100 to get ready

  server.begin();

  Serial.print("server is at ");
  Serial.println(Ethernet.localIP());
  Serial.println(Ethernet.subnetMask());
  Serial.println(Ethernet.gatewayIP());
  Serial.println(Ethernet.dnsServerIP());

  Serial.println("Setup done");    // rest of your setup

}


void loop()
{
  
  if (server.available())
    Serial.print("AVAL");

  // if an incoming client connects, there will be bytes available to read:
  EthernetClient client = server.available();
  
  if (client == true) {
    Serial.println("1 client !!!");
    // read bytes from the incoming client and write them back
    // to any clients connected to the server:
    // server.write(client.read());
    Serial.println(client.read());
  }
  else
  { Serial.print("z"); }

  delay(800);
  
}

Is your client in the same network as the Arduino? Check for a firewall on your PC, and on your Ethernet router.

I appreciate your reply.

Yes, my client uses the same DHCP server.
I have no firewall on my PC.
My router with setup free to all, no restrictions.

When I test with port 80, it works fine.
I did try port 23, and also function well.
When I try to port 21,-not work-

But now in this moment, everything gets worse.

The above code NOT loaded to mega2560.
Many examples sketchs of load properly.

loading seems to be in a cycle, and not end:

avrdude: Recv: H [48]
avrdude: Recv: u [75]
avrdude: Recv: h [68]
avrdude: Recv: ? [3f]
avrdude: Recv: . [0d]
avrdude: Recv: . [0a]
avrdude: Recv: B [42]
avrdude: Recv: o [6f]
avrdude: Recv: o [6f]
avrdude: Recv: t [74]
avrdude: Recv: l [6c]
avrdude: Recv: o [6f]
avrdude: Recv: a [61]
avrdude: Recv: d [64]
avrdude: Recv: e [65]
avrdude: Recv: r [72]
avrdude: Recv: > [3e]
Avrdude: Recv: > [3e]

Again, again.

I do not understand is that other sketchs load fine and work, and this one don't.

Do you have some demon my arduino? I want to kick him out! XD

FTP requires two connections. One command and one data. I don't have a FTP server yet, but I do have a FTP client example in the playground.
http://playground.arduino.cc/Code/FTP

edit: Don't use this. It causes an upload fail on many versions of the Mega2560 bootloader.

    Serial.println("1 client !!!");

Remove one of the exclamation marks like this:

    Serial.println("1 client !!");

Thank you.
I appreciate your time and attention.

I followed your advice on the exclamation mark.
so soon I will have patience with the bootloader.

The biggest of my problems is that I can not take the first step.
Detecting the client.

My Arduino this deaf with port 21,
but listen perfectly on port 80.

server.available() not detecting with port 21

It will be another demon that I have to kick? XD XD

What software are you using to test the connection? Don't use a web browser. IE and Chrome will not open a connection to port 21. I use PuTTY.
I use port 21 and RAW. Set "close window on exit" to never so you can see the response.

several, client software.

IE and Chrome with 192.168.1.95:21
the simple C:\WINDOWS\system32\ftp.exe
and the FileZilla, now the psftp.exe.

of course the client software, NOT receive a response,
The sketch server response, yet.

But the client status is "connected",
this for a short time (exactly 60 seconds)
then "connection closed by remote host".

... and during that time,
function server.available() with absolutely omission of the connection of the client.

This occurs here, with my PC, Arduino, LAN, etc.,

I wonder if the function server.available(), responds appropriately in other circumstances using port 21.

I think that is part of bootloader,
I also think that: bootloader controls the ping responses.
On this, also would like to know how to control the ping responses.
To enable and disable ping replies,
But maybe this should be another forum thread.

I think that is part of bootloader,
I also think that: bootloader controls the ping responses.

No. I tested this with my equipment and code. Mega 2560 with an ethernet shield. It worked great with PuTTY. Failed miserably with IE and Chrome.

Don't mix protocols. The server response for a FTP connection is different than a HTTP connection.

Do you have PuTTY installed on your computer?

When you mentioned PuTTy, I try with psftp.exe and not good.

The small chance of something, for me is great !!!

So, I attended your valuable information.
I went download exactly the putty.exe
http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

My first attempt and then GOOL !!!
client detected !!!

Now, yet:
I have no idea what is the difference between ftp.exe and PuTTy.
The fact is that work differently,
and client PuTTY is detected by function server.available()

With this, I can now continue.

I appreciate your time and attention.

I have no idea what is the difference between ftp.exe and PuTTy.
The fact is that work differently,
and client PuTTY is detected by function server.available()

That is what I was saying. HTTP and FTP are different responses from the server. You can't put a HTTP server on a FTP port, then use a FTP program. You must use a RAW TCP type connection.

so,
if Ethernet.h and EthernetServer.h libraries are http-raw
my powelfull ftp server need "raw special client".
this is not what I want. I like work with standart ftp client.

Then I need other library to develop the FTP server.
Is this correct?

It is clear that I have no business idea,
but I want to do everything possible.

I appreciate any related information.

+++
I think this is Gordian Knot,
I suspect that begins in IPAddress.h,
UDP and RAW
... perhaps, a small modification ...
I do not know

the standard Arduino Ethernet library does not include something...
then use other one library ?
Now my question is: Which is best?

SurferTim:
That is what I was saying. HTTP and FTP are different responses from the server. You can't put a HTTP server on a FTP port, then use a FTP program. You must use a RAW TCP type connection.

I'm puzzled about what is going on here. It's clear this is on the right lines because changing the client has changed the behaviour, but according the the evidence given it shouldn't have made any difference - the problem described was that the server did not see any incoming connect request. Unless/until the TCP connection has been established it is irrelevant what application protocol is carried over it. The only explanation I can think of is that the description of the symptoms was inaccurate and in fact we were successfully establishing the TCP connection and then failing at some later step in the process.

It's clear this is on the right lines because changing the client has changed the behaviour, but according the the evidence given it shouldn't have made any difference - the problem described was that the server did not see any incoming connect request.

It did not receive a connection request because IE and Chrome do not allow any type of port 21 connection. Chrome displays the message "unsafe port" and does not attempt to establish a connection. Try it!

edit: You would have the same problem with a SMTP server. The client does not send a request. The server sends a "hello" first. Then the SMTP client responds to that hello. In this case, you do not show a connection until the client sends something. But the client will not send anything until the server sends a "hello". But you are not sending a "hello". Deadlock.

If you want to test this, fire up PuTTY and connect to the Arduino with port 21 and RAW mode. When it connects, don't enter anything. Check the Arduino. No connection. Now type "GET / HTTP/1.0" and press the enter key only once. Now you will get a "connection" message on the arduino, but it will not send a response until you press the enter key again.

SurferTim:
IE and Chrome do not allow any type of port 21 connection. Chrome displays the message "unsafe port" and does not attempt to establish a connection. Try it!

I've not noticed that behaviour before - but then, I don't tend to use a browser as a generic TCP client, because it isn't one. It seems happy enough using the FTP protocol on that port. However, it'd be far better to use a proper FTP client for testing (or even roll your own using telnet) so that you have full control over what happens. The good news is that none of this affects the server side code and is easily surmountable by using the right client.

Take a look at this code:
http://playground.arduino.cc/Code/FTP
The first thing it does after the connection is established is wait for the FTP server to send a "hello". I would guess that the connection is not showing as established because that particular code is not sending the hello. The web browser may actually establish the connection to the ethernet shield, but when it does not receive a "hello" from the Arduino, then you get the unsafe port message. I have not checked the network packets.

edit: That is why I posted this warning in reply #9:

Don't mix protocols. The server response for a FTP connection is different than a HTTP connection.

I thought that the symptoms were that the Arduino wasn't seeing the incoming TCP connection at all, but I could be wrong. I wholeheartedly agree with your warning about using the wrong client for the protocol you're using.

I used PuTTY to test this stuff. It works just like I am telling you. The w5100 does not indicate "connected" on a socket until it has something in the rx buffer. You can connect, and the shield shows nothing. Send that one GET line to put something in the rx buffer, and suddenly you are connected.

If that is not the way it turns out for you, I would like to know that.

I'm coming to the conclusion that:
cannot be harvested pears from elm.

The Ethernet.h, EthenetServer.h EthernetClient.h, etc.
all source designed for UDP and RAW.

the standard Arduino Ethernet library does not include the TCP, all is UDP.

Am newbie and I have no idea how to include TCP.
I appreciate any related information.