test_system_utils.cpp 892 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (C) 2015 Pavel Kirienko <pavel.kirienko@gmail.com>
  3. */
  4. #include <uavcan_linux/uavcan_linux.hpp>
  5. #include <iostream>
  6. #include <iomanip>
  7. #include "debug.hpp"
  8. int main(int argc, const char** argv)
  9. {
  10. try
  11. {
  12. const std::vector<std::string> iface_names(argv + 1, argv + argc);
  13. const auto res = uavcan_linux::MachineIDReader(iface_names).readAndGetLocation();
  14. const auto original_flags = std::cout.flags();
  15. for (auto x : res.first)
  16. {
  17. std::cout << std::hex << std::setw(2) << std::setfill('0') << int(x);
  18. }
  19. std::cout.width(0);
  20. std::cout.flags(original_flags);
  21. std::cout << std::endl;
  22. std::cout << res.second << std::endl;
  23. return 0;
  24. }
  25. catch (const std::exception& ex)
  26. {
  27. std::cerr << "Exception: " << ex.what() << std::endl;
  28. return 1;
  29. }
  30. }