version.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include <chrono>
3 #include <thread>
4 
5 #include <boost/program_options.hpp>
6 #include <crazyflie_cpp/Crazyflie.h>
7 
8 int main(int argc, char **argv)
9 {
10 
11  std::string uri;
12  std::string defaultUri("radio://0/80/2M/E7E7E7E7E7");
13 
14  namespace po = boost::program_options;
15 
16  po::options_description desc("Allowed options");
17  desc.add_options()
18  ("help", "produce help message")
19  ("uri", po::value<std::string>(&uri)->default_value(defaultUri), "unique ressource identifier")
20  ;
21 
22  try
23  {
24  po::variables_map vm;
25  po::store(po::parse_command_line(argc, argv, desc), vm);
26  po::notify(vm);
27 
28  if (vm.count("help")) {
29  std::cout << desc << "\n";
30  return 0;
31  }
32  }
33  catch(po::error& e)
34  {
35  std::cerr << e.what() << std::endl << std::endl;
36  std::cerr << desc << std::endl;
37  return 1;
38  }
39 
40  try
41  {
42  Crazyflie cf(uri);
43 
44  std::cout << "firmware version: " << cf.getFirmwareVersion() << std::endl;
45  std::cout << "protocol version: " << cf.getProtocolVersion() << std::endl;
46  std::cout << "device type name: " << cf.getDeviceTypeName() << std::endl;
47 
48  // cf.requestParamToc();
49 
50  // uint32_t revision0 = 0;
51  // uint16_t revision1 = 0;
52  // uint32_t revchanged0 = 0;
53  // uint16_t revchanged1 = 0;
54  // uint8_t modified = 1;
55 
56  // const Crazyflie::ParamTocEntry* entry = cf.getParamTocEntry("firmware", "revision0");
57  // if (entry) {
58  // revision0 = cf.getParam<uint32_t>(entry->id);
59  // }
60 
61  // entry = cf.getParamTocEntry("firmware", "revision1");
62  // if (entry) {
63  // revision1 = cf.getParam<uint16_t>(entry->id);
64  // }
65 
66  // entry = cf.getParamTocEntry("firmware", "modified");
67  // if (entry) {
68  // modified = cf.getParam<uint8_t>(entry->id);
69  // }
70 
71  // entry = cf.getParamTocEntry("firmware", "revchanged0");
72  // if (entry) {
73  // revchanged0 = cf.getParam<uint32_t>(entry->id);
74  // }
75 
76  // entry = cf.getParamTocEntry("firmware", "revchanged1");
77  // if (entry) {
78  // revchanged1 = cf.getParam<uint16_t>(entry->id);
79  // }
80 
81  // uint64_t revision = ((uint64_t)revision0 << 16) | revision1;
82  // uint64_t revChanged = ((uint64_t)revchanged0 << 16) | revchanged1;
83 
84  // std::cout << std::hex << revision << "," << (bool)modified << "," << revChanged << std::endl;
85 
86  return 0;
87  }
88  catch(std::exception& e)
89  {
90  std::cerr << e.what() << std::endl;
91  return 1;
92  }
93 }
uint8_t error
std::string getDeviceTypeName()
Definition: Crazyflie.cpp:152
int main(int argc, char **argv)
Definition: version.cpp:8
int getProtocolVersion()
Definition: Crazyflie.cpp:134
std::string getFirmwareVersion()
Definition: Crazyflie.cpp:143


crazyflie_tools
Author(s): Wolfgang Hoenig
autogenerated on Mon Sep 28 2020 03:40:15