Merge branch 'dynamic_node_id_raft' of https://github.com/UAVCAN/uavcan into dynamic_node_id_raft

This commit is contained in:
David Sidrane
2015-05-19 17:48:25 -10:00
2 changed files with 19 additions and 5 deletions
+18 -4
View File
@@ -4,6 +4,11 @@
#pragma once
#if __GNUC__
// We need auto_ptr for compatibility reasons
# pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#include <uavcan/node/abstract_node.hpp>
#include <memory>
#include <set>
@@ -212,20 +217,20 @@ struct TestNetwork
{
for (uavcan::uint8_t i = 0; i < NumNodes; i++)
{
nodes[i].reset(new NodeEnvironment(first_node_id + i));
nodes[i].reset(new NodeEnvironment(uint8_t(first_node_id + i)));
}
for (uavcan::uint8_t i = 0; i < NumNodes; i++)
{
for (uavcan::uint8_t k = 0; k < NumNodes; k++)
{
nodes[i]->linkTogether(nodes[k].get());
nodes[i]->can_driver.linkTogether(&nodes[k]->can_driver);
}
}
for (uavcan::uint8_t i = 0; i < NumNodes; i++)
{
assert(nodes[i]->others.size() == (NumNodes - 1));
assert(nodes[i]->can_driver.others.size() == (NumNodes - 1));
}
}
@@ -238,7 +243,7 @@ struct TestNetwork
{
for (uavcan::uint8_t i = 0; i < NumNodes; i++)
{
int ret = nodes[i]->spin(uavcan::MonotonicDuration::fromMSec(1));
int ret = nodes[i]->node.spin(uavcan::MonotonicDuration::fromMSec(1));
if (ret < 0)
{
return ret;
@@ -247,4 +252,13 @@ struct TestNetwork
}
return 0;
}
TestNode& operator[](unsigned index)
{
if (index >= NumNodes)
{
throw std::out_of_range("No such test node");
}
return nodes[index]->node;
}
};
+1 -1
View File
@@ -11,7 +11,7 @@ TEST(TestNode, TestNetwork)
TestNetwork<4> nwk;
uavcan::CanFrame frame;
for (int i = 0; i < 8; i++)
for (uint8_t i = 0; i < 8; i++)
{
frame.data[i] = i;
}