mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-20 09:43:34 +08:00
Support for different DTID limits depending on data type kind; tests are failing now!
This commit is contained in:
@@ -24,22 +24,49 @@ enum DataTypeKind
|
||||
};
|
||||
|
||||
|
||||
static inline DataTypeKind getDataTypeKindForTransferType(const TransferType tt)
|
||||
{
|
||||
if (tt == TransferTypeServiceResponse ||
|
||||
tt == TransferTypeServiceRequest)
|
||||
{
|
||||
return DataTypeKindService;
|
||||
}
|
||||
else if (tt == TransferTypeMessageBroadcast ||
|
||||
tt == TransferTypeMessageUnicast)
|
||||
{
|
||||
return DataTypeKindMessage;
|
||||
}
|
||||
else
|
||||
{
|
||||
UAVCAN_ASSERT(0);
|
||||
return DataTypeKind(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class UAVCAN_EXPORT DataTypeID
|
||||
{
|
||||
uint16_t value_;
|
||||
|
||||
public:
|
||||
static const uint16_t Max = 1023;
|
||||
static const uint16_t MaxServiceDataTypeIDValue = 511;
|
||||
static const uint16_t MaxMessageDataTypeIDValue = 2047;
|
||||
static const uint16_t MaxPossibleDataTypeIDValue = MaxMessageDataTypeIDValue;
|
||||
|
||||
DataTypeID() : value_(0xFFFF) { }
|
||||
|
||||
DataTypeID(uint16_t id) // Implicit
|
||||
: value_(id)
|
||||
{
|
||||
UAVCAN_ASSERT(isValid());
|
||||
UAVCAN_ASSERT(id < 0xFFFF);
|
||||
}
|
||||
|
||||
bool isValid() const { return value_ <= Max; }
|
||||
static DataTypeID getMaxValueForDataTypeKind(const DataTypeKind dtkind);
|
||||
|
||||
bool isValidForDataTypeKind(DataTypeKind dtkind) const
|
||||
{
|
||||
return value_ <= getMaxValueForDataTypeKind(dtkind).get();
|
||||
}
|
||||
|
||||
uint16_t get() const { return value_; }
|
||||
|
||||
@@ -128,6 +155,8 @@ public:
|
||||
UAVCAN_ASSERT(std::strlen(name) <= MaxFullNameLen);
|
||||
}
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
DataTypeKind getKind() const { return kind_; }
|
||||
DataTypeID getID() const { return id_; }
|
||||
const DataTypeSignature& getSignature() const { return signature_; }
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace uavcan
|
||||
/**
|
||||
* Bit mask where bit at index X is set if there's a Data Type with ID X.
|
||||
*/
|
||||
typedef BitSet<DataTypeID::Max + 1> DataTypeIDMask;
|
||||
typedef BitSet<DataTypeID::MaxPossibleDataTypeIDValue + 1> DataTypeIDMask;
|
||||
|
||||
/**
|
||||
* This singleton is shared among all existing node instances. It is instantiated automatically
|
||||
@@ -153,6 +153,7 @@ public:
|
||||
|
||||
/**
|
||||
* Computes Aggregate Signature for all known data types selected by the mask.
|
||||
* Extra bits will be zeroed.
|
||||
* Please read the DSDL specification.
|
||||
* @param[in] kind Data Type Kind - messages or services.
|
||||
* @param[inout] inout_id_mask Data types to compute aggregate signature for; bits at
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
, last_frame_(last_frame)
|
||||
{
|
||||
UAVCAN_ASSERT((transfer_type == TransferTypeMessageBroadcast) == dst_node_id.isBroadcast());
|
||||
UAVCAN_ASSERT(data_type_id.isValid());
|
||||
UAVCAN_ASSERT(data_type_id.isValidForDataTypeKind(getDataTypeKindForTransferType(transfer_type)));
|
||||
UAVCAN_ASSERT(src_node_id.isUnicast() ? (src_node_id != dst_node_id) : true);
|
||||
UAVCAN_ASSERT(frame_index <= MaxIndex);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user