test seeking in a file on mDot

Dependencies:   libmDot mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
mfiore
Date:
Wed Aug 24 14:29:47 2016 +0000
Child:
1:4d3a502a7e58
Commit message:
initial commit - keep appending to a single file to test maximum file size in the filesystem

Changed in this revision

libmDot.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmDot.lib	Wed Aug 24 14:29:47 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/MultiTech/code/libmDot/#b50f92f1c6ff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Aug 24 14:29:47 2016 +0000
@@ -0,0 +1,75 @@
+#include "mbed.h"
+#include "mDot.h"
+#include "MTSLog.h"
+#include <vector>
+
+int main()
+{
+    mDot* dot;
+    std::vector<mDot::mdot_file> files;
+    mDot::mdot_file file;
+    const char filename[] = "test_file.txt";
+
+    // get a mDot handle
+    dot = mDot::getInstance();
+
+    // print library version information
+    logInfo("version: %s", dot->getId().c_str());
+
+    files = dot->listUserFiles();
+    if (files.size() == 0) {
+        logInfo("no user files");
+    } else {
+        logInfo("user files:");
+        for (std::vector<mDot::mdot_file>::iterator it = files.begin(); it != files.end(); it++) {
+            printf("\t%s [%d]\r\n", it->name, it->size);
+        }
+    }
+    
+    logInfo("deleting user files");
+    for (std::vector<mDot::mdot_file>::iterator it = files.begin(); it != files.end(); it++) {
+        dot->deleteUserFile(it->name);
+    }
+
+    while (true) {
+        uint8_t buf[2048];
+
+        memset(buf, 0x3B, sizeof(buf));
+
+        file = dot->openUserFile(filename, mDot::FM_RDWR | mDot::FM_CREAT | mDot::FM_APPEND);
+        if (file.fd < 0) {
+            logError("failed to open file");
+            break;
+        } else {
+            if (dot->writeUserFile(file, (void*)buf, sizeof(buf)) != sizeof(buf)) {
+                logError("didn't write entire buffer");
+                break;
+            }
+
+            dot->closeUserFile(file);
+        }
+
+
+        files = dot->listUserFiles();
+        if (files.size() == 0) {
+            logInfo("no user files");
+        } else {
+            logInfo("user files:");
+            for (std::vector<mDot::mdot_file>::iterator it = files.begin(); it != files.end(); it++) {
+                printf("\t%s [%d]\r\n", it->name, it->size);
+            }
+        }
+    }
+
+    files = dot->listUserFiles();
+    if (files.size() == 0) {
+        logInfo("no user files");
+    } else {
+        logInfo("user files:");
+        for (std::vector<mDot::mdot_file>::iterator it = files.begin(); it != files.end(); it++) {
+            printf("\t%s [%d]\r\n", it->name, it->size);
+        }
+    }
+
+    return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Wed Aug 24 14:29:47 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#4c105b8d7cae
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Aug 24 14:29:47 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34
\ No newline at end of file