Need Advice on howto send large amont of data PC <-> ethernet shield

Hello guys,

I am using an Arduino Duemilanov with ethernet shield.

Objective of this project is to send some data from the PC via the Ethernet shield and then store the data on the SD card, and then (after being not connected to the net) get and proses the stored data.

I could use some advice here..... I have playing with UDP to send data and to store it on the SD card

The problem I am facing:

  1. UDP(W5100) and the SdFat is giving some problems ex. arduino crashes even thou i do :
      digitalWrite(10, LOW); // turn off the W5100 chip!
      digitalWrite(4, HIGH); // turn on the SD chipselect!
      sdCard(data); 
      digitalWrite(10, HIGH); // turn on the W5100 chip!
      digitalWrite(4, LOW); // turn off the SD chipselect!

even by doing so it crashes...after executing sdCard(data);
The sdCard(data) function does exactly the same as the example given on the SdFat lib (fgets).

Running the example separately (with out the Ethernet lib) then it works perfectly

  1. The UDP itself is a-bit-messy, it sometimes sends garbage out from the PC (probably noise on my wireless connection )

What i Need is:

  1. Do anyone have an alternative way to communicate with the ardoino from a PC (sending heavy data ~ 1024 bytes so the http with /get is out of the picture) ?

  2. anyone have a code exp. that successfully get and store data from the SD and to an array while using the ethernet lib. ?

all comments are welcome

thanks in advance

/cheers

You should turn off the sd card before turning on the ethernet. Now you switch on the ethernet too early , might give a conflict...

robtillaart:
You should turn off the sd card before turning on the ethernet. Now you switch on the ethernet too early , might give a conflict...

yea true...but again this should not be the cause... why the function sdCard() crashes as I turn on the ethernet and off the SD after the sd function all.

have done the following as u suggested:

digitalWrite(10, LOW);
      delay(10);
      digitalWrite(4, HIGH); 
      delay(10);
      sdCard(&p_params);
      digitalWrite(4, LOW); 
      delay(10);
      digitalWrite(10, HIGH);
      delay(10);

but still as soon as it comes to line where i call: SdFile rdfile("test.txt", O_READ); it freezes

here is the sdCard function code:

void sdCard( receivedPacket * p_params[] )
{
  char line[250];
  int n,i=0;

  Serial.println( "in copyFromSdcard " );
  if (!sd.init(SPI_FULL_SPEED, chipSelect)) sd.initErrorHalt();  // have also tried with HALF_SPEED....same story

  Serial.println( "1" );

  SdFile rdfile("test.txt", O_READ);   // at this point it halds.. have 2x cheecked if the file test.txt is on the SD ..and it is

  Serial.println( "2" );

  // check for open error
  if (!rdfile.isOpen()) error("demoFgets");

  Serial.println( "3" );

  cout << endl << pstr(
    "Lines with '>' end with a '\\n' character\n"
    "Lines with '#' do not end with a '\\n' character\n"
    "\n");
    
  // read lines from the file
  while ((n = rdfile.fgets(line, sizeof(line))) > 0) {
    if(i<10)p_params[i]->packetBuffer = strdup(line); 
    i++;
  }

   for(int j =0; j<10; j++)
  {
    Serial.print( "Data " );
    Serial.print( j );
    Serial.print( ": " );
    Serial.println( p_params [j]->packetBuffer ); 
  }

}

The Ethernet shield page says that you shall have to send a HIGH to pin 10 disable the W5100, and a LOW to enable it.

Try this code:

      digitalWrite(10, HIGH); // turn off the W5100 chip!
      digitalWrite(4, LOW); // turn on the SD chipselect!
      sdCard(data); 
      digitalWrite(4, HIGH); // turn off the SD chipselect!
      digitalWrite(10, LOW); // turn on the W5100 chip!

Cheers,

phil.