CanRxFrame inherits CanFrame

This commit is contained in:
Pavel Kirienko 2014-02-02 22:58:44 +04:00
parent 8794c7eab9
commit 6790b04056
5 changed files with 8 additions and 8 deletions

View File

@ -15,9 +15,8 @@
namespace uavcan
{
struct CanRxFrame
struct CanRxFrame : public CanFrame
{
CanFrame frame;
uint64_t timestamp;
uint8_t iface_index;

View File

@ -137,7 +137,7 @@ struct RxFrame
bool parse(const CanRxFrame& can_frame)
{
if (!frame.parse(can_frame.frame))
if (!frame.parse(can_frame))
return false;
timestamp = can_frame.timestamp;
iface_index = can_frame.iface_index;

View File

@ -347,7 +347,7 @@ int CanIOManager::receive(CanRxFrame& frame, uint64_t monotonic_deadline)
assert(0); // Nonexistent interface
continue;
}
const int res = iface->receive(frame.frame, frame.timestamp);
const int res = iface->receive(frame, frame.timestamp);
if (res == 0)
{
assert(0); // select() reported that iface has pending RX frames, but receive() returned none

View File

@ -196,13 +196,14 @@ TEST(CanIOManager, CanDriverMock)
static bool rxFrameEquals(const uavcan::CanRxFrame& rxframe, const uavcan::CanFrame& frame,
uint64_t timestamp, int iface_index)
{
if (rxframe.frame != frame)
if (static_cast<const uavcan::CanFrame&>(rxframe) != frame)
{
std::cout << "Frame mismatch:\n"
<< " " << rxframe.frame.toString(uavcan::CanFrame::STR_ALIGNED) << "\n"
<< " " << rxframe.toString(uavcan::CanFrame::STR_ALIGNED) << "\n"
<< " " << frame.toString(uavcan::CanFrame::STR_ALIGNED) << std::endl;
}
return (rxframe.frame == frame) && (rxframe.timestamp == timestamp) && (rxframe.iface_index == iface_index);
return (static_cast<const uavcan::CanFrame&>(rxframe) == frame) &&
(rxframe.timestamp == timestamp) && (rxframe.iface_index == iface_index);
}
TEST(CanIOManager, Reception)

View File

@ -145,7 +145,7 @@ TEST(Transfer, RxFrameParseCompile)
ASSERT_FALSE(rx_frame.parse(can_rx_frame));
// Default
can_rx_frame.frame.id = CanFrame::FLAG_EFF;
can_rx_frame.id = CanFrame::FLAG_EFF;
ASSERT_TRUE(rx_frame.parse(can_rx_frame));
ASSERT_EQ(0, rx_frame.timestamp);
ASSERT_EQ(0, rx_frame.iface_index);