version.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include <chrono>
00003 #include <thread>
00004 
00005 #include <boost/program_options.hpp>
00006 #include <crazyflie_cpp/Crazyflie.h>
00007 
00008 int main(int argc, char **argv)
00009 {
00010 
00011   std::string uri;
00012   std::string defaultUri("radio://0/80/2M/E7E7E7E7E7");
00013 
00014   namespace po = boost::program_options;
00015 
00016   po::options_description desc("Allowed options");
00017   desc.add_options()
00018     ("help", "produce help message")
00019     ("uri", po::value<std::string>(&uri)->default_value(defaultUri), "unique ressource identifier")
00020   ;
00021 
00022   try
00023   {
00024     po::variables_map vm;
00025     po::store(po::parse_command_line(argc, argv, desc), vm);
00026     po::notify(vm);
00027 
00028     if (vm.count("help")) {
00029       std::cout << desc << "\n";
00030       return 0;
00031     }
00032   }
00033   catch(po::error& e)
00034   {
00035     std::cerr << e.what() << std::endl << std::endl;
00036     std::cerr << desc << std::endl;
00037     return 1;
00038   }
00039 
00040   try
00041   {
00042     Crazyflie cf(uri);
00043     cf.requestParamToc();
00044 
00045     uint32_t revision0 = 0;
00046     uint16_t revision1 = 0;
00047     uint32_t revchanged0 = 0;
00048     uint16_t revchanged1 = 0;
00049     uint8_t modified = 1;
00050 
00051     const Crazyflie::ParamTocEntry* entry = cf.getParamTocEntry("firmware", "revision0");
00052     if (entry) {
00053       revision0 = cf.getParam<uint32_t>(entry->id);
00054     }
00055 
00056     entry = cf.getParamTocEntry("firmware", "revision1");
00057     if (entry) {
00058       revision1 = cf.getParam<uint16_t>(entry->id);
00059     }
00060 
00061     entry = cf.getParamTocEntry("firmware", "modified");
00062     if (entry) {
00063       modified = cf.getParam<uint8_t>(entry->id);
00064     }
00065 
00066     entry = cf.getParamTocEntry("firmware", "revchanged0");
00067     if (entry) {
00068       revchanged0 = cf.getParam<uint32_t>(entry->id);
00069     }
00070 
00071     entry = cf.getParamTocEntry("firmware", "revchanged1");
00072     if (entry) {
00073       revchanged1 = cf.getParam<uint16_t>(entry->id);
00074     }
00075 
00076     uint64_t revision = ((uint64_t)revision0 << 16) | revision1;
00077     uint64_t revChanged = ((uint64_t)revchanged0 << 16) | revchanged1;
00078 
00079     std::cout << std::hex << revision << "," << (bool)modified << "," << revChanged << std::endl;
00080 
00081     return 0;
00082   }
00083   catch(std::exception& e)
00084   {
00085     std::cerr << e.what() << std::endl;
00086     return 1;
00087   }
00088 }


crazyflie_tools
Author(s): Wolfgang Hoenig
autogenerated on Sun Oct 8 2017 02:48:04