16 const std::string& name)
23 node->setName(name.c_str());
24 node->getLogger().setLevel(uavcan::protocol::debug::LogLevel::DEBUG);
29 uavcan::protocol::HardwareVersion hwver;
30 std::copy(app_id.begin(), app_id.end(), hwver.unique_id.begin());
31 std::cout << hwver << std::endl;
33 node->setHardwareVersion(hwver);
39 const int start_res =
node->start();
47 ENFORCE(0 <= client.start(
node->getNodeStatusProvider().getHardwareVersion().unique_id, preferred_node_id));
49 std::cout <<
"Waiting for dynamic node ID allocation..." << std::endl;
51 while (!client.isAllocationComplete())
56 std::cerr <<
"Spin error: " << res << std::endl;
60 std::cout <<
"Node ID " <<
int(client.getAllocatedNodeID().get())
61 <<
" allocated by " <<
int(client.getAllocatorNodeID().get()) << std::endl;
66 node->setNodeID(client.getAllocatedNodeID());
68 node->setModeOperational();
80 std::cerr <<
"Spin error: " << res << std::endl;
87 int main(
int argc,
const char** argv)
93 std::cerr <<
"Usage:\n\t"
94 << argv[0] <<
" <instance-id> <can-iface-name-1> [can-iface-name-N...]\n"
95 <<
"Where <instance-id> is used to augment the unique node ID and also indicates\n"
96 <<
"the preferred node ID value. Valid range is [0, 127]."
101 const int instance_id = std::stoi(argv[1]);
102 if (instance_id < 0 || instance_id > 127)
104 std::cerr <<
"Invalid instance ID: " << instance_id << std::endl;
111 "org.uavcan.linux_test_dynamic_node_id_client");
116 catch (
const std::exception& ex)
118 std::cerr <<
"Error: " << ex.what() << std::endl;