mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 06:33:34 +08:00
Integrated DataTypeSignature; hash removed
This commit is contained in:
@@ -85,50 +85,28 @@ public:
|
||||
};
|
||||
|
||||
|
||||
struct DataTypeHash
|
||||
{
|
||||
enum { NumBytes = 16 };
|
||||
uint8_t value[NumBytes];
|
||||
|
||||
DataTypeHash()
|
||||
{
|
||||
std::fill(value, value + NumBytes, 0);
|
||||
}
|
||||
|
||||
DataTypeHash(const uint8_t source[NumBytes])
|
||||
{
|
||||
std::copy(source, source + NumBytes, value);
|
||||
}
|
||||
|
||||
bool operator!=(const DataTypeHash& rhs) const { return !operator==(rhs); }
|
||||
bool operator==(const DataTypeHash& rhs) const
|
||||
{
|
||||
return std::equal(value, value + NumBytes, rhs.value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct DataTypeDescriptor
|
||||
{
|
||||
DataTypeKind kind;
|
||||
uint16_t id;
|
||||
DataTypeHash hash;
|
||||
DataTypeSignature signature;
|
||||
|
||||
DataTypeDescriptor()
|
||||
: kind(DataTypeKind(0))
|
||||
, id(0)
|
||||
, signature(DataTypeSignature::zero())
|
||||
{ }
|
||||
|
||||
DataTypeDescriptor(DataTypeKind kind, uint16_t id, const DataTypeHash& hash)
|
||||
DataTypeDescriptor(DataTypeKind kind, uint16_t id, const DataTypeSignature& signature)
|
||||
: kind(kind)
|
||||
, id(id)
|
||||
, hash(hash)
|
||||
, signature(signature)
|
||||
{ }
|
||||
|
||||
bool operator!=(const DataTypeDescriptor& rhs) const { return !operator==(rhs); }
|
||||
bool operator==(const DataTypeDescriptor& rhs) const
|
||||
{
|
||||
return (kind == rhs.kind) && (id == rhs.id) && (hash == rhs.hash);
|
||||
return (kind == rhs.kind) && (id == rhs.id) && (signature == rhs.signature);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -35,12 +35,6 @@ public:
|
||||
: value_(0xFFFF)
|
||||
{ }
|
||||
|
||||
TransferCRC(const uint8_t* bytes, unsigned int len)
|
||||
: value_(0xFFFF)
|
||||
{
|
||||
add(bytes, len);
|
||||
}
|
||||
|
||||
void add(uint8_t byte)
|
||||
{
|
||||
value_ = ((value_ << 8) ^ Table[((value_ >> 8) ^ byte) & 0xFF]) & 0xFFFF;
|
||||
|
||||
@@ -95,7 +95,7 @@ class TransferListenerBase : public LinkedListNode<TransferListenerBase>
|
||||
protected:
|
||||
TransferListenerBase(const DataTypeDescriptor& data_type)
|
||||
: data_type_(data_type)
|
||||
, crc_base_(data_type.hash.value, DataTypeHash::NumBytes)
|
||||
, crc_base_(data_type.signature.toTransferCRC())
|
||||
{ }
|
||||
|
||||
virtual ~TransferListenerBase() { }
|
||||
|
||||
@@ -31,7 +31,7 @@ public:
|
||||
: max_transfer_interval_(max_transfer_interval)
|
||||
, data_type_(data_type)
|
||||
, qos_(qos)
|
||||
, crc_base_(data_type.hash.value, DataTypeHash::NumBytes)
|
||||
, crc_base_(data_type.signature.toTransferCRC())
|
||||
, dispatcher_(dispatcher)
|
||||
{ }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user