cleanflight_read_test.cpp
Go to the documentation of this file.
00001 #include <string>
00002 #include <iostream>
00003 
00004 #include <MSP.hpp>
00005 #include <msp_msg.hpp>
00006 #include <msg_print.hpp>
00007 
00008 int main(int argc, char *argv[]) {
00009     const std::string device = (argc>1) ? std::string(argv[1]) : "/dev/ttyUSB0";
00010     const uint baudrate = (argc>2) ? std::stoul(argv[2]) : 115200;
00011 
00012     msp::MSP msp(device, baudrate);
00013 
00014     // wait for established connection
00015     {
00016     msp::msg::Ident ident;
00017     msp.request_wait(ident, 100);
00018     }
00019 
00020     std::cout << "MSP ready..." << std::endl;
00021 
00022     msp::msg::ApiVersion api_version;
00023     if(msp.request_block(api_version))
00024         std::cout << api_version << std::endl;
00025     else
00026         std::cerr << "Could not determine Cleanflight API version." << std::endl;
00027 
00028     msp::msg::FcVariant fc_variant;
00029     if(msp.request_block(fc_variant))
00030         std::cout << fc_variant << std::endl;
00031 
00032     msp::msg::FcVersion fc_version;
00033     if(msp.request_block(fc_version))
00034         std::cout << fc_version << std::endl;
00035 
00036     msp::msg::BoardInfo board_info;
00037     if(msp.request_block(board_info))
00038         std::cout << board_info << std::endl;
00039 
00040     msp::msg::BuildInfo build_info;
00041     if(msp.request_block(build_info))
00042         std::cout << build_info << std::endl;
00043 
00044     msp::msg::RxConfig rx_config;
00045     msp.request_block(rx_config);
00046 
00047     msp::msg::Feature feature;
00048     if(msp.request_block(feature))
00049         std::cout<<feature<<std::endl;
00050 
00051     msp::msg::RxMap rx_map;
00052     if(msp.request_block(rx_map))
00053         std::cout<<rx_map<<std::endl;
00054 
00055     return 0;
00056 }


msp
Author(s): Christian Rauch
autogenerated on Mon Oct 9 2017 03:02:13