mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 16:13:34 +08:00
Most enums were replaced with constants, according to MISRA
This commit is contained in:
@@ -29,7 +29,7 @@ class UAVCAN_EXPORT DataTypeID
|
|||||||
uint16_t value_;
|
uint16_t value_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { Max = 1023 };
|
static const uint16_t Max = 1023;
|
||||||
|
|
||||||
DataTypeID() : value_(0xFFFF) { }
|
DataTypeID() : value_(0xFFFF) { }
|
||||||
|
|
||||||
@@ -69,13 +69,13 @@ class UAVCAN_EXPORT DataTypeSignatureCRC
|
|||||||
public:
|
public:
|
||||||
static DataTypeSignatureCRC extend(uint64_t crc);
|
static DataTypeSignatureCRC extend(uint64_t crc);
|
||||||
|
|
||||||
DataTypeSignatureCRC() : crc_(0xFFFFFFFFFFFFFFFF) { }
|
DataTypeSignatureCRC() : crc_(0xFFFFFFFFFFFFFFFFULL) { }
|
||||||
|
|
||||||
void add(uint8_t byte);
|
void add(uint8_t byte);
|
||||||
|
|
||||||
void add(const uint8_t* bytes, unsigned len);
|
void add(const uint8_t* bytes, unsigned len);
|
||||||
|
|
||||||
uint64_t get() const { return crc_ ^ 0xFFFFFFFFFFFFFFFF; }
|
uint64_t get() const { return crc_ ^ 0xFFFFFFFFFFFFFFFFULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ class UAVCAN_EXPORT DataTypeDescriptor
|
|||||||
const char* full_name_;
|
const char* full_name_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { MaxFullNameLen = 80 };
|
static const unsigned MaxFullNameLen = 80;
|
||||||
|
|
||||||
DataTypeDescriptor()
|
DataTypeDescriptor()
|
||||||
: kind_(DataTypeKind(0))
|
: kind_(DataTypeKind(0))
|
||||||
|
|||||||
@@ -95,11 +95,8 @@ struct UAVCAN_EXPORT CanSelectMasks
|
|||||||
{ }
|
{ }
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
CanIOFlagLoopback = 1 ///< Send the frame back to RX with true TX timestamps
|
|
||||||
};
|
|
||||||
typedef uint16_t CanIOFlags;
|
typedef uint16_t CanIOFlags;
|
||||||
|
static const CanIOFlags CanIOFlagLoopback = 1; ///< Send the frame back to RX with true TX timestamps
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Single non-blocking CAN interface.
|
* Single non-blocking CAN interface.
|
||||||
|
|||||||
@@ -9,14 +9,13 @@
|
|||||||
|
|
||||||
namespace uavcan
|
namespace uavcan
|
||||||
{
|
{
|
||||||
|
namespace
|
||||||
|
{
|
||||||
/**
|
/**
|
||||||
* Common error codes.
|
* Common error codes.
|
||||||
* Functions that return signed integers may also return inverted error codes,
|
* Functions that return signed integers may also return inverted error codes,
|
||||||
* i.e. returned value should be inverted back to get the actual error code.
|
* i.e. returned value should be inverted back to get the actual error code.
|
||||||
*/
|
*/
|
||||||
namespace
|
|
||||||
{
|
|
||||||
|
|
||||||
const int16_t ErrOk = 0;
|
const int16_t ErrOk = 0;
|
||||||
const int16_t ErrFailure = 1;
|
const int16_t ErrFailure = 1;
|
||||||
const int16_t ErrInvalidParam = 2;
|
const int16_t ErrInvalidParam = 2;
|
||||||
|
|||||||
@@ -91,15 +91,15 @@ namespace uavcan
|
|||||||
* fit this size; otherwise compilation fails.
|
* fit this size; otherwise compilation fails.
|
||||||
*/
|
*/
|
||||||
#if UAVCAN_MEM_POOL_BLOCK_SIZE
|
#if UAVCAN_MEM_POOL_BLOCK_SIZE
|
||||||
enum { MemPoolBlockSize = UAVCAN_MEM_POOL_BLOCK_SIZE };
|
static const unsigned MemPoolBlockSize = UAVCAN_MEM_POOL_BLOCK_SIZE;
|
||||||
#else
|
#else
|
||||||
enum { MemPoolBlockSize = 64 };
|
static const unsigned MemPoolBlockSize = 64;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __BIGGEST_ALIGNMENT__
|
#ifdef __BIGGEST_ALIGNMENT__
|
||||||
enum { MemPoolAlignment = __BIGGEST_ALIGNMENT__ };
|
static const unsigned MemPoolAlignment = __BIGGEST_ALIGNMENT__;
|
||||||
#else
|
#else
|
||||||
enum { MemPoolAlignment = 16 };
|
static const unsigned MemPoolAlignment = 16;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef char _alignment_check_for_MEM_POOL_BLOCK_SIZE[((MemPoolBlockSize & (MemPoolAlignment - 1)) == 0) ? 1 : -1];
|
typedef char _alignment_check_for_MEM_POOL_BLOCK_SIZE[((MemPoolBlockSize & (MemPoolAlignment - 1)) == 0) ? 1 : -1];
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class UAVCAN_EXPORT MapBase : Noncopyable
|
|||||||
|
|
||||||
KVGroup()
|
KVGroup()
|
||||||
{
|
{
|
||||||
StaticAssert<(NumKV > 0)>::check();
|
StaticAssert<(static_cast<unsigned>(NumKV) > 0)>::check();
|
||||||
IsDynamicallyAllocatable<KVGroup>::check();
|
IsDynamicallyAllocatable<KVGroup>::check();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ class UAVCAN_EXPORT MapBase : Noncopyable
|
|||||||
|
|
||||||
KVPair* find(const Key& key)
|
KVPair* find(const Key& key)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < NumKV; i++)
|
for (unsigned i = 0; i < static_cast<unsigned>(NumKV); i++)
|
||||||
{
|
{
|
||||||
if (kvs[i].match(key))
|
if (kvs[i].match(key))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ class UAVCAN_EXPORT Array : public ArrayImpl<T, ArrayMode, MaxSize_>
|
|||||||
void packSquareMatrixImpl(const InputIter src_row_major)
|
void packSquareMatrixImpl(const InputIter src_row_major)
|
||||||
{
|
{
|
||||||
StaticAssert<IsDynamic>::check();
|
StaticAssert<IsDynamic>::check();
|
||||||
enum { Width = CompileTimeIntSqrt<MaxSize>::Result };
|
const unsigned Width = CompileTimeIntSqrt<MaxSize>::Result;
|
||||||
|
|
||||||
bool all_nans = true;
|
bool all_nans = true;
|
||||||
bool scalar_matrix = true;
|
bool scalar_matrix = true;
|
||||||
@@ -409,7 +409,7 @@ class UAVCAN_EXPORT Array : public ArrayImpl<T, ArrayMode, MaxSize_>
|
|||||||
void unpackSquareMatrixImpl(OutputIter it) const
|
void unpackSquareMatrixImpl(OutputIter it) const
|
||||||
{
|
{
|
||||||
StaticAssert<IsDynamic>::check();
|
StaticAssert<IsDynamic>::check();
|
||||||
enum { Width = CompileTimeIntSqrt<MaxSize>::Result };
|
const unsigned Width = CompileTimeIntSqrt<MaxSize>::Result;
|
||||||
/*
|
/*
|
||||||
* Unpacking as follows:
|
* Unpacking as follows:
|
||||||
* - Array of length 1 will be unpacked to scalar matrix
|
* - Array of length 1 will be unpacked to scalar matrix
|
||||||
@@ -453,8 +453,17 @@ public:
|
|||||||
|
|
||||||
enum { IsDynamic = ArrayMode == ArrayModeDynamic };
|
enum { IsDynamic = ArrayMode == ArrayModeDynamic };
|
||||||
enum { MaxSize = MaxSize_ };
|
enum { MaxSize = MaxSize_ };
|
||||||
enum { MinBitLen = IsDynamic ? 0 : (RawValueType::MinBitLen * MaxSize) };
|
enum
|
||||||
enum { MaxBitLen = Base::SizeBitLen + RawValueType::MaxBitLen * MaxSize };
|
{
|
||||||
|
MinBitLen = (IsDynamic == 0)
|
||||||
|
? (static_cast<unsigned>(RawValueType::MinBitLen) * static_cast<unsigned>(MaxSize))
|
||||||
|
: 0
|
||||||
|
};
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
MaxBitLen = static_cast<unsigned>(Base::SizeBitLen) +
|
||||||
|
static_cast<unsigned>(RawValueType::MaxBitLen) * static_cast<unsigned>(MaxSize)
|
||||||
|
};
|
||||||
|
|
||||||
static int encode(const SelfType& array, ScalarCodec& codec, const TailArrayOptimizationMode tao_mode)
|
static int encode(const SelfType& array, ScalarCodec& codec, const TailArrayOptimizationMode tao_mode)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ void bitarrayCopy(const unsigned char* src_org, int src_offset, int src_len, uns
|
|||||||
|
|
||||||
class UAVCAN_EXPORT BitStream
|
class UAVCAN_EXPORT BitStream
|
||||||
{
|
{
|
||||||
enum { MaxBytesPerRW = 16 };
|
static const unsigned MaxBytesPerRW = 16;
|
||||||
|
|
||||||
ITransferBuffer& buf_;
|
ITransferBuffer& buf_;
|
||||||
int bit_offset_;
|
int bit_offset_;
|
||||||
@@ -33,7 +33,7 @@ class UAVCAN_EXPORT BitStream
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { MaxBitsPerRW = MaxBytesPerRW * 8 };
|
static const unsigned MaxBitsPerRW = MaxBytesPerRW * 8;
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ private:
|
|||||||
static inline void saturate(StorageType& value)
|
static inline void saturate(StorageType& value)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
if (!IsExactRepresentation && isfinite(value))
|
if ((IsExactRepresentation == 0) && isfinite(value))
|
||||||
{
|
{
|
||||||
if (value > max())
|
if (value > max())
|
||||||
{
|
{
|
||||||
@@ -172,7 +172,7 @@ private:
|
|||||||
static inline void truncate(StorageType& value)
|
static inline void truncate(StorageType& value)
|
||||||
{
|
{
|
||||||
using namespace std;
|
using namespace std;
|
||||||
if (!IsExactRepresentation && isfinite(value))
|
if ((IsExactRepresentation == 0) && isfinite(value))
|
||||||
{
|
{
|
||||||
if (value > max())
|
if (value > max())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,19 +44,29 @@ private:
|
|||||||
static StorageType max()
|
static StorageType max()
|
||||||
{
|
{
|
||||||
StaticAssert<(sizeof(uintmax_t) >= 8)>::check();
|
StaticAssert<(sizeof(uintmax_t) >= 8)>::check();
|
||||||
return StorageType(IsSigned ? ((uintmax_t(1) << (BitLen - 1)) - 1) : ((uintmax_t(1) << BitLen) - 1));
|
if (IsSigned == 0)
|
||||||
|
{
|
||||||
|
return StorageType((uintmax_t(1) << static_cast<unsigned>(BitLen)) - 1U);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return StorageType((uintmax_t(1) << (static_cast<unsigned>(BitLen) - 1U)) - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
static UnsignedStorageType mask()
|
static UnsignedStorageType mask()
|
||||||
{
|
{
|
||||||
StaticAssert<(sizeof(uintmax_t) >= 8)>::check();
|
StaticAssert<(sizeof(uintmax_t) >= 8U)>::check();
|
||||||
return UnsignedStorageType((uintmax_t(1) << BitLen) - 1);
|
return UnsignedStorageType((uintmax_t(1) << static_cast<unsigned>(BitLen)) - 1U);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LimitsImpl64
|
struct LimitsImpl64
|
||||||
{
|
{
|
||||||
static StorageType max() { return StorageType(IsSigned ? 0x7FFFFFFFFFFFFFFF : 0xFFFFFFFFFFFFFFFF); }
|
static StorageType max()
|
||||||
static UnsignedStorageType mask() { return 0xFFFFFFFFFFFFFFFF; }
|
{
|
||||||
|
return StorageType((IsSigned != 0) ? 0x7FFFFFFFFFFFFFFFLL : 0xFFFFFFFFFFFFFFFFULL);
|
||||||
|
}
|
||||||
|
static UnsignedStorageType mask() { return 0xFFFFFFFFFFFFFFFFULL; }
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef typename Select<(BitLen == 64), LimitsImpl64, LimitsImplGeneric>::Result Limits;
|
typedef typename Select<(BitLen == 64), LimitsImpl64, LimitsImplGeneric>::Result Limits;
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum { TimerPeriodMs100 = 5 };
|
static const unsigned TimerPeriodMs100 = 5;
|
||||||
|
|
||||||
typedef MethodBinder<NodeStatusMonitor*,
|
typedef MethodBinder<NodeStatusMonitor*,
|
||||||
void (NodeStatusMonitor::*)(const ReceivedDataStructure<protocol::NodeStatus>&)>
|
void (NodeStatusMonitor::*)(const ReceivedDataStructure<protocol::NodeStatus>&)>
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public:
|
|||||||
return *static_cast<D*>(this);
|
return *static_cast<D*>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { StringBufSize = 32 };
|
static const unsigned StringBufSize = 32;
|
||||||
void toString(char buf[StringBufSize]) const;
|
void toString(char buf[StringBufSize]) const;
|
||||||
#if UAVCAN_TOSTRING
|
#if UAVCAN_TOSTRING
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
@@ -169,7 +169,7 @@ public:
|
|||||||
return *static_cast<T*>(this);
|
return *static_cast<T*>(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum { StringBufSize = 32 };
|
static const unsigned StringBufSize = 32;
|
||||||
void toString(char buf[StringBufSize]) const;
|
void toString(char buf[StringBufSize]) const;
|
||||||
#if UAVCAN_TOSTRING
|
#if UAVCAN_TOSTRING
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
@@ -214,6 +214,12 @@ public:
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template <typename D>
|
||||||
|
const unsigned DurationBase<D>::StringBufSize;
|
||||||
|
|
||||||
|
template <typename T, typename D>
|
||||||
|
const unsigned TimeBase<T, D>::StringBufSize;
|
||||||
|
|
||||||
template <typename D>
|
template <typename D>
|
||||||
void DurationBase<D>::toString(char buf[StringBufSize]) const
|
void DurationBase<D>::toString(char buf[StringBufSize]) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ public:
|
|||||||
, qos(uint8_t(qos))
|
, qos(uint8_t(qos))
|
||||||
, flags(flags)
|
, flags(flags)
|
||||||
{
|
{
|
||||||
assert(qos == Volatile || qos == Persistent);
|
assert((qos == Volatile) || (qos == Persistent));
|
||||||
IsDynamicallyAllocatable<Entry>::check();
|
IsDynamicallyAllocatable<Entry>::check();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,9 +11,9 @@
|
|||||||
namespace uavcan
|
namespace uavcan
|
||||||
{
|
{
|
||||||
|
|
||||||
enum { MaxTransferPayloadLen = 439 }; ///< According to the standard
|
static const unsigned MaxTransferPayloadLen = 439; ///< According to the RFC
|
||||||
|
|
||||||
enum { MaxSingleFrameTransferPayloadLen = 7 };
|
static const unsigned MaxSingleFrameTransferPayloadLen = 7;
|
||||||
|
|
||||||
enum TransferType
|
enum TransferType
|
||||||
{
|
{
|
||||||
@@ -30,8 +30,8 @@ class UAVCAN_EXPORT TransferID
|
|||||||
uint8_t value_;
|
uint8_t value_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { BitLen = 3 };
|
static const uint8_t BitLen = 3U;
|
||||||
enum { Max = (1 << BitLen) - 1 };
|
static const uint8_t Max = (1U << BitLen) - 1U;
|
||||||
|
|
||||||
TransferID()
|
TransferID()
|
||||||
: value_(0)
|
: value_(0)
|
||||||
@@ -67,17 +67,13 @@ public:
|
|||||||
|
|
||||||
class UAVCAN_EXPORT NodeID
|
class UAVCAN_EXPORT NodeID
|
||||||
{
|
{
|
||||||
enum
|
static const uint8_t ValueBroadcast = 0;
|
||||||
{
|
static const uint8_t ValueInvalid = 0xFF;
|
||||||
ValueBroadcast = 0,
|
|
||||||
ValueInvalid = 0xFF
|
|
||||||
};
|
|
||||||
uint8_t value_;
|
uint8_t value_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum { BitLen = 7 };
|
static const uint8_t BitLen = 7U;
|
||||||
enum { Max = (1 << BitLen) - 1 };
|
static const uint8_t Max = (1U << BitLen) - 1U;
|
||||||
|
|
||||||
static const NodeID Broadcast;
|
static const NodeID Broadcast;
|
||||||
|
|
||||||
NodeID() : value_(ValueInvalid) { }
|
NodeID() : value_(ValueInvalid) { }
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ class UAVCAN_EXPORT DynamicTransferBufferManagerEntry
|
|||||||
struct Block : LinkedListNode<Block>
|
struct Block : LinkedListNode<Block>
|
||||||
{
|
{
|
||||||
enum { Size = MemPoolBlockSize - sizeof(LinkedListNode<Block>) };
|
enum { Size = MemPoolBlockSize - sizeof(LinkedListNode<Block>) };
|
||||||
uint8_t data[Size];
|
uint8_t data[static_cast<unsigned>(Size)];
|
||||||
|
|
||||||
static Block* instantiate(IPoolAllocator& allocator);
|
static Block* instantiate(IPoolAllocator& allocator);
|
||||||
static void destroy(Block*& obj, IPoolAllocator& allocator);
|
static void destroy(Block*& obj, IPoolAllocator& allocator);
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
enum TidRelation { TidSame, TidRepeat, TidFuture };
|
enum TidRelation { TidSame, TidRepeat, TidFuture };
|
||||||
enum { IfaceIndexNotSet = 0xFF };
|
static const uint8_t IfaceIndexNotSet = 0xFF;
|
||||||
|
|
||||||
MonotonicTime prev_transfer_ts_;
|
MonotonicTime prev_transfer_ts_;
|
||||||
MonotonicTime this_transfer_ts_;
|
MonotonicTime this_transfer_ts_;
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ std::string CanFrame::toString(StringRepresentation mode) const
|
|||||||
|
|
||||||
assert(mode == StrTight || mode == StrAligned);
|
assert(mode == StrTight || mode == StrAligned);
|
||||||
|
|
||||||
static const int ASCII_COLUMN_OFFSET = 36;
|
static const unsigned AsciiColumnOffset = 36U;
|
||||||
|
|
||||||
char buf[50];
|
char buf[50];
|
||||||
char* wpos = buf;
|
char* wpos = buf;
|
||||||
@@ -96,7 +96,7 @@ std::string CanFrame::toString(StringRepresentation mode) const
|
|||||||
wpos += snprintf(wpos, epos - wpos, " %02x", unsigned(data[dlen]));
|
wpos += snprintf(wpos, epos - wpos, " %02x", unsigned(data[dlen]));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (mode == StrAligned && wpos < buf + ASCII_COLUMN_OFFSET) // alignment
|
while ((mode == StrAligned) && (wpos < buf + AsciiColumnOffset)) // alignment
|
||||||
{
|
{
|
||||||
*wpos++ = ' ';
|
*wpos++ = ' ';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,13 +9,16 @@
|
|||||||
namespace uavcan
|
namespace uavcan
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const unsigned BitStream::MaxBytesPerRW;
|
||||||
|
const unsigned BitStream::MaxBitsPerRW;
|
||||||
|
|
||||||
int BitStream::write(const uint8_t* bytes, const int bitlen)
|
int BitStream::write(const uint8_t* bytes, const int bitlen)
|
||||||
{
|
{
|
||||||
// Temporary buffer is needed to merge new bits with cached unaligned bits from the last write() (see byte_cache_)
|
// Temporary buffer is needed to merge new bits with cached unaligned bits from the last write() (see byte_cache_)
|
||||||
uint8_t tmp[MaxBytesPerRW + 1];
|
uint8_t tmp[MaxBytesPerRW + 1];
|
||||||
|
|
||||||
// Tmp space must be large enough to accomodate new bits AND unaligned bits from the last write()
|
// Tmp space must be large enough to accomodate new bits AND unaligned bits from the last write()
|
||||||
const int bytelen = bitlenToBytelen(bitlen + (bit_offset_ % 8));
|
const unsigned bytelen = bitlenToBytelen(bitlen + (bit_offset_ % 8));
|
||||||
assert(MaxBytesPerRW >= bytelen);
|
assert(MaxBytesPerRW >= bytelen);
|
||||||
tmp[0] = tmp[bytelen - 1] = 0;
|
tmp[0] = tmp[bytelen - 1] = 0;
|
||||||
|
|
||||||
@@ -40,7 +43,7 @@ int BitStream::write(const uint8_t* bytes, const int bitlen)
|
|||||||
{
|
{
|
||||||
return write_res;
|
return write_res;
|
||||||
}
|
}
|
||||||
if (write_res < bytelen)
|
if (static_cast<unsigned>(write_res) < bytelen)
|
||||||
{
|
{
|
||||||
return ResultOutOfBuffer;
|
return ResultOutOfBuffer;
|
||||||
}
|
}
|
||||||
@@ -53,7 +56,7 @@ int BitStream::read(uint8_t* bytes, const int bitlen)
|
|||||||
{
|
{
|
||||||
uint8_t tmp[MaxBytesPerRW + 1];
|
uint8_t tmp[MaxBytesPerRW + 1];
|
||||||
|
|
||||||
const int bytelen = bitlenToBytelen(bitlen + (bit_offset_ % 8));
|
const unsigned bytelen = bitlenToBytelen(bitlen + (bit_offset_ % 8));
|
||||||
assert(MaxBytesPerRW >= bytelen);
|
assert(MaxBytesPerRW >= bytelen);
|
||||||
|
|
||||||
const int read_res = buf_.read(bit_offset_ / 8, tmp, bytelen);
|
const int read_res = buf_.read(bit_offset_ / 8, tmp, bytelen);
|
||||||
@@ -61,7 +64,7 @@ int BitStream::read(uint8_t* bytes, const int bitlen)
|
|||||||
{
|
{
|
||||||
return read_res;
|
return read_res;
|
||||||
}
|
}
|
||||||
if (read_res < bytelen)
|
if (static_cast<unsigned>(read_res) < bytelen)
|
||||||
{
|
{
|
||||||
return ResultOutOfBuffer;
|
return ResultOutOfBuffer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,8 @@
|
|||||||
namespace uavcan
|
namespace uavcan
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const unsigned NodeStatusMonitor::TimerPeriodMs100;
|
||||||
|
|
||||||
NodeStatusMonitor::Entry& NodeStatusMonitor::getEntry(NodeID node_id) const
|
NodeStatusMonitor::Entry& NodeStatusMonitor::getEntry(NodeID node_id) const
|
||||||
{
|
{
|
||||||
if (node_id.get() < 1 || node_id.get() > NodeID::Max)
|
if (node_id.get() < 1 || node_id.get() > NodeID::Max)
|
||||||
@@ -55,7 +57,7 @@ void NodeStatusMonitor::handleNodeStatus(const ReceivedDataStructure<protocol::N
|
|||||||
|
|
||||||
void NodeStatusMonitor::handleTimerEvent(const TimerEvent&)
|
void NodeStatusMonitor::handleTimerEvent(const TimerEvent&)
|
||||||
{
|
{
|
||||||
enum { OfflineTimeoutMs100 = protocol::NodeStatus::OFFLINE_TIMEOUT_MS / 100 };
|
const int OfflineTimeoutMs100 = protocol::NodeStatus::OFFLINE_TIMEOUT_MS / 100;
|
||||||
|
|
||||||
for (int i = 1; i <= NodeID::Max; i++)
|
for (int i = 1; i <= NodeID::Max; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,9 +8,19 @@
|
|||||||
|
|
||||||
namespace uavcan
|
namespace uavcan
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* TransferID
|
||||||
|
*/
|
||||||
|
const uint8_t TransferID::BitLen;
|
||||||
|
const uint8_t TransferID::Max;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NodeID
|
* NodeID
|
||||||
*/
|
*/
|
||||||
|
const uint8_t NodeID::ValueBroadcast;
|
||||||
|
const uint8_t NodeID::ValueInvalid;
|
||||||
|
const uint8_t NodeID::BitLen;
|
||||||
|
const uint8_t NodeID::Max;
|
||||||
const NodeID NodeID::Broadcast(ValueBroadcast);
|
const NodeID NodeID::Broadcast(ValueBroadcast);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace uavcan
|
|||||||
const uint32_t TransferReceiver::MinTransferIntervalUSec;
|
const uint32_t TransferReceiver::MinTransferIntervalUSec;
|
||||||
const uint32_t TransferReceiver::MaxTransferIntervalUSec;
|
const uint32_t TransferReceiver::MaxTransferIntervalUSec;
|
||||||
const uint32_t TransferReceiver::DefaultTransferIntervalUSec;
|
const uint32_t TransferReceiver::DefaultTransferIntervalUSec;
|
||||||
|
const uint8_t TransferReceiver::IfaceIndexNotSet;
|
||||||
|
|
||||||
void TransferReceiver::registerError() const
|
void TransferReceiver::registerError() const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,11 @@
|
|||||||
|
|
||||||
namespace uavcan
|
namespace uavcan
|
||||||
{
|
{
|
||||||
|
/*
|
||||||
|
* DataTypeID
|
||||||
|
*/
|
||||||
|
const uint16_t DataTypeID::Max;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DataTypeSignatureCRC
|
* DataTypeSignatureCRC
|
||||||
*/
|
*/
|
||||||
@@ -71,6 +76,8 @@ TransferCRC DataTypeSignature::toTransferCRC() const
|
|||||||
/*
|
/*
|
||||||
* DataTypeDescriptor
|
* DataTypeDescriptor
|
||||||
*/
|
*/
|
||||||
|
const unsigned DataTypeDescriptor::MaxFullNameLen;
|
||||||
|
|
||||||
bool DataTypeDescriptor::match(DataTypeKind kind, const char* name) const
|
bool DataTypeDescriptor::match(DataTypeKind kind, const char* name) const
|
||||||
{
|
{
|
||||||
return (kind_ == kind) && !std::strcmp(full_name_, name);
|
return (kind_ == kind) && !std::strcmp(full_name_, name);
|
||||||
|
|||||||
Reference in New Issue
Block a user