3 #include <boost/program_options.hpp> 4 #include <crazyflie_cpp/Crazyradio.h> 5 #include <crazyflie_cpp/CrazyflieUSB.h> 8 int main(
int argc,
char **argv)
11 std::string addressStr;
12 std::string defaultAddressStr(
"0xE7E7E7E7E7");
15 namespace po = boost::program_options;
17 po::options_description desc(
"Allowed options");
19 (
"help",
"produce help message")
20 (
"address", po::value<std::string>(&addressStr)->default_value(defaultAddressStr),
"device address")
21 (
"verbose,v",
"verbose output")
27 po::store(po::parse_command_line(argc, argv, desc), vm);
30 if (vm.count(
"help")) {
31 std::cout << desc <<
"\n";
34 verbose = vm.count(
"verbose");
38 std::cerr << e.what() << std::endl << std::endl;
39 std::cerr << desc << std::endl;
46 if (numCrazyradios > 0) {
48 std::stringstream sstr;
49 sstr << std::hex << addressStr;
54 std::cout <<
"Found Crazyradio with version " << radio.
version() << std::endl;
57 size_t numCFsFound = 0;
58 for (uint8_t datarate = 0; datarate < 3; ++datarate) {
63 uint8_t test[] = {0xFF};
68 std::cout <<
"radio://0/" << (uint32_t)
channel <<
"/";
81 if (defaultAddressStr != addressStr) {
82 std::stringstream sstr;
83 sstr << std::hex << std::uppercase <<
address;
84 std::cout <<
"/" << sstr.str();
86 std::cout << std::endl;
93 std::cout <<
"No Crazyflie found. Did you specify the correct address?" << std::endl;
96 std::cout <<
"No Crazyradio found." << std::endl;
100 if (numCFoverUSB > 0) {
103 std::cout <<
"Found Crazyflie connected via USB cable with version " << cfusb.
version() << std::endl;
106 for (uint32_t i = 0; i < numCFoverUSB; ++i) {
107 std::cout <<
"usb://" << i << std::endl;
110 }
else if (verbose) {
111 std::cout <<
"No Crazyflie connected via USB cable found." << std::endl;
115 catch(std::exception& e)
117 std::cerr << e.what() << std::endl;
virtual void sendPacket(const uint8_t *data, uint32_t length, ITransport::Ack &result)
void setAddress(uint64_t address)
int main(int argc, char **argv)
void setDatarate(Datarate datarate)
static uint32_t numDevices()
static uint32_t numDevices()
void setChannel(uint8_t channel)