mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-30 12:04:07 +08:00
Better name for anonymous transfers (automatic renaming)
This commit is contained in:
parent
042aa60773
commit
df2a38c217
@ -62,11 +62,11 @@ public:
|
||||
|
||||
/**
|
||||
* By default, attempt to send a transfer from passive mode will result in an error @ref ErrPassive.
|
||||
* This option allows to enable sending rogue transfers from passive mode.
|
||||
* This option allows to enable sending anonymous transfers from passive mode.
|
||||
*/
|
||||
void allowRogueTransfers()
|
||||
void allowAnonymousTransfers()
|
||||
{
|
||||
sender_->allowRogueTransfers();
|
||||
sender_->allowAnonymousTransfers();
|
||||
}
|
||||
|
||||
INode& getNode() const { return node_; }
|
||||
|
||||
@ -67,7 +67,7 @@ public:
|
||||
TransferID getTransferID() const { return safeget<TransferID, &IncomingTransfer::getTransferID>(); }
|
||||
NodeID getSrcNodeID() const { return safeget<NodeID, &IncomingTransfer::getSrcNodeID>(); }
|
||||
uint8_t getIfaceIndex() const { return safeget<uint8_t, &IncomingTransfer::getIfaceIndex>(); }
|
||||
bool isRogueTransfer() const { return safeget<bool, &IncomingTransfer::isRogueTransfer>(); }
|
||||
bool isAnonymousTransfer() const { return safeget<bool, &IncomingTransfer::isAnonymousTransfer>(); }
|
||||
};
|
||||
|
||||
/**
|
||||
@ -198,12 +198,12 @@ protected:
|
||||
}
|
||||
|
||||
/**
|
||||
* By default, rogue transfers will be ignored.
|
||||
* This option allows to enable reception of rogue transfers.
|
||||
* By default, anonymous transfers will be ignored.
|
||||
* This option allows to enable reception of anonymous transfers.
|
||||
*/
|
||||
void allowRogueTransfers()
|
||||
void allowAnonymousTransfers()
|
||||
{
|
||||
forwarder_->allowRogueTransfers();
|
||||
forwarder_->allowAnonymousTransfers();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -87,7 +87,7 @@ public:
|
||||
*/
|
||||
using BaseType::init;
|
||||
|
||||
using BaseType::allowRogueTransfers;
|
||||
using BaseType::allowAnonymousTransfers;
|
||||
using BaseType::getTransferSender;
|
||||
using BaseType::getMinTxTimeout;
|
||||
using BaseType::getMaxTxTimeout;
|
||||
|
||||
@ -111,7 +111,7 @@ public:
|
||||
return BaseType::startAsMessageListener();
|
||||
}
|
||||
|
||||
using BaseType::allowRogueTransfers;
|
||||
using BaseType::allowAnonymousTransfers;
|
||||
using BaseType::stop;
|
||||
using BaseType::getFailureCount;
|
||||
};
|
||||
|
||||
@ -51,9 +51,9 @@ public:
|
||||
virtual void release() { }
|
||||
|
||||
/**
|
||||
* Whether this is a rogue transfer
|
||||
* Whether this is a anonymous transfer
|
||||
*/
|
||||
virtual bool isRogueTransfer() const { return false; }
|
||||
virtual bool isAnonymousTransfer() const { return false; }
|
||||
|
||||
MonotonicTime getMonotonicTimestamp() const { return ts_mono_; }
|
||||
UtcTime getUtcTimestamp() const { return ts_utc_; }
|
||||
@ -73,7 +73,7 @@ class UAVCAN_EXPORT SingleFrameIncomingTransfer : public IncomingTransfer
|
||||
public:
|
||||
explicit SingleFrameIncomingTransfer(const RxFrame& frm);
|
||||
virtual int read(unsigned offset, uint8_t* data, unsigned len) const;
|
||||
virtual bool isRogueTransfer() const;
|
||||
virtual bool isAnonymousTransfer() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -99,7 +99,7 @@ class UAVCAN_EXPORT TransferListenerBase : public LinkedListNode<TransferListene
|
||||
MapBase<TransferBufferManagerKey, TransferReceiver>& receivers_;
|
||||
ITransferBufferManager& bufmgr_;
|
||||
TransferPerfCounter& perf_;
|
||||
bool allow_rogue_transfers_;
|
||||
bool allow_anonymous_transfers_;
|
||||
|
||||
class TimedOutReceiverPredicate
|
||||
{
|
||||
@ -126,13 +126,13 @@ protected:
|
||||
, receivers_(receivers)
|
||||
, bufmgr_(bufmgr)
|
||||
, perf_(perf)
|
||||
, allow_rogue_transfers_(false)
|
||||
, allow_anonymous_transfers_(false)
|
||||
{ }
|
||||
|
||||
virtual ~TransferListenerBase() { }
|
||||
|
||||
void handleReception(TransferReceiver& receiver, const RxFrame& frame, TransferBufferAccessor& tba);
|
||||
void handleRogueTransferReception(const RxFrame& frame);
|
||||
void handleAnonymousTransferReception(const RxFrame& frame);
|
||||
|
||||
virtual void handleIncomingTransfer(IncomingTransfer& transfer) = 0;
|
||||
|
||||
@ -140,10 +140,10 @@ public:
|
||||
const DataTypeDescriptor& getDataTypeDescriptor() const { return data_type_; }
|
||||
|
||||
/**
|
||||
* By default, rogue transfers will be ignored.
|
||||
* This option allows to enable reception of rogue transfers.
|
||||
* By default, anonymous transfers will be ignored.
|
||||
* This option allows to enable reception of anonymous transfers.
|
||||
*/
|
||||
void allowRogueTransfers() { allow_rogue_transfers_ = true; }
|
||||
void allowAnonymousTransfers() { allow_anonymous_transfers_ = true; }
|
||||
|
||||
void cleanup(MonotonicTime ts);
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ class UAVCAN_EXPORT TransferSender
|
||||
const TransferCRC crc_base_;
|
||||
CanIOFlags flags_;
|
||||
uint8_t iface_mask_;
|
||||
bool allow_rogue_transfers_;
|
||||
bool allow_anonymous_transfers_;
|
||||
|
||||
Dispatcher& dispatcher_;
|
||||
|
||||
@ -47,7 +47,7 @@ public:
|
||||
, crc_base_(data_type.getSignature().toTransferCRC())
|
||||
, flags_(CanIOFlags(0))
|
||||
, iface_mask_(AllIfacesMask)
|
||||
, allow_rogue_transfers_(false)
|
||||
, allow_anonymous_transfers_(false)
|
||||
, dispatcher_(dispatcher)
|
||||
{ }
|
||||
|
||||
@ -62,13 +62,13 @@ public:
|
||||
}
|
||||
|
||||
/**
|
||||
* Rogue transfers (i.e. transfers that don't carry a valid Source Node ID) can be sent if
|
||||
* Anonymous transfers (i.e. transfers that don't carry a valid Source Node ID) can be sent if
|
||||
* the local node is configured in passive mode (i.e. the node doesn't have a valid Node ID).
|
||||
* By default, this class will return an error if it is asked to send a transfer while the
|
||||
* node is configured in passive mode. However, if this option is enabled, it will be possible
|
||||
* to send rogue transfers from passive mode.
|
||||
* to send anonymous transfers from passive mode.
|
||||
*/
|
||||
void allowRogueTransfers() { allow_rogue_transfers_ = true; }
|
||||
void allowAnonymousTransfers() { allow_anonymous_transfers_ = true; }
|
||||
|
||||
/**
|
||||
* Send with explicit Transfer ID.
|
||||
|
||||
@ -31,7 +31,7 @@ void DynamicNodeIDAllocationClient::handleTimerEvent(const TimerEvent&)
|
||||
void DynamicNodeIDAllocationClient::handleDynamicNodeIDAllocation(
|
||||
const ReceivedDataStructure<protocol::DynamicNodeIDAllocation>& msg)
|
||||
{
|
||||
if ((msg.short_unique_id != short_unique_id_) || msg.isRogueTransfer())
|
||||
if ((msg.short_unique_id != short_unique_id_) || msg.isAnonymousTransfer())
|
||||
{
|
||||
return; // Not ours
|
||||
}
|
||||
@ -83,7 +83,7 @@ int DynamicNodeIDAllocationClient::startImpl()
|
||||
{
|
||||
return res;
|
||||
}
|
||||
dnida_pub_.allowRogueTransfers();
|
||||
dnida_pub_.allowAnonymousTransfers();
|
||||
|
||||
res = dnida_sub_.start(
|
||||
DynamicNodeIDAllocationCallback(this, &DynamicNodeIDAllocationClient::handleDynamicNodeIDAllocation));
|
||||
@ -91,7 +91,7 @@ int DynamicNodeIDAllocationClient::startImpl()
|
||||
{
|
||||
return res;
|
||||
}
|
||||
dnida_sub_.allowRogueTransfers();
|
||||
dnida_sub_.allowAnonymousTransfers();
|
||||
|
||||
startPeriodic(
|
||||
MonotonicDuration::fromMSec(protocol::DynamicNodeIDAllocation::ALLOCATEE_MIN_BROADCAST_INTERVAL_SEC * 1000));
|
||||
|
||||
@ -50,7 +50,7 @@ int SingleFrameIncomingTransfer::read(unsigned offset, uint8_t* data, unsigned l
|
||||
return int(len);
|
||||
}
|
||||
|
||||
bool SingleFrameIncomingTransfer::isRogueTransfer() const
|
||||
bool SingleFrameIncomingTransfer::isAnonymousTransfer() const
|
||||
{
|
||||
return (getTransferType() == TransferTypeMessageBroadcast) && getSrcNodeID().isBroadcast();
|
||||
}
|
||||
@ -177,9 +177,9 @@ void TransferListenerBase::handleReception(TransferReceiver& receiver, const RxF
|
||||
}
|
||||
}
|
||||
|
||||
void TransferListenerBase::handleRogueTransferReception(const RxFrame& frame)
|
||||
void TransferListenerBase::handleAnonymousTransferReception(const RxFrame& frame)
|
||||
{
|
||||
if (allow_rogue_transfers_)
|
||||
if (allow_anonymous_transfers_)
|
||||
{
|
||||
perf_.addRxTransfer();
|
||||
SingleFrameIncomingTransfer it(frame);
|
||||
@ -221,9 +221,9 @@ void TransferListenerBase::handleFrame(const RxFrame& frame)
|
||||
else if (frame.getSrcNodeID().isBroadcast() &&
|
||||
frame.isFirst() &&
|
||||
frame.isLast() &&
|
||||
frame.getDstNodeID().isBroadcast()) // Rogue transfer
|
||||
frame.getDstNodeID().isBroadcast()) // Anonymous transfer
|
||||
{
|
||||
handleRogueTransferReception(frame);
|
||||
handleAnonymousTransferReception(frame);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -30,11 +30,11 @@ int TransferSender::send(const uint8_t* payload, unsigned payload_len, Monotonic
|
||||
|
||||
/*
|
||||
* Checking if we're allowed to send.
|
||||
* In passive mode we can send only rogue transfers, if they are enabled.
|
||||
* In passive mode we can send only anonymous transfers, if they are enabled.
|
||||
*/
|
||||
if (dispatcher_.isPassiveMode())
|
||||
{
|
||||
const bool allow = allow_rogue_transfers_ &&
|
||||
const bool allow = allow_anonymous_transfers_ &&
|
||||
(transfer_type == TransferTypeMessageBroadcast) &&
|
||||
(int(payload_len) <= frame.getMaxPayloadLen());
|
||||
if (!allow)
|
||||
|
||||
@ -54,11 +54,11 @@ TEST(DynamicNodeIDAllocationClient, Basic)
|
||||
|
||||
/*
|
||||
* Initializing subscriber
|
||||
* Rogue transfers must be enabled
|
||||
* Anonymous transfers must be enabled
|
||||
*/
|
||||
SubscriberWithCollector<uavcan::protocol::DynamicNodeIDAllocation> dynid_sub(nodes.a);
|
||||
ASSERT_LE(0, dynid_sub.start());
|
||||
dynid_sub.subscriber.allowRogueTransfers();
|
||||
dynid_sub.subscriber.allowAnonymousTransfers();
|
||||
|
||||
/*
|
||||
* Monitoring requests at 1Hz
|
||||
@ -86,7 +86,7 @@ TEST(DynamicNodeIDAllocationClient, Basic)
|
||||
|
||||
/*
|
||||
* Sending a bunch of responses
|
||||
* Note that response transfers are NOT rogue
|
||||
* Note that response transfers are NOT anonymous
|
||||
*/
|
||||
uavcan::Publisher<uavcan::protocol::DynamicNodeIDAllocation> dynid_pub(nodes.a);
|
||||
ASSERT_LE(0, dynid_pub.init());
|
||||
|
||||
@ -245,7 +245,7 @@ TEST(TransferListener, MaximumTransferLength)
|
||||
}
|
||||
|
||||
|
||||
TEST(TransferListener, RogueTransfers)
|
||||
TEST(TransferListener, AnonymousTransfers)
|
||||
{
|
||||
const uavcan::DataTypeDescriptor type(uavcan::DataTypeKindMessage, 123, uavcan::DataTypeSignature(123456789), "A");
|
||||
|
||||
@ -264,15 +264,15 @@ TEST(TransferListener, RogueTransfers)
|
||||
|
||||
emulator.send(transfers);
|
||||
|
||||
// Nothing will be received, because rogue transfers are disabled by default
|
||||
// Nothing will be received, because anonymous transfers are disabled by default
|
||||
ASSERT_TRUE(subscriber.isEmpty());
|
||||
|
||||
subscriber.allowRogueTransfers();
|
||||
subscriber.allowAnonymousTransfers();
|
||||
|
||||
// Re-send everything again
|
||||
emulator.send(transfers);
|
||||
|
||||
// Now the rogue transfers are enabled
|
||||
// Now the anonymous transfers are enabled
|
||||
ASSERT_TRUE(subscriber.matchAndPop(transfers[1])); // Only SFT broadcast will be accepted
|
||||
ASSERT_TRUE(subscriber.matchAndPop(transfers[3]));
|
||||
|
||||
|
||||
@ -241,7 +241,7 @@ TEST(TransferSender, PassiveMode)
|
||||
uavcan::TransferTypeMessageBroadcast, uavcan::NodeID::Broadcast));
|
||||
|
||||
// Overriding the default
|
||||
sender.allowRogueTransfers();
|
||||
sender.allowAnonymousTransfers();
|
||||
|
||||
// OK, now we can broadcast in any mode
|
||||
ASSERT_LE(0, sender.send(Payload, sizeof(Payload), tsMono(1000), uavcan::MonotonicTime(),
|
||||
|
||||
@ -132,11 +132,11 @@ public:
|
||||
|
||||
const bool single_frame = dynamic_cast<uavcan::SingleFrameIncomingTransfer*>(&transfer) != NULL;
|
||||
|
||||
const bool rogue = single_frame &&
|
||||
transfer.getSrcNodeID().isBroadcast() &&
|
||||
(transfer.getTransferType() == uavcan::TransferTypeMessageBroadcast);
|
||||
const bool anonymous = single_frame &&
|
||||
transfer.getSrcNodeID().isBroadcast() &&
|
||||
(transfer.getTransferType() == uavcan::TransferTypeMessageBroadcast);
|
||||
|
||||
ASSERT_EQ(rogue, transfer.isRogueTransfer());
|
||||
ASSERT_EQ(anonymous, transfer.isAnonymousTransfer());
|
||||
}
|
||||
|
||||
bool matchAndPop(const Transfer& reference)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user