11 const std::string& name)
19 node->setName(name.c_str());
21 node->getLogger().setLevel(uavcan::protocol::debug::LogLevel::DEBUG);
26 std::cout <<
"Starting the node..." << std::endl;
27 const int start_res =
node->start();
28 std::cout <<
"Start returned: " << start_res << std::endl;
31 std::cout <<
"Node started successfully" << std::endl;
36 node->setModeOperational();
37 node->logInfo(
"init",
"Hello world! I'm [%*], NID %*",
38 node->getNodeStatusProvider().getName().c_str(),
int(
node->getNodeID().get()));
49 std::cout << msg << std::endl;
51 auto log_sub =
node->makeSubscriber<uavcan::protocol::debug::LogMessage>(log_handler);
62 std::cout <<
"Remote node NID " <<
int(event.node_id.get()) <<
" changed status: "
63 <<
event.old_status.toString() <<
" --> "
64 <<
event.status.toString() << std::endl;
68 NodeStatusMonitor nsm(*
node);
76 node->logInfo(
"timer",
"Another minute passed...");
90 node->logError(
"spin",
"Error %*", res);
95 int main(
int argc,
const char** argv)
101 std::cerr <<
"Usage:\n\t" << argv[0] <<
" <node-id> <can-iface-name-1> [can-iface-name-N...]" << std::endl;
104 const int self_node_id = std::stoi(argv[1]);
105 std::vector<std::string> iface_names;
106 for (
int i = 2; i < argc; i++)
108 iface_names.emplace_back(argv[i]);
111 std::cout <<
"Node initialized successfully" << std::endl;
115 catch (
const std::exception& ex)
117 std::cerr <<
"Exception: " << ex.what() << std::endl;