7 #include <unordered_map>
30 std::printf(
"\033[%um",
static_cast<unsigned>(color_));
51 static const std::unordered_map<std::uint8_t, std::pair<CLIColor, std::string>> map
60 return map.at(health);
62 catch (std::out_of_range&)
70 static const std::unordered_map<std::uint8_t, std::pair<CLIColor, std::string>> map
82 catch (std::out_of_range&)
93 const int nid_int = nid.
get();
95 const unsigned vendor_code =
status_registry_[nid_int].vendor_specific_status_code;
97 std::printf(
" %-3d |", nid_int);
99 CLIColorizer clz(mode_and_color.first);
100 std::printf(
" %-15s ", mode_and_color.second.c_str());
104 CLIColorizer clz(health_and_color.first);
105 std::printf(
" %-8s ", health_and_color.second.c_str());
107 std::printf(
"| %-10lu | %04x %s'%s %u\n", uptime, vendor_code,
108 std::bitset<8>((vendor_code >> 8) & 0xFF).to_string().c_str(),
109 std::bitset<8>(vendor_code).to_string().c_str(),
115 std::printf(
"\x1b[1J");
116 std::printf(
"\x1b[H");
117 std::printf(
" NID | Mode | Health | Uptime [s] | Vendor-specific status code\n");
118 std::printf(
"-----+-----------------+----------+------------+-hex---bin----------------dec--\n");
141 uavcan::protocol::SoftwareVersion(), uavcan::protocol::HardwareVersion());
142 node->setModeOperational();
155 node->logError(
"spin",
"Error %*", res);
160 int main(
int argc,
const char** argv)
166 std::cerr <<
"Usage:\n\t" << argv[0] <<
" <can-iface-name-1> [can-iface-name-N...]" << std::endl;
169 std::vector<std::string> iface_names;
170 for (
int i = 1; i < argc; i++)
172 iface_names.emplace_back(argv[i]);
178 catch (
const std::exception& ex)
180 std::cerr <<
"Error: " << ex.what() << std::endl;