-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain_no_runner.cpp
92 lines (71 loc) · 2.54 KB
/
main_no_runner.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//C standard libraries
#include <iostream>
#include <cstdlib>
#include <string>
#include <csignal>
//JSON handling
#include "JSONHandler.hpp"
#include "SystemConfigReader.hpp"
#include "RadarConfigReader.hpp"
#include "CLIController.hpp"
#include "DCA1000Handler.hpp"
#include "SerialStreamer.hpp"
using json = nlohmann::json;
CLIController* cli_global = nullptr;
DCA1000Handler* dca_global = nullptr;
void signalHandler(int signum){
std::cout << "Interrupt signal (" << signum << ") received.\n";
if (cli_global && cli_global->initialized) {
cli_global->sendStopCommand();
}
if (dca_global && dca_global->initialized) {
dca_global->send_recordStop();
}
}
int main(int, char**){
//handle sigint commands
signal(SIGINT,signalHandler);
std::string config_file = "../configs/radar_0_IWR1843_demo.json";
SystemConfigReader config_reader(config_file);
if(! config_reader.initialized){
return 0;
}
std::cout << "Radar Config Path: " << config_reader.getRadarConfigPath() << std::endl;
std::cout << "CLI Port: " << config_reader.getRadarCliPort() << std::endl;
std::cout << "SDK Major Version: " << config_reader.getSDKMajorVersion() << std::endl;
const std::string radar_config_path = config_reader.getRadarConfigPath();
RadarConfigReader radar_config_reader(radar_config_path);
//setup the DCA1000
// DCA1000Handler dca1000_handler(config_reader,radar_config_reader);
// dca_global = &dca1000_handler;
// // //initialize the DCA1000
// if(dca1000_handler.initialized == false){
// return false;
// } else{
// std::cout << "DCA1000 Successfully initialized" <<std::endl;
// }
SerialStreamer serial_streamer(config_reader);
// //send a configuration to the radar board
CLIController cli_controller(config_reader);
if(cli_controller.initialized){
cli_controller.send_config_to_IWR();
}
// //send record start command
// dca1000_handler.send_recordStart();
//send sensor start command
cli_controller.sendStartCommand();
//process the first frame
serial_streamer.process_next_message();
//define a buffer
for (size_t i = 0; i < 20; i++)
{
// dca1000_handler.process_next_packet();
if(!serial_streamer.process_next_message()){
// break;
}
}
std::cout << "sending IWR stop command" << std::endl;
cli_controller.sendStopCommand();
// std::cout << "sending DCA1000 stop command" << std::endl;
// dca1000_handler.send_recordStop();
}