Forum Software Ferduino code SD Files

SD Files  [SOLVED]


Post Number:#1 Post Thu Oct 02, 2014 10:14 pm
Posts: 60
Topics: 3
Images: 0
Solve rating: 1
Joined: Sun Jun 15, 2014 11:50 pm
Topics: 3
Age: 56
Gender: None specified
National Flag:
United States of America
Is there a way to access the files on the micro SD card on the Ethernet card with out having to take the stack apart ??

Post Number:#2 Post Fri Oct 03, 2014 10:43 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

Use this code:

#include <SdFat.h>

const int chipSelect = 5;     // For Ferduino Mega 2560
//const int chipSelect = 4;   // For ethernet shield

Sd2Card card;
SdFile file;
SdFile root;
SdVolume volume;

char *arquivo[11] = {"LOGTDIA.TXT", "LOGPDIA.TXT", "LOGODIA.TXT", "LOGDDIA.TXT", "LOGRDIA.TXT", "HDP1.TXT", "HDP2.TXT", "HDP3.TXT", "HDP4.TXT", "HDP5.TXT", "HDP6.TXT"};

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

  card.init(SPI_QUARTER_SPEED, chipSelect);
  volume.init(&card);
  root.openRoot(&volume);

  while(!Serial)
  {
    ; // wait for serial.
  }
  for(int i = 0; i < 11; i++)
  {
    if(file.open(&root, arquivo[i], O_READ))
    {
      Serial.print("Reading ");
      Serial.print(arquivo[i]);
      Serial.println(" ...");
      Serial.println("*******************************");
      delay(2000);
      while ((data = file.read()) >= 0)
       {
         Serial.write(data);
        }
      file.close();
      Serial.println("Finished!");
      Serial.println("******************************");
      Serial.println();
    }
    else
    {
      Serial.print("Can't open ");
      Serial.print(arquivo[i]);
      Serial.println(" !");
      Serial.println("******************************");
      Serial.println();
      delay(2000);
    }
  }
}

void loop()
{
}


Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#3 Post Sat Oct 04, 2014 12:16 am
Posts: 60
Topics: 3
Images: 0
Solve rating: 1
Joined: Sun Jun 15, 2014 11:50 pm
Topics: 3
Age: 56
Gender: None specified
National Flag:
United States of America
is there a way to use that sketch with out clearing the eeprom that is running the Ferduino sketch on it now?? I am not even sure if I am logging all the different things I am suppose to will have to look in to it more over this weekend

Post Number:#4 Post Sat Oct 04, 2014 11:30 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

Hi!

What's the a reason to clear the EEPROM after use a code that no changes any value saved?

You can see some "#include <EEPROM.h>" or "EEPROM.write()" on code?

Best regards.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#5 Post Sun Oct 05, 2014 12:04 am
Posts: 60
Topics: 3
Images: 0
Solve rating: 1
Joined: Sun Jun 15, 2014 11:50 pm
Topics: 3
Age: 56
Gender: None specified
National Flag:
United States of America
no I do not see any "#include <EEPROM.h>" or "EEPROM.write()" just don't understand how to use this code with out deleting what I have on the arduino now then uploading that new code use it then EEPROM.clear then reupload the Ferduino code if there is a better way then please teach me so other users will read it and be able to benefit.

Post Number:#6 Post Sun Oct 05, 2014 10:09 am
Posts: 1699
Topics: 38
Images: 301
Solve rating: 233
Joined: Mon Mar 03, 2014 5:59 pm
Topics: 38
Age: 39
Location: São Paulo
Gender: Male
National Flag:
Brazil

The answer is simple.

You NEVER need clear the EEPROM after use any code that no changes the values saved.
Post your doubts on forum because it can help another user too. Just PM me for support if it's absolutely necessary.

Post Number:#7 Post Mon Oct 06, 2014 12:28 am
Posts: 60
Topics: 3
Images: 0
Solve rating: 1
Joined: Sun Jun 15, 2014 11:50 pm
Topics: 3
Age: 56
Gender: None specified
National Flag:
United States of America
worked out very well for me all the files are there just the last 6 could not be open
Thank you for teaching me this




Return to Ferduino code





Who is online

Users viewing this topic: No registered users and 1 guest

cron