SDCard version
Fork of gr-peach-opencv-project-sd-card by
cProcess/mStorage.cpp@167:2ee3e82cb6f5, 2017-07-21 (annotated)
- Committer:
- thedo
- Date:
- Fri Jul 21 01:26:54 2017 +0000
- Revision:
- 167:2ee3e82cb6f5
- Parent:
- 166:240bc5a0f42a
gr-peach-opencv-project-sd-card
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
thedo | 166:240bc5a0f42a | 1 | #include "mStorage.hpp" |
thedo | 166:240bc5a0f42a | 2 | |
thedo | 166:240bc5a0f42a | 3 | cStorage::cStorage(char *name) |
thedo | 166:240bc5a0f42a | 4 | { |
thedo | 166:240bc5a0f42a | 5 | fs = new FATFileSystem(name); |
thedo | 166:240bc5a0f42a | 6 | mounted = false; |
thedo | 166:240bc5a0f42a | 7 | } |
thedo | 166:240bc5a0f42a | 8 | |
thedo | 166:240bc5a0f42a | 9 | cStorage::~cStorage(void) |
thedo | 166:240bc5a0f42a | 10 | { |
thedo | 166:240bc5a0f42a | 11 | if( mounted == true) |
thedo | 166:240bc5a0f42a | 12 | { |
thedo | 166:240bc5a0f42a | 13 | fs->unmount(); |
thedo | 166:240bc5a0f42a | 14 | delete fs; |
thedo | 166:240bc5a0f42a | 15 | } |
thedo | 166:240bc5a0f42a | 16 | } |
thedo | 166:240bc5a0f42a | 17 | |
thedo | 166:240bc5a0f42a | 18 | mStorageError cStorage::isConnectSdCard() |
thedo | 166:240bc5a0f42a | 19 | { |
thedo | 166:240bc5a0f42a | 20 | if (sd.connect()) |
thedo | 166:240bc5a0f42a | 21 | { |
thedo | 166:240bc5a0f42a | 22 | return STORG_PASS; |
thedo | 166:240bc5a0f42a | 23 | } |
thedo | 166:240bc5a0f42a | 24 | return STORG_FAIL; |
thedo | 166:240bc5a0f42a | 25 | } |
thedo | 166:240bc5a0f42a | 26 | |
thedo | 166:240bc5a0f42a | 27 | mStorageError cStorage::mountSdCard() |
thedo | 166:240bc5a0f42a | 28 | { |
thedo | 166:240bc5a0f42a | 29 | if(fs == NULL) |
thedo | 166:240bc5a0f42a | 30 | { |
thedo | 166:240bc5a0f42a | 31 | return STORG_FAIL; |
thedo | 166:240bc5a0f42a | 32 | } |
thedo | 166:240bc5a0f42a | 33 | else if( fs->mount(&sd) == 0 ) |
thedo | 166:240bc5a0f42a | 34 | { |
thedo | 166:240bc5a0f42a | 35 | mounted = true; |
thedo | 166:240bc5a0f42a | 36 | return STORG_PASS; |
thedo | 166:240bc5a0f42a | 37 | } |
thedo | 166:240bc5a0f42a | 38 | return STORG_FAIL; |
thedo | 166:240bc5a0f42a | 39 | } |
thedo | 166:240bc5a0f42a | 40 | |
thedo | 166:240bc5a0f42a | 41 | mStorageError cStorage::unmountSdCard() |
thedo | 166:240bc5a0f42a | 42 | { |
thedo | 166:240bc5a0f42a | 43 | if( mounted == true ) |
thedo | 166:240bc5a0f42a | 44 | { |
thedo | 166:240bc5a0f42a | 45 | fs->mount(&sd); |
thedo | 166:240bc5a0f42a | 46 | return STORG_PASS; |
thedo | 166:240bc5a0f42a | 47 | } |
thedo | 166:240bc5a0f42a | 48 | return STORG_FAIL; |
thedo | 166:240bc5a0f42a | 49 | } |