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 
00044     std::cout << "firmware version: " << cf.getFirmwareVersion() << std::endl;
00045     std::cout << "protocol version: " << cf.getProtocolVersion() << std::endl;
00046     std::cout << "device type name: " << cf.getDeviceTypeName() << std::endl;
00047 
00048     // cf.requestParamToc();
00049 
00050     // uint32_t revision0 = 0;
00051     // uint16_t revision1 = 0;
00052     // uint32_t revchanged0 = 0;
00053     // uint16_t revchanged1 = 0;
00054     // uint8_t modified = 1;
00055 
00056     // const Crazyflie::ParamTocEntry* entry = cf.getParamTocEntry("firmware", "revision0");
00057     // if (entry) {
00058     //   revision0 = cf.getParam<uint32_t>(entry->id);
00059     // }
00060 
00061     // entry = cf.getParamTocEntry("firmware", "revision1");
00062     // if (entry) {
00063     //   revision1 = cf.getParam<uint16_t>(entry->id);
00064     // }
00065 
00066     // entry = cf.getParamTocEntry("firmware", "modified");
00067     // if (entry) {
00068     //   modified = cf.getParam<uint8_t>(entry->id);
00069     // }
00070 
00071     // entry = cf.getParamTocEntry("firmware", "revchanged0");
00072     // if (entry) {
00073     //   revchanged0 = cf.getParam<uint32_t>(entry->id);
00074     // }
00075 
00076     // entry = cf.getParamTocEntry("firmware", "revchanged1");
00077     // if (entry) {
00078     //   revchanged1 = cf.getParam<uint16_t>(entry->id);
00079     // }
00080 
00081     // uint64_t revision = ((uint64_t)revision0 << 16) | revision1;
00082     // uint64_t revChanged = ((uint64_t)revchanged0 << 16) | revchanged1;
00083 
00084     // std::cout << std::hex << revision << "," << (bool)modified << "," << revChanged << std::endl;
00085 
00086     return 0;
00087   }
00088   catch(std::exception& e)
00089   {
00090     std::cerr << e.what() << std::endl;
00091     return 1;
00092   }
00093 }


crazyflie_tools
Author(s): Wolfgang Hoenig
autogenerated on Wed Jun 12 2019 19:20:48