| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 | /* * Read the logfile created by the eventlog.ino example. * Demo of pathnames and working directories */#include <SPI.h>#include "SdFat.h"#include "sdios.h"// SD chip select pinconst uint8_t chipSelect = SS;// file system objectSdFat sd;// define a serial output streamArduinoOutStream cout(Serial);//------------------------------------------------------------------------------void setup() {  int c;  Serial.begin(9600);  // Wait for USB Serial  while (!Serial) {    yield();  }  // Initialize at the highest speed supported by the board that is  // not over 50 MHz. Try a lower speed if SPI errors occur.  if (!sd.begin(chipSelect, SD_SCK_MHZ(50))) {    sd.initErrorHalt();  }  // set current working directory  if (!sd.chdir("logs/2014/Jan/")) {    sd.errorHalt("chdir failed. Did you run eventlog.ino?");  }  // open file in current working directory  ifstream file("logfile.txt");  if (!file.is_open()) {    sd.errorHalt("open failed");  }  // copy the file to Serial  while ((c = file.get()) >= 0) {    cout << (char)c;  }  cout << "Done" << endl;}//------------------------------------------------------------------------------void loop() {}
 |