-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
54 lines (44 loc) · 1.28 KB
/
test.cpp
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
#include <iostream>
#include <stdlib.h>
#include <string>
#ifdef _WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
#include "board_shim.h"
#include "data_filter.h"
using namespace std;
// https://brainflow.readthedocs.io/en/stable/Examples.html#id4
int main(int argc, char *argv[]) {
BoardShim::enable_dev_board_logger();
struct BrainFlowInputParams params;
int res = 0;
int board_id = (int)BoardIds::SYNTHETIC_BOARD;
// use synthetic board for demo
BoardShim *board = new BoardShim(board_id, params);
try {
board->prepare_session();
board->start_stream();
#ifdef _WIN32
Sleep(5000);
#else
sleep(5);
#endif
board->stop_stream();
BrainFlowArray<double, 2> data = board->get_current_board_data(10);
board->release_session();
std::cout << "Original data:" << std::endl << data << std::endl;
DataFilter::write_file(data, "test.csv", "w");
BrainFlowArray<double, 2> restored_data = DataFilter::read_file("test.csv");
std::cout << "Restored data:" << std::endl << restored_data << std::endl;
} catch (const BrainFlowException &err) {
BoardShim::log_message((int)LogLevels::LEVEL_ERROR, err.what());
res = err.exit_code;
if (board->is_prepared()) {
board->release_session();
}
}
delete board;
return res;
}