-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscancanbus.cpp
47 lines (35 loc) · 1.08 KB
/
scancanbus.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
// License: Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported (CC BY-NC-ND 3.0)
#include "uvr_can.hpp"
void knoten_in_json(int aktiveknoten[]) {
std::cout << "{\"knoten\": [";
int erste_iteration = 1;
for(int i = 0; i < 64; i++) {
if(aktiveknoten[i] == 1611) {
if(erste_iteration) {
erste_iteration = 0;
} else {
std::cout << ",";
}
std::cout << "{\"typ\": \"uvr1611\", \"can_id\": " << i << "}";
}
}
std::cout << "]}" << std::endl;
}
int main(int argc, char **argv)
{
int aktiveknoten[array_size] = {0};
if (argc != 2)
{
std::cerr << "usage: %s can-interface\n" << argv[0] << std::endl;
return -1;
}
std::string can_if(argv[1]);
Uvr_Can uvr;
uvr.getSocket_c(can_if);
uvr.scanBus(aktiveknoten);
//boost::thread canHeartBeatThread(canHeartBeatFunc, sock, self_node_id);
uvr.selektiereUVRs_c(aktiveknoten);
knoten_in_json(aktiveknoten);
//canHeartBeatThread.join();
return 0;
}