Руслан Урядинский / libuavcan

Dependents:   UAVCAN UAVCAN_Subscriber

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers test_system_utils.cpp Source File

test_system_utils.cpp

00001 /*
00002  * Copyright (C) 2015 Pavel Kirienko <pavel.kirienko@gmail.com>
00003  */
00004 
00005 #include <uavcan_linux/uavcan_linux.hpp>
00006 #include <iostream>
00007 #include <iomanip>
00008 #include "debug.hpp"
00009 
00010 int main(int argc, const char** argv)
00011 {
00012     try
00013     {
00014         const std::vector<std::string> iface_names(argv + 1, argv + argc);
00015 
00016         const auto res = uavcan_linux::MachineIDReader(iface_names).readAndGetLocation();
00017 
00018         const auto original_flags = std::cout.flags();
00019 
00020         for (auto x : res.first)
00021         {
00022             std::cout << std::hex << std::setw(2) << std::setfill('0') << int(x);
00023         }
00024 
00025         std::cout.width(0);
00026         std::cout.flags(original_flags);
00027 
00028         std::cout << std::endl;
00029 
00030         std::cout << res.second << std::endl;
00031 
00032         return 0;
00033     }
00034     catch (const std::exception& ex)
00035     {
00036         std::cerr << "Exception: " << ex.what() << std::endl;
00037         return 1;
00038     }
00039 }