diff options
-rw-r--r-- | libraries/Bridge/FileIO.cpp | 22 | ||||
-rw-r--r-- | libraries/Bridge/FileIO.h | 12 | ||||
-rw-r--r-- | libraries/Bridge/examples/Datalogger/Datalogger.ino | 18 |
3 files changed, 18 insertions, 34 deletions
diff --git a/libraries/Bridge/FileIO.cpp b/libraries/Bridge/FileIO.cpp index c49c2b4..0fab55f 100644 --- a/libraries/Bridge/FileIO.cpp +++ b/libraries/Bridge/FileIO.cpp @@ -159,21 +159,15 @@ const char *File::name() { -boolean SDClass::begin() { - Process chksd; - int res = chksd.runShellCommand(F("cat /sys/bus/scsi/drivers/sd/*/block/sda/size")); - if (res == 0) { - if (chksd.peek() != '0') - return true; - } - return false; +boolean FileSystemClass::begin() { + return true; } -File SDClass::open(const char *filename, uint8_t mode) { +File FileSystemClass::open(const char *filename, uint8_t mode) { return File(filename, mode); } -boolean SDClass::exists(const char *filepath) { +boolean FileSystemClass::exists(const char *filepath) { Process ls; ls.begin("ls"); ls.addParameter(filepath); @@ -181,7 +175,7 @@ boolean SDClass::exists(const char *filepath) { return (res == 0); } -boolean SDClass::mkdir(const char *filepath) { +boolean FileSystemClass::mkdir(const char *filepath) { Process mk; mk.begin("mkdir"); mk.addParameter("-p"); @@ -190,7 +184,7 @@ boolean SDClass::mkdir(const char *filepath) { return (res == 0); } -boolean SDClass::remove(const char *filepath) { +boolean FileSystemClass::remove(const char *filepath) { Process rm; rm.begin("rm"); rm.addParameter(filepath); @@ -198,7 +192,7 @@ boolean SDClass::remove(const char *filepath) { return (res == 0); } -boolean SDClass::rmdir(const char *filepath) { +boolean FileSystemClass::rmdir(const char *filepath) { Process rm; rm.begin("rmdir"); rm.addParameter(filepath); @@ -206,4 +200,4 @@ boolean SDClass::rmdir(const char *filepath) { return (res == 0); } -SDClass SD; +FileSystemClass FileSystem; diff --git a/libraries/Bridge/FileIO.h b/libraries/Bridge/FileIO.h index 4485215..629e5f2 100644 --- a/libraries/Bridge/FileIO.h +++ b/libraries/Bridge/FileIO.h @@ -46,7 +46,7 @@ public: operator bool(); const char * name(); - boolean isDirectory(void); + boolean iFileSystemirectory(void); File openNextFile(uint8_t mode = FILE_READ); void rewindDirectory(void); @@ -66,13 +66,11 @@ private: uint8_t handle; }; -class SDClass { +class FileSystemClass { public: - SDClass() : bridge(Bridge) { } - SDClass(BridgeClass &_b) : bridge(_b) { } + FileSystemClass() : bridge(Bridge) { } + FileSystemClass(BridgeClass &_b) : bridge(_b) { } - // This needs to be called to set up the connection to the SD card - // before other methods are used. boolean begin(); // Open the specified file/directory with the supplied mode (e.g. read or @@ -98,6 +96,6 @@ private: BridgeClass &bridge; }; -extern SDClass SD; +extern FileSystemClass FileSystem; #endif diff --git a/libraries/Bridge/examples/Datalogger/Datalogger.ino b/libraries/Bridge/examples/Datalogger/Datalogger.ino index 5412631..dfd269f 100644 --- a/libraries/Bridge/examples/Datalogger/Datalogger.ino +++ b/libraries/Bridge/examples/Datalogger/Datalogger.ino @@ -8,8 +8,8 @@ * analog sensors on analog ins 0, 1, and 2 * SD card attached to SD card slot of the Arduino Yun - You are allowed to remove the SD card while the Linux and the - sketch is running but becareful to don't remove it while + You can remove the SD card while the Linux and the + sketch are running but becareful to don't remove it while the system is writing on it. created 24 Nov 2010 @@ -29,19 +29,11 @@ void setup() { // Initialize the Bridge and the Console Bridge.begin(); Console.begin(); + FileSystem.begin(); while(!Console){ ; // wait for Console port to connect. } - - // see if the card is present and can be initialized: - if (!SD.begin()) { - Console.println("SD card failed, or not present"); - // don't do anything more: - return; - } - Console.println("SD card initialized."); - } @@ -62,8 +54,8 @@ void loop () { // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. - // The SD card is mounted at the following "/mnt/sda1" - File dataFile = SD.open("/mnt/sda1/datalog.txt", FILE_APPEND); + // The FileSystem card is mounted at the following "/mnt/FileSystema1" + File dataFile = FileSystem.open("/mnt/sda1/datalog.txt", FILE_APPEND); // if the file is available, write to it: if (dataFile) { |