|
2507
|
Using Arduino / Networking, Protocols, and Devices / Re: Official Ethernet Shield crashes
|
on: February 26, 2012, 10:59:04 am
|
fortunately i've done the cisco ccna course around networks bases Good. Then it should not be difficult for you to assign a static ip to the Arduino. You should know all about ips, subnets, gateways, and dns. Once you assign a static ip to the shield, can you ping the Arduino ip from a localnet computer?
|
|
|
|
|
2510
|
Using Arduino / Networking, Protocols, and Devices / Re: Uploading file from SD card to remote server?
|
on: February 26, 2012, 09:12:00 am
|
Update: I have the full package working now. Upload files from the FTP server to the SD card, or download files from the SD card to the FTP server. Right now, I have a define that allows me to compile either upload or download to save program memory. The code with debugging compiles to 25856 bytes. A little steep for an Uno, but for my Mega2560, not a problem. If you are interested, let me know. I have a little error checking to do to insure all works ok. If anyone shows interest, I will post the code then. If you are not interested, at least I'll have it when I need it. 
|
|
|
|
|
2511
|
Using Arduino / Networking, Protocols, and Devices / Re: Connecting Ethernet shield to ICSP header vs Digital pins
|
on: February 25, 2012, 12:37:41 pm
|
Hum, OK. Is there a reason that the ICSP header pins aren't conencted to the I/O header pins though (that is pins 11, 12, and 13 on the ATMega would conenct to both the 11, 12, 13 I/O pins and the ICSP header)?
I'm not sure what you mean, but the SPI data pins are on each device's digital pins and the ICSP. The Uno SPI data pins are on the ICSP pins, and digital pins 11-13. The Mega data pins are on the ICSP pins, and digital pins 50-52. (not connected to the ethernet shield) The reason most ethernet shields do not connect the SPI to data pins 11-13 is to allow the Mega to use those pins as digital I/O. I did not vote either way, but I prefer a Mega, so if I had to vote... 
|
|
|
|
|
2516
|
Using Arduino / Networking, Protocols, and Devices / Re: Uploading file from SD card to remote server?
|
on: February 24, 2012, 04:21:33 pm
|
If you want to try what I have so far, this connects in passive mode to both the command and data ports. Change network settings and user/password down in the sendFTP function. Press the 'f' key and enter. It just connects and disconnects to insure it can. See if it works on your ftp server. // w5100 FTP passive client // IDE v1.0 only
#include <SPI.h> #include <Ethernet.h>
// Set to your network settings byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x59, 0x67 }; IPAddress ip( 192, 168, 0, 2 ); IPAddress gateway( 192, 168, 0, 1 ); IPAddress subnet( 255, 255, 255, 0 );
// Change this to the ip of the ftp server IPAddress server( 192, 168, 0, 3 );
EthernetClient client; EthernetClient dclient;
char outBuf[128]; char outCount;
void setup() { Serial.begin(9600); pinMode(4,OUTPUT); digitalWrite(4,HIGH); Ethernet.begin(mac, ip, gateway, gateway, subnet); delay(2000); Serial.println("Ready. Press f"); }
void loop() { byte inChar;
inChar = Serial.read();
if(inChar == 'f') { if(sendFTP()) Serial.println("FTP OK"); else Serial.println("FTP failed"); } }
byte sendFTP() { if (client.connect(server,21)) { Serial.println("Command connected"); } else { Serial.println("Connamd connection failed"); return 0; }
if(!eRcv()) return 0;
// Change to your user and password client.write("USER myusername\r\n");
if(!eRcv()) return 0;
client.write("PASS mypassword\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 rtnVal[32]; sscanf(outBuf,"%*s %*s %*s %*s %s",rtnVal);
unsigned int hiPort,loPort;
sscanf(rtnVal,"%*c%*d%*c%*d%*c%*d%*c%*d%*c%d%*c%d",&hiPort,&loPort); Serial.print("Port "); hiPort = hiPort << 8; loPort = loPort & 255; hiPort = hiPort | loPort; Serial.println(hiPort);
if (dclient.connect(server,hiPort)) { Serial.println("Data connected"); } else { Serial.println("Data connection failed"); client.stop(); return 0; }
client.write("QUIT\r\n");
if(!eRcv()) return 0;
dclient.stop(); client.stop(); Serial.println("disconnected"); 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 < 127) { outBuf[outCount] = thisByte; outCount++; outBuf[outCount] = 0; } }
if(respCode >= '4') { efail(); return 0; }
return 1; }
void efail() { byte thisByte = 0;
client.write("QUIT\r\n");
while(!client.available()) delay(1);
while(client.available()) { thisByte = client.read(); Serial.write(thisByte); }
client.stop(); dclient.stop(); Serial.println("disconnected"); }
|
|
|
|
|
2517
|
Using Arduino / Networking, Protocols, and Devices / Re: Uploading file from SD card to remote server?
|
on: February 24, 2012, 12:54:26 pm
|
But, you think it is OK to have the Arduino/accelerometer/SD card/boxer out there? Nobody said anything about high impact!  But why not? If the thing survives, ok with me. I've already got my ethernet shield connected to my FTP server. I'll let you know how it goes. edit: I just logged in with a username and password. So far, it works pretty clean, but the difficult part is to come. Will I be able to keep the command connection to port 21 open when I open a data connection to port 20?
|
|
|
|
|
2518
|
Using Arduino / Networking, Protocols, and Devices / Re: Uploading file from SD card to remote server?
|
on: February 24, 2012, 11:33:04 am
|
Wouldn't it be simpler to remove the SD card from the Arduino, put it in the PC, and then deal with the data there? Not always. If I want to retrieve data from my rooftop unit, and the area is being pummeled by lightning, going to the roof of a 22 story building would not be a healthy thing to do. I can see where FTP would be really helpful. I have not gotten that far along where I need that much data yet, but I can see it coming. Doesn't look that bad to me. Don't let the thought that "nobody has done it before" is a reason for you not to do it. I took the time to write email sending code. I will post a link to that. It uses a two-way communication like you will need for the FTP protocol. It sends a command, then listens for, and serial.prints, the response. http://arduino.cc/forum/index.php/topic,69647.15.htmlHere is the formats for the commands and responses for FTP. http://www.w3.org/Protocols/rfc959/8_PortNumber.htmlI like the idea! 
|
|
|
|
|