mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 17:23:34 +08:00
Linux makeNode() helper overload
This commit is contained in:
@@ -392,16 +392,9 @@ static uavcan_linux::NodePtr initMainNode(const std::vector<std::string>& ifaces
|
||||
{
|
||||
std::cout << "Initializing main node" << std::endl;
|
||||
|
||||
auto node = uavcan_linux::makeNode(ifaces);
|
||||
|
||||
node->setNodeID(nid);
|
||||
node->setName(name.c_str());
|
||||
|
||||
auto node = uavcan_linux::makeNode(ifaces, name.c_str(),
|
||||
uavcan::protocol::SoftwareVersion(), uavcan::protocol::HardwareVersion(), nid);
|
||||
node->getLogger().setLevel(uavcan::protocol::debug::LogLevel::DEBUG);
|
||||
|
||||
const int start_res = node->start();
|
||||
ENFORCE(0 == start_res);
|
||||
|
||||
node->setModeOperational();
|
||||
return node;
|
||||
}
|
||||
@@ -414,8 +407,8 @@ static uavcan_linux::SubNodePtr initSubNode(unsigned num_ifaces, uavcan::INode&
|
||||
typedef VirtualCanDriver<QueuePoolSize> Driver;
|
||||
|
||||
std::shared_ptr<Driver> driver(new Driver(num_ifaces));
|
||||
auto node = uavcan_linux::makeSubNode(driver);
|
||||
node->setNodeID(main_node.getNodeID());
|
||||
|
||||
auto node = uavcan_linux::makeSubNode(driver, main_node.getNodeID());
|
||||
|
||||
main_node.getDispatcher().installRxFrameListener(driver.get());
|
||||
|
||||
|
||||
@@ -32,25 +32,15 @@ constexpr int MinUpdateInterval = 100;
|
||||
|
||||
uavcan_linux::NodePtr initNode(const std::vector<std::string>& ifaces, uavcan::NodeID nid, const std::string& name)
|
||||
{
|
||||
auto node = uavcan_linux::makeNode(ifaces);
|
||||
const auto app_id = uavcan_linux::makeApplicationID(uavcan_linux::MachineIDReader().read(), name, nid.get());
|
||||
|
||||
uavcan::protocol::HardwareVersion hwver;
|
||||
std::copy(app_id.begin(), app_id.end(), hwver.unique_id.begin());
|
||||
std::cout << hwver << std::endl;
|
||||
|
||||
auto node = uavcan_linux::makeNode(ifaces, name.c_str(), uavcan::protocol::SoftwareVersion(), hwver, nid);
|
||||
|
||||
node->setNodeID(nid);
|
||||
node->setName(name.c_str());
|
||||
node->getLogger().setLevel(uavcan::protocol::debug::LogLevel::DEBUG);
|
||||
|
||||
{
|
||||
const auto app_id = uavcan_linux::makeApplicationID(uavcan_linux::MachineIDReader().read(), name, nid.get());
|
||||
|
||||
uavcan::protocol::HardwareVersion hwver;
|
||||
std::copy(app_id.begin(), app_id.end(), hwver.unique_id.begin());
|
||||
std::cout << hwver << std::endl;
|
||||
|
||||
node->setHardwareVersion(hwver);
|
||||
}
|
||||
|
||||
const int start_res = node->start();
|
||||
ENFORCE(0 == start_res);
|
||||
|
||||
node->setModeOperational();
|
||||
|
||||
return node;
|
||||
|
||||
@@ -137,9 +137,8 @@ public:
|
||||
|
||||
static uavcan_linux::NodePtr initNodeInPassiveMode(const std::vector<std::string>& ifaces, const std::string& node_name)
|
||||
{
|
||||
auto node = uavcan_linux::makeNode(ifaces);
|
||||
node->setName(node_name.c_str());
|
||||
ENFORCE(0 == node->start());
|
||||
auto node = uavcan_linux::makeNode(ifaces, node_name.c_str(),
|
||||
uavcan::protocol::SoftwareVersion(), uavcan::protocol::HardwareVersion());
|
||||
node->setModeOperational();
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -74,10 +74,9 @@ public:
|
||||
|
||||
uavcan_linux::NodePtr initNode(const std::vector<std::string>& ifaces, uavcan::NodeID nid, const std::string& name)
|
||||
{
|
||||
auto node = uavcan_linux::makeNode(ifaces);
|
||||
node->setNodeID(nid);
|
||||
node->setName(name.c_str());
|
||||
ENFORCE(0 == node->start()); // This node doesn't check its network compatibility
|
||||
auto node = uavcan_linux::makeNode(ifaces, name.c_str(),
|
||||
uavcan::protocol::SoftwareVersion(), uavcan::protocol::HardwareVersion(),
|
||||
nid);
|
||||
node->setModeOperational();
|
||||
return node;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user