Emulation of LocalFileSystem with virtual COM.
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
USBLocalFileSystem.cpp
- Committer:
- va009039
- Date:
- 2014-05-06
- Branch:
- branch
- Revision:
- 2:97c314eae8b8
- Parent:
- 1:00c9eb8af5c2
- Child:
- 4:8f6857784854
File content as of revision 2:97c314eae8b8:
#include "USBLocalFileSystem.h" #include "RamDisk.h" #include "SDStorage.h" USBLocalFileSystem::USBLocalFileSystem(const char* name) { RamDisk* storage = new RamDisk; init(storage, name); } USBLocalFileSystem::USBLocalFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name) { SDStorage* storage = new SDStorage(mosi, miso, sclk, cs); storage->storage_initialize(); init(storage, name); } USBLocalFileSystem::USBLocalFileSystem(StorageInterface* storage, const char* name) { init(storage, name); } void USBLocalFileSystem::init(StorageInterface* storage, const char* name) { _name = name; _storage = storage; _usb = new USBStorage2(_storage); _local = new LocalStorage(_storage); } void USBLocalFileSystem::remount() { if (_local) { delete _local; } _local = new LocalStorage(_storage); } int USBLocalFileSystem::readable() { return _usb->readable(); } int USBLocalFileSystem::writeable() { return _usb->writeable(); } int USBLocalFileSystem::getc() { return _usb->getc(); } void USBLocalFileSystem::putc(int c) { _usb->putc(c); }