Emulation of LocalFileSystem with virtual COM.

Dependencies:   USBDevice

Dependents:   KL46Z-lpc81isp lpcterm2

#include "USBLocalFileSystem.h"

int main() {
    USBLocalFileSystem* usb_local = new USBLocalFileSystem(); // RamDisk(64KB)

    while(1) {
        usb_local->lock(true);
        usb_local->remount();
        char filename[32];
        if (usb_local->find(filename, sizeof(filename), "*.TXT")) {
            FILE* fp = fopen(filename, "r");
            if (fp) {
                int c;
                while((c = fgetc(fp)) != EOF) {
                    usb_local->putc(c);
                }
                fclose(fp);
            }
        }    
        usb_local->lock(false);

        wait_ms(1000*5);
    }
}



Sample application:

Import programKL46Z-lpc81isp

ISP example program.

Import programlpcterm2

semihost server example program

Branch:
branch
Revision:
2:97c314eae8b8
Parent:
0:39eb4d5b97df
--- a/src/RamDisk.cpp	Sun May 04 00:23:05 2014 +0000
+++ b/src/RamDisk.cpp	Tue May 06 15:42:30 2014 +0900
@@ -13,18 +13,20 @@
 
 /* virtual */ uint32_t RamDisk::storage_sectors()
 {
+    report_sectors_count++;
     return _sectors;
 }
 
 /* virtual */ uint32_t RamDisk::storage_size()
 {
+    report_size_count++;
     return _sectors * 512;
 }
 
 /* virtual */ int RamDisk::storage_read(uint8_t * data, uint32_t block)
 {
     RAMDISK_DBG("R block=%d", block);
-    update();
+    report_read_count++;
     memset(data, 0x00, 512);
     if (_sector_image.count(block) > 0) {
         uint8_t* buf = _sector_image[block];
@@ -47,7 +49,7 @@
 
 /* virtual */ int RamDisk::storage_write(const uint8_t * data, uint32_t block)
 {
-    update();
+    report_write_count++;
     int size = block_size(data);
     if (_sector_image.count(block) > 0) {
         uint8_t* buf = _sector_image[block];