mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 23:53:33 +08:00
Support for different DTID limits depending on data type kind; tests are failing now!
This commit is contained in:
@@ -61,7 +61,7 @@ GlobalDataTypeRegistry::RegistrationResult GlobalDataTypeRegistry::remove(Entry*
|
||||
|
||||
GlobalDataTypeRegistry::RegistrationResult GlobalDataTypeRegistry::registImpl(Entry* dtd)
|
||||
{
|
||||
if (!dtd || (dtd->descriptor.getID() > DataTypeID::Max))
|
||||
if (!dtd || !dtd->descriptor.isValid())
|
||||
{
|
||||
UAVCAN_ASSERT(0);
|
||||
return RegistrationResultInvalidParams;
|
||||
@@ -241,7 +241,7 @@ DataTypeSignature GlobalDataTypeRegistry::computeAggregateSignature(DataTypeKind
|
||||
p = p->getNextListNode();
|
||||
}
|
||||
prev_dtid++;
|
||||
while (prev_dtid <= DataTypeID::Max)
|
||||
while (unsigned(prev_dtid) < inout_id_mask.size())
|
||||
{
|
||||
inout_id_mask[unsigned(prev_dtid++)] = false;
|
||||
}
|
||||
|
||||
@@ -17,17 +17,21 @@ void DataTypeInfoProvider::handleComputeAggregateTypeSignatureRequest(
|
||||
const protocol::ComputeAggregateTypeSignature::Request& request,
|
||||
protocol::ComputeAggregateTypeSignature::Response& response)
|
||||
{
|
||||
const DataTypeKind kind = DataTypeKind(request.kind.value);
|
||||
const DataTypeKind kind = DataTypeKind(request.kind.value); // No mapping needed
|
||||
if (!isValidDataTypeKind(kind))
|
||||
{
|
||||
UAVCAN_TRACE("DataTypeInfoProvider",
|
||||
"ComputeAggregateTypeSignature request with invalid DataTypeKind %i", kind);
|
||||
"ComputeAggregateTypeSignature request with invalid DataTypeKind %d", kind);
|
||||
return;
|
||||
}
|
||||
|
||||
UAVCAN_TRACE("DataTypeInfoProvider", "ComputeAggregateTypeSignature request for dtk=%i", int(request.kind.value));
|
||||
UAVCAN_TRACE("DataTypeInfoProvider", "ComputeAggregateTypeSignature request for dtk=%d, len(known_ids)=%d",
|
||||
int(request.kind.value), int(request.known_ids.size()));
|
||||
|
||||
// Correcting the mask length according to the data type kind
|
||||
response.mutually_known_ids = request.known_ids;
|
||||
response.mutually_known_ids.resize(static_cast<uint16_t>(DataTypeID::getMaxValueForDataTypeKind(kind).get() + 1U));
|
||||
|
||||
response.aggregate_signature =
|
||||
GlobalDataTypeRegistry::instance().computeAggregateSignature(kind, response.mutually_known_ids).get();
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ bool Frame::isValid() const
|
||||
((transfer_type_ == TransferTypeMessageBroadcast) != dst_node_id_.isBroadcast()) ||
|
||||
(transfer_type_ >= NumTransferTypes) ||
|
||||
(static_cast<int>(payload_len_) > getMaxPayloadLen()) ||
|
||||
(!data_type_id_.isValid());
|
||||
(!data_type_id_.isValidForDataTypeKind(getDataTypeKindForTransferType(transfer_type_)));
|
||||
|
||||
return !invalid;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,26 @@ namespace uavcan
|
||||
/*
|
||||
* DataTypeID
|
||||
*/
|
||||
const uint16_t DataTypeID::Max;
|
||||
const uint16_t DataTypeID::MaxServiceDataTypeIDValue;
|
||||
const uint16_t DataTypeID::MaxMessageDataTypeIDValue;
|
||||
const uint16_t DataTypeID::MaxPossibleDataTypeIDValue;
|
||||
|
||||
DataTypeID DataTypeID::getMaxValueForDataTypeKind(const DataTypeKind dtkind)
|
||||
{
|
||||
if (dtkind == DataTypeKindService)
|
||||
{
|
||||
return MaxServiceDataTypeIDValue;
|
||||
}
|
||||
else if (dtkind == DataTypeKindMessage)
|
||||
{
|
||||
return MaxMessageDataTypeIDValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
UAVCAN_ASSERT(0);
|
||||
return DataTypeID(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* DataTypeSignatureCRC
|
||||
@@ -78,6 +97,13 @@ TransferCRC DataTypeSignature::toTransferCRC() const
|
||||
*/
|
||||
const unsigned DataTypeDescriptor::MaxFullNameLen;
|
||||
|
||||
bool DataTypeDescriptor::isValid() const
|
||||
{
|
||||
return id_.isValidForDataTypeKind(kind_) &&
|
||||
(full_name_ != NULL) &&
|
||||
(*full_name_ != '\0');
|
||||
}
|
||||
|
||||
bool DataTypeDescriptor::match(DataTypeKind kind, const char* name) const
|
||||
{
|
||||
return (kind_ == kind) && !std::strncmp(full_name_, name, MaxFullNameLen);
|
||||
|
||||
Reference in New Issue
Block a user