-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
71 lines (65 loc) · 2.03 KB
/
main.cpp
File metadata and controls
71 lines (65 loc) · 2.03 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <stdio.h>
#include <string.h>
#include <mbed.h>
#include "BufferedSerial.h"
#include "Data.h"
#include "Storage.h"
Data data;
DigitalOut debugLED(LED1);
static BufferedSerial port(USBTX,USBRX,115200);
FileHandle *mbed::mbed_override_console(int fd) { return &port; }
void setupUSBSerial()
{
port.set_format(8);
}
int main(){
char aux[1]= {0x0};
int size, modoRead, pathLido, tempo = 0;
char nro[15];
setupUSBSerial();
debugPrint("Start program\n");
// Storage st;
// st.initStorage<FlashDevice>();
// st.createFile(&st.flash);
// st.openNewFile(&st.flash);
// st.openFile(&st.flash);
// st.writeFile(data, st.flash.file);
// st.closeFile(&st.flash);
// st.showDirectory(&st.flash);
// char file[] = "/fl/log001.bin";
// st.readFile(&st.flash,file);
if(port.readable()){
port.read(aux,sizeof(aux));
}
Timer t;
t.start();
while(1){
tempo = duration_cast<std::chrono::milliseconds>(t.elapsed_time()).count();
debugPrint("%d\n", tempo);
if(port.readable() && tempo <= 15000){
if(port.read(aux,sizeof(aux)), aux[0] == 0x52)
modoRead = 1;
if(modoRead == 1 && port.read(aux,sizeof(aux)), aux[0] >= 0x30 && aux[0] <= 0x39){
pathLido = 1;
nro[0] = aux[0];
}
if(modoRead == 1 && pathLido == 1 && port.read(aux,sizeof(aux)), aux[0] >= 0x30 && aux[0] <= 0x39){
pathLido = 2;
nro[1] = aux[0];
}
if(modoRead == 1 && pathLido == 2 && port.read(aux,sizeof(aux)), aux[0] >= 0x30 && aux[0] <= 0x39){
pathLido = 3;
nro[2] = aux[0];
}
if(modoRead == 1 && pathLido == 3){
char path[15] = "/fl/log";
debugPrint("%s\n", strcat(strcat(path, nro), ".bin"));
// st.readFile(&st.flash,strcat(strcat(path, nro), ".bin"));
}
}
}
return 0;
}