mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 16:43:34 +08:00
All unit tests compile, but crash. This is the most horrifying commit I've ever made.
This commit is contained in:
@@ -56,9 +56,7 @@ public:
|
||||
|
||||
DataTypeID(uint16_t id) // Implicit
|
||||
: value_(id)
|
||||
{
|
||||
UAVCAN_ASSERT(id <= MaxPossibleDataTypeIDValue);
|
||||
}
|
||||
{ }
|
||||
|
||||
static DataTypeID getMaxValueForDataTypeKind(const DataTypeKind dtkind);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ class UAVCAN_EXPORT DataTypeInfoProvider : Noncopyable
|
||||
}
|
||||
|
||||
void handleComputeAggregateTypeSignatureRequest(const protocol::ComputeAggregateTypeSignature::Request& request,
|
||||
protocol::ComputeAggregateTypeSignature::Response& response)
|
||||
protocol::ComputeAggregateTypeSignature::Response&)
|
||||
{
|
||||
const DataTypeKind kind = DataTypeKind(request.kind.value); // No mapping needed
|
||||
if (!isValidDataTypeKind(kind))
|
||||
@@ -51,6 +51,7 @@ class UAVCAN_EXPORT DataTypeInfoProvider : Noncopyable
|
||||
return;
|
||||
}
|
||||
|
||||
#if 0 /* TODO FIXME */
|
||||
UAVCAN_TRACE("DataTypeInfoProvider", "ComputeAggregateTypeSignature request for dtk=%d, len(known_ids)=%d",
|
||||
int(request.kind.value), int(request.known_ids.size()));
|
||||
|
||||
@@ -61,6 +62,7 @@ class UAVCAN_EXPORT DataTypeInfoProvider : Noncopyable
|
||||
|
||||
response.aggregate_signature =
|
||||
GlobalDataTypeRegistry::instance().computeAggregateSignature(kind, response.mutually_known_ids).get();
|
||||
#endif
|
||||
}
|
||||
|
||||
void handleGetDataTypeInfoRequest(const protocol::GetDataTypeInfo::Request& request,
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
*/
|
||||
int start(const protocol::HardwareVersion& hardware_version,
|
||||
const NodeID preferred_node_id = NodeID::Broadcast,
|
||||
const TransferPriority transfer_priority = TransferPriorityNormal);
|
||||
const TransferPriority transfer_priority = TransferPriority::OneHigherThanLowest);
|
||||
|
||||
/**
|
||||
* Use this method to determine when allocation is complete.
|
||||
|
||||
+3
-3
@@ -237,15 +237,15 @@ public:
|
||||
, allocation_pub_(node)
|
||||
{ }
|
||||
|
||||
int init()
|
||||
int init(const TransferPriority priority)
|
||||
{
|
||||
int res = allocation_pub_.init();
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
(void)allocation_pub_.setPriority(TransferPriorityLow);
|
||||
allocation_pub_.setTxTimeout(MonotonicDuration::fromMSec(Allocation::DEFAULT_REQUEST_PERIOD_MS));
|
||||
allocation_pub_.setPriority(priority);
|
||||
allocation_pub_.setTxTimeout(MonotonicDuration::fromMSec(1000 /* TODO FIXME ALLOCATION RANDOMIZATION */));
|
||||
|
||||
res = allocation_sub_.start(AllocationCallback(this, &AllocationRequestManager::handleAllocation));
|
||||
if (res < 0)
|
||||
|
||||
@@ -135,7 +135,8 @@ public:
|
||||
, storage_(storage)
|
||||
{ }
|
||||
|
||||
int init(const UniqueID& own_unique_id)
|
||||
int init(const UniqueID& own_unique_id,
|
||||
const TransferPriority priority = TransferPriority::OneHigherThanLowest)
|
||||
{
|
||||
/*
|
||||
* Initializing storage first, because the next step requires it to be loaded
|
||||
@@ -173,13 +174,13 @@ public:
|
||||
/*
|
||||
* Misc
|
||||
*/
|
||||
res = allocation_request_manager_.init();
|
||||
res = allocation_request_manager_.init(priority);
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
res = node_discoverer_.init();
|
||||
res = node_discoverer_.init(priority);
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
|
||||
+2
-2
@@ -207,7 +207,7 @@ public:
|
||||
* storage backend using key 'cluster_size'.
|
||||
* Returns negative error code.
|
||||
*/
|
||||
int init(uint8_t init_cluster_size = ClusterSizeUnknown)
|
||||
int init(const uint8_t init_cluster_size, const TransferPriority priority)
|
||||
{
|
||||
/*
|
||||
* Figuring out the cluster size
|
||||
@@ -263,7 +263,7 @@ public:
|
||||
{
|
||||
return res;
|
||||
}
|
||||
(void)discovery_pub_.setPriority(TransferPriorityLow);
|
||||
discovery_pub_.setPriority(priority);
|
||||
|
||||
res = discovery_sub_.start(DiscoveryCallback(this, &ClusterManager::handleDiscovery));
|
||||
if (res < 0)
|
||||
|
||||
@@ -727,7 +727,7 @@ public:
|
||||
* value from the persistent storage will be used. If not set and there's no such key
|
||||
* in the persistent storage, initialization will fail.
|
||||
*/
|
||||
int init(uint8_t cluster_size = ClusterManager::ClusterSizeUnknown)
|
||||
int init(const uint8_t cluster_size, const TransferPriority priority)
|
||||
{
|
||||
/*
|
||||
* Initializing state variables
|
||||
@@ -748,7 +748,7 @@ public:
|
||||
return res;
|
||||
}
|
||||
|
||||
res = cluster_.init(cluster_size);
|
||||
res = cluster_.init(cluster_size, priority);
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
|
||||
@@ -246,12 +246,14 @@ public:
|
||||
, node_discoverer_(node, tracer, *this)
|
||||
{ }
|
||||
|
||||
int init(const UniqueID& own_unique_id, const uint8_t cluster_size = ClusterManager::ClusterSizeUnknown)
|
||||
int init(const UniqueID& own_unique_id,
|
||||
const uint8_t cluster_size = ClusterManager::ClusterSizeUnknown,
|
||||
const TransferPriority priority = TransferPriority::OneHigherThanLowest)
|
||||
{
|
||||
/*
|
||||
* Initializing Raft core first, because the next step requires Log to be loaded
|
||||
*/
|
||||
int res = raft_core_.init(cluster_size);
|
||||
int res = raft_core_.init(cluster_size, priority);
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
@@ -276,13 +278,13 @@ public:
|
||||
/*
|
||||
* Misc
|
||||
*/
|
||||
res = allocation_request_manager_.init();
|
||||
res = allocation_request_manager_.init(priority);
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
res = node_discoverer_.init();
|
||||
res = node_discoverer_.init(priority);
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
|
||||
@@ -309,8 +309,10 @@ public:
|
||||
, node_status_sub_(node)
|
||||
{ }
|
||||
|
||||
int init()
|
||||
int init(const TransferPriority priority)
|
||||
{
|
||||
// TODO FIXME set priority
|
||||
(void)priority;
|
||||
int res = get_node_info_client_.init();
|
||||
if (res < 0)
|
||||
{
|
||||
|
||||
@@ -46,14 +46,14 @@ class UAVCAN_EXPORT GlobalTimeSyncMaster : protected LoopbackFrameListenerBase
|
||||
UAVCAN_ASSERT(iface_index < MaxCanIfaces);
|
||||
}
|
||||
|
||||
int init()
|
||||
int init(TransferPriority priority = TransferPriority::OneLowerThanHighest)
|
||||
{
|
||||
const int res = pub_.init();
|
||||
if (res >= 0)
|
||||
{
|
||||
pub_.getTransferSender().setIfaceMask(uint8_t(1 << iface_index_));
|
||||
pub_.getTransferSender().setCanIOFlags(CanIOFlagLoopback);
|
||||
pub_.setPriority(TransferPriorityHigh); // Fixed priority
|
||||
pub_.setPriority(priority);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class UAVCAN_EXPORT GlobalTimeSyncMaster : protected LoopbackFrameListenerBase
|
||||
{
|
||||
if (frame.getDataTypeID() == dtid_ &&
|
||||
frame.getTransferType() == TransferTypeMessageBroadcast &&
|
||||
frame.isLast() && frame.isFirst() &&
|
||||
frame.isStartOfTransfer() && frame.isEndOfTransfer() &&
|
||||
frame.getSrcNodeID() == node_.getNodeID())
|
||||
{
|
||||
iface_masters_[iface]->setTxTimestamp(frame.getUtcTimestamp());
|
||||
|
||||
@@ -94,14 +94,14 @@ public:
|
||||
* Must be called once before use.
|
||||
* Returns negative error code.
|
||||
*/
|
||||
int init()
|
||||
int init(TransferPriority priority = TransferPriority::OneHigherThanLowest)
|
||||
{
|
||||
const int res = logmsg_pub_.init();
|
||||
if (res < 0)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
logmsg_pub_.setPriority(TransferPriorityLow); // Fixed priority
|
||||
logmsg_pub_.setPriority(priority); // Fixed priority
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,7 @@ class UAVCAN_EXPORT NetworkCompatibilityChecker : Noncopyable
|
||||
last_cats_request_ok_ = resp.isSuccessful();
|
||||
if (last_cats_request_ok_)
|
||||
{
|
||||
#if 0 /* TODO FIXME */
|
||||
const DataTypeSignature sign = GlobalDataTypeRegistry::instance().
|
||||
computeAggregateSignature(checking_dtkind_, resp.getResponse().mutually_known_ids);
|
||||
|
||||
@@ -129,6 +130,7 @@ class UAVCAN_EXPORT NetworkCompatibilityChecker : Noncopyable
|
||||
{
|
||||
result_.conflicting_node = resp.getCallID().server_node_id;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +145,8 @@ class UAVCAN_EXPORT NetworkCompatibilityChecker : Noncopyable
|
||||
checking_dtkind_ = kind;
|
||||
protocol::ComputeAggregateTypeSignature::Request request;
|
||||
request.kind.value = kind;
|
||||
GlobalDataTypeRegistry::instance().getDataTypeIDMask(kind, request.known_ids);
|
||||
// TODO FIXME
|
||||
// GlobalDataTypeRegistry::instance().getDataTypeIDMask(kind, request.known_ids);
|
||||
|
||||
int res = cats_cln_.call(nid, request);
|
||||
if (res < 0)
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <cassert>
|
||||
#include <uavcan/build_config.hpp>
|
||||
#include <uavcan/util/templates.hpp>
|
||||
#include <uavcan/std.hpp>
|
||||
|
||||
namespace uavcan
|
||||
@@ -29,7 +30,13 @@ class UAVCAN_EXPORT TransferPriority
|
||||
|
||||
public:
|
||||
static const uint8_t BitLen = 5U;
|
||||
static const uint8_t NumericallyMax = (1U << BitLen) - 1;
|
||||
static const uint8_t NumericallyMin = 0;
|
||||
|
||||
/// This priority is used by default
|
||||
static const TransferPriority Default;
|
||||
static const TransferPriority OneHigherThanLowest;
|
||||
static const TransferPriority OneLowerThanHighest;
|
||||
|
||||
TransferPriority() : value_(0xFF) { }
|
||||
|
||||
@@ -39,6 +46,16 @@ public:
|
||||
UAVCAN_ASSERT(isValid());
|
||||
}
|
||||
|
||||
template <uint8_t Percent>
|
||||
static TransferPriority fromPercent()
|
||||
{
|
||||
StaticAssert<(Percent <= 100)>::check();
|
||||
enum { Result = ((100U - Percent) * NumericallyMax) / 100U };
|
||||
StaticAssert<(Result <= NumericallyMax)>::check();
|
||||
StaticAssert<(Result >= NumericallyMin)>::check();
|
||||
return TransferPriority(Result);
|
||||
}
|
||||
|
||||
uint8_t get() const { return value_; }
|
||||
|
||||
bool isValid() const { return value_ < (1U << BitLen); }
|
||||
|
||||
Reference in New Issue
Block a user