-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcmd_reset.cpp
38 lines (27 loc) · 1.04 KB
/
cmd_reset.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
#include <hoytech/protected_queue.h>
#include "ephemerand/ublox.h"
#include "ephemerand/util.h"
namespace ephemerand {
void cmd_reset(std::string device, bool verbose) {
ephemerand::Ublox ub(device);
ub.connect();
ub.run();
while(1) {
auto msg = ub.output_queue.pop();
if (auto m = std::get_if<UbloxMessage_Version>(&msg)) {
if (verbose) std::cout << "# Connection OK. SW: " << m->software_version << " HW: " << m->hardware_version << std::endl;
ub.reset();
} else if (auto m = std::get_if<UbloxMessage_Ack>(&msg)) {
if (m->message_class == MSG_CLASS_CFG && m->message_id == MSG_ID_CFG_RST) {
if (verbose) std::cout << "# Device has been reset." << std::endl;
std::exit(0);
}
std::cerr << "Unexpected ack: " << m->message_class << " / " << m->message_id << std::endl;
std::exit(1);
} else {
std::cerr << "Unrecognized message type" << std::endl;
std::exit(1);
}
}
}
}