mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-30 00:23:34 +08:00
::uavcan::CanIOManeger::MaxIfaces --> ::uavcan::MaxCanIfaces
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
namespace uavcan
|
namespace uavcan
|
||||||
{
|
{
|
||||||
|
|
||||||
|
enum { MaxCanIfaces = 3 };
|
||||||
|
|
||||||
struct CanRxFrame : public CanFrame
|
struct CanRxFrame : public CanFrame
|
||||||
{
|
{
|
||||||
MonotonicTime ts_mono;
|
MonotonicTime ts_mono;
|
||||||
@@ -116,14 +118,10 @@ public:
|
|||||||
|
|
||||||
class CanIOManager : Noncopyable
|
class CanIOManager : Noncopyable
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
enum { MaxIfaces = 3 };
|
|
||||||
|
|
||||||
private:
|
|
||||||
ICanDriver& driver_;
|
ICanDriver& driver_;
|
||||||
ISystemClock& sysclock_;
|
ISystemClock& sysclock_;
|
||||||
|
|
||||||
CanTxQueue tx_queues_[MaxIfaces];
|
CanTxQueue tx_queues_[MaxCanIfaces];
|
||||||
|
|
||||||
// Noncopyable
|
// Noncopyable
|
||||||
CanIOManager(CanIOManager&);
|
CanIOManager(CanIOManager&);
|
||||||
@@ -138,9 +136,9 @@ public:
|
|||||||
: driver_(driver)
|
: driver_(driver)
|
||||||
, sysclock_(sysclock)
|
, sysclock_(sysclock)
|
||||||
{
|
{
|
||||||
assert(driver.getNumIfaces() <= MaxIfaces);
|
assert(driver.getNumIfaces() <= MaxCanIfaces);
|
||||||
// We can't initialize member array with non-default constructors in C++03
|
// We can't initialize member array with non-default constructors in C++03
|
||||||
for (int i = 0; i < MaxIfaces; i++)
|
for (int i = 0; i < MaxCanIfaces; i++)
|
||||||
{
|
{
|
||||||
tx_queues_[i].~CanTxQueue();
|
tx_queues_[i].~CanTxQueue();
|
||||||
new (tx_queues_ + i) CanTxQueue(&allocator, &sysclock);
|
new (tx_queues_ + i) CanTxQueue(&allocator, &sysclock);
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ bool CanTxQueue::topPriorityHigherOrEqual(const CanFrame& rhs_frame) const
|
|||||||
*/
|
*/
|
||||||
int CanIOManager::sendToIface(int iface_index, const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags)
|
int CanIOManager::sendToIface(int iface_index, const CanFrame& frame, MonotonicTime tx_deadline, CanIOFlags flags)
|
||||||
{
|
{
|
||||||
assert(iface_index >= 0 && iface_index < MaxIfaces);
|
assert(iface_index >= 0 && iface_index < MaxCanIfaces);
|
||||||
ICanIface* const iface = driver_.getIface(iface_index);
|
ICanIface* const iface = driver_.getIface(iface_index);
|
||||||
if (iface == NULL)
|
if (iface == NULL)
|
||||||
{
|
{
|
||||||
@@ -214,7 +214,7 @@ int CanIOManager::sendToIface(int iface_index, const CanFrame& frame, MonotonicT
|
|||||||
|
|
||||||
int CanIOManager::sendFromTxQueue(int iface_index)
|
int CanIOManager::sendFromTxQueue(int iface_index)
|
||||||
{
|
{
|
||||||
assert(iface_index >= 0 && iface_index < MaxIfaces);
|
assert(iface_index >= 0 && iface_index < MaxCanIfaces);
|
||||||
CanTxQueue::Entry* entry = tx_queues_[iface_index].peek();
|
CanTxQueue::Entry* entry = tx_queues_[iface_index].peek();
|
||||||
if (entry == NULL)
|
if (entry == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -238,14 +238,14 @@ int CanIOManager::makePendingTxMask() const
|
|||||||
int CanIOManager::getNumIfaces() const
|
int CanIOManager::getNumIfaces() const
|
||||||
{
|
{
|
||||||
const int num = driver_.getNumIfaces();
|
const int num = driver_.getNumIfaces();
|
||||||
assert(num > 0 && num <= MaxIfaces);
|
assert(num > 0 && num <= MaxCanIfaces);
|
||||||
return std::min(std::max(num, 0), (int)MaxIfaces);
|
return std::min(std::max(num, 0), (int)MaxCanIfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t CanIOManager::getNumErrors(int iface_index) const
|
uint64_t CanIOManager::getNumErrors(int iface_index) const
|
||||||
{
|
{
|
||||||
ICanIface* const iface = driver_.getIface(iface_index);
|
ICanIface* const iface = driver_.getIface(iface_index);
|
||||||
if (iface == NULL || iface_index >= MaxIfaces || iface_index < 0)
|
if (iface == NULL || iface_index >= MaxCanIfaces || iface_index < 0)
|
||||||
{
|
{
|
||||||
assert(0);
|
assert(0);
|
||||||
return std::numeric_limits<uint64_t>::max();
|
return std::numeric_limits<uint64_t>::max();
|
||||||
|
|||||||
Reference in New Issue
Block a user