mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-26 01:53:34 +08:00
Minor source reorganization; few dangerous C functions replaced with safer std:: alternatives
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "common.hpp"
|
||||
#include <uavcan/can_driver.hpp>
|
||||
|
||||
TEST(CanFrame, FrameProperties)
|
||||
{
|
||||
@@ -1,10 +1,12 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
|
||||
* Copyright (C) 2014 <pavel.kirienko@gmail.com>
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <uavcan/internal/can_io.hpp>
|
||||
#include <cassert>
|
||||
#include <uavcan/can_driver.hpp>
|
||||
#include <uavcan/system_clock.hpp>
|
||||
|
||||
class SystemClockMock : public uavcan::ISystemClock
|
||||
{
|
||||
@@ -47,32 +49,3 @@ static uavcan::CanFrame makeFrame(uint32_t id, const std::string& str_data, Fram
|
||||
id |= (type == EXT) ? uavcan::CanFrame::FLAG_EFF : 0;
|
||||
return uavcan::CanFrame(id, reinterpret_cast<const uint8_t*>(str_data.c_str()), str_data.length());
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
int getQueueLength(uavcan::CanTxQueue& queue)
|
||||
{
|
||||
const uavcan::CanTxQueue::Entry* p = queue.peek();
|
||||
int length = 0;
|
||||
while (p)
|
||||
{
|
||||
length++;
|
||||
p = p->getNextListNode();
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
bool isInQueue(uavcan::CanTxQueue& queue, const uavcan::CanFrame& frame)
|
||||
{
|
||||
const uavcan::CanTxQueue::Entry* p = queue.peek();
|
||||
while (p)
|
||||
{
|
||||
if (frame == p->frame)
|
||||
return true;
|
||||
p = p->getNextListNode();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,9 @@
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <gtest/gtest.h>
|
||||
#include "common.hpp"
|
||||
#include <uavcan/internal/transport/can_io.hpp>
|
||||
#include "../../common.hpp"
|
||||
|
||||
|
||||
class CanIfaceMock : public uavcan::ICanIface
|
||||
{
|
||||
@@ -3,7 +3,33 @@
|
||||
*/
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include "common.hpp"
|
||||
#include <uavcan/internal/transport/can_io.hpp>
|
||||
#include "../../common.hpp"
|
||||
|
||||
|
||||
static int getQueueLength(uavcan::CanTxQueue& queue)
|
||||
{
|
||||
const uavcan::CanTxQueue::Entry* p = queue.peek();
|
||||
int length = 0;
|
||||
while (p)
|
||||
{
|
||||
length++;
|
||||
p = p->getNextListNode();
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
static bool isInQueue(uavcan::CanTxQueue& queue, const uavcan::CanFrame& frame)
|
||||
{
|
||||
const uavcan::CanTxQueue::Entry* p = queue.peek();
|
||||
while (p)
|
||||
{
|
||||
if (frame == p->frame)
|
||||
return true;
|
||||
p = p->getNextListNode();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
TEST(CanTxQueue, Qos)
|
||||
{
|
||||
Reference in New Issue
Block a user