-
-
Notifications
You must be signed in to change notification settings - Fork 24
/
sd_recovery_files.ino
58 lines (49 loc) · 1020 Bytes
/
sd_recovery_files.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <SD.h>
File root;
void setup()
{
Serial.begin(115200);
pinMode(10, OUTPUT);
SD.begin(10);
root = SD.open("/");
readDirectory(root, "");
Serial.println("done!");
}
void loop()
{
// nothing happens after setup finishes.
}
void readDirectory(File dir, String folder) {
boolean files = true;
while(files) {
File entry = dir.openNextFile();
if (! entry) {
files = false;
} else {
if (entry.isDirectory()) {
String folder_new = folder;
folder_new += entry.name();
folder_new += "/";
readDirectory(entry, folder_new);
} else {
outputFile(entry, folder);
}
}
}
}
void outputFile(File entry, String folder) {
Serial.print("--- ");
Serial.print(folder);
Serial.print(entry.name());
Serial.print(";");
Serial.println(entry.size(), DEC);
byte r;
while (entry.available()) {
r = entry.read();
if (r < 0x10) {
Serial.print("0");
}
Serial.print(r, HEX);
}
Serial.println();
}