listMemories.cpp
Go to the documentation of this file.
1 #include <iostream>
2 
3 #include <boost/program_options.hpp>
4 #include <crazyflie_cpp/Crazyflie.h>
5 
6 int main(int argc, char **argv)
7 {
8 
9  std::string uri;
10  std::string defaultUri("radio://0/80/2M/E7E7E7E7E7");
11 
12  namespace po = boost::program_options;
13 
14  po::options_description desc("Allowed options");
15  desc.add_options()
16  ("help", "produce help message")
17  ("uri", po::value<std::string>(&uri)->default_value(defaultUri), "unique ressource identifier")
18  ;
19 
20  try
21  {
22  po::variables_map vm;
23  po::store(po::parse_command_line(argc, argv, desc), vm);
24  po::notify(vm);
25 
26  if (vm.count("help")) {
27  std::cout << desc << "\n";
28  return 0;
29  }
30  }
31  catch(po::error& e)
32  {
33  std::cerr << e.what() << std::endl << std::endl;
34  std::cerr << desc << std::endl;
35  return 1;
36  }
37 
38  try
39  {
40  Crazyflie cf(uri);
41  cf.requestMemoryToc();
42 
43  std::for_each(cf.memoriesBegin(), cf.memoriesEnd(),
44  [](const Crazyflie::MemoryTocEntry& entry)
45  {
46  std::cout << (int)entry.id << ": " << std::endl;
47  std::cout << " type: ";
48  switch (entry.type) {
50  std::cout << "EEPROM";
51  break;
53  std::cout << "1-Wire";
54  break;
56  std::cout << "LED12";
57  break;
59  std::cout << "LOCO";
60  break;
61  default:
62  std::cout << "Unknown type!";
63  break;
64  }
65  std::cout << std::endl;
66  std::cout << " size: " << entry.size << std::endl;
67  std::cout << " addr: " << entry.addr << std::endl;
68  }
69  );
70 
71  return 0;
72  }
73  catch(std::exception& e)
74  {
75  std::cerr << e.what() << std::endl;
76  return 1;
77  }
78 }
std::vector< MemoryTocEntry >::const_iterator memoriesBegin() const
uint8_t error
void requestMemoryToc()
Definition: Crazyflie.cpp:857
std::vector< MemoryTocEntry >::const_iterator memoriesEnd() const
int main(int argc, char **argv)
Definition: listMemories.cpp:6


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