00001 #include <FlightController.hpp> 00002 00003 #include <iostream> 00004 00005 struct MyIdent : public msp::Request { 00006 msp::ID id() const { return msp::ID::MSP_IDENT; } 00007 00008 msp::ByteVector raw_data; 00009 00010 void decode(const msp::ByteVector &data) { 00011 raw_data = data; 00012 } 00013 00014 }; 00015 00016 struct Callbacks { 00017 void onIdent(const MyIdent &ident) { 00018 std::cout << "Raw Ident data: "; 00019 for(auto d : ident.raw_data) { 00020 std::cout << int(d) << ","; 00021 } 00022 std::cout << std::endl; 00023 } 00024 }; 00025 00026 int main(int argc, char *argv[]) { 00027 const std::string device = (argc>1) ? std::string(argv[1]) : "/dev/ttyUSB0"; 00028 const uint baudrate = (argc>2) ? std::stoul(argv[2]) : 115200; 00029 00030 Callbacks cbs; 00031 fcu::FlightController fcu(device, baudrate); 00032 fcu.initialise(); 00033 00034 // subscribe with costum type 00035 fcu.subscribe(&Callbacks::onIdent, &cbs, 1); 00036 00037 // Ctrl+C to quit 00038 std::cin.get(); 00039 }