Merge branch 'dynamic_node_id'

This commit is contained in:
Pavel Kirienko
2015-04-26 07:51:05 +03:00
27 changed files with 707 additions and 24 deletions
@@ -115,6 +115,7 @@ public:
: canio_(driver, allocator, sysclock)
, sysclock_(sysclock)
, outgoing_transfer_reg_(otr)
, self_node_id_(NodeID::Broadcast) // Default
, self_node_id_is_set_(false)
{ }
+1 -1
View File
@@ -50,7 +50,7 @@ public:
{
UAVCAN_ASSERT((transfer_type == TransferTypeMessageBroadcast) == dst_node_id.isBroadcast());
UAVCAN_ASSERT(data_type_id.isValid());
UAVCAN_ASSERT(src_node_id != dst_node_id);
UAVCAN_ASSERT(src_node_id.isUnicast() ? (src_node_id != dst_node_id) : true);
UAVCAN_ASSERT(frame_index <= MaxIndex);
}
@@ -50,6 +50,11 @@ public:
*/
virtual void release() { }
/**
* Whether this is a anonymous transfer
*/
virtual bool isAnonymousTransfer() const { return false; }
MonotonicTime getMonotonicTimestamp() const { return ts_mono_; }
UtcTime getUtcTimestamp() const { return ts_utc_; }
TransferType getTransferType() const { return transfer_type_; }
@@ -68,6 +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 isAnonymousTransfer() const;
};
/**
@@ -93,6 +99,7 @@ class UAVCAN_EXPORT TransferListenerBase : public LinkedListNode<TransferListene
MapBase<TransferBufferManagerKey, TransferReceiver>& receivers_;
ITransferBufferManager& bufmgr_;
TransferPerfCounter& perf_;
bool allow_anonymous_transfers_;
class TimedOutReceiverPredicate
{
@@ -119,17 +126,25 @@ protected:
, receivers_(receivers)
, bufmgr_(bufmgr)
, perf_(perf)
, allow_anonymous_transfers_(false)
{ }
virtual ~TransferListenerBase() { }
void handleReception(TransferReceiver& receiver, const RxFrame& frame, TransferBufferAccessor& tba);
void handleAnonymousTransferReception(const RxFrame& frame);
virtual void handleIncomingTransfer(IncomingTransfer& transfer) = 0;
public:
const DataTypeDescriptor& getDataTypeDescriptor() const { return data_type_; }
/**
* By default, anonymous transfers will be ignored.
* This option allows to enable reception of anonymous transfers.
*/
void allowAnonymousTransfers() { allow_anonymous_transfers_ = true; }
void cleanup(MonotonicTime ts);
virtual void handleFrame(const RxFrame& frame);
@@ -25,6 +25,7 @@ class UAVCAN_EXPORT TransferSender
const TransferCRC crc_base_;
CanIOFlags flags_;
uint8_t iface_mask_;
bool allow_anonymous_transfers_;
Dispatcher& dispatcher_;
@@ -46,6 +47,7 @@ public:
, crc_base_(data_type.getSignature().toTransferCRC())
, flags_(CanIOFlags(0))
, iface_mask_(AllIfacesMask)
, allow_anonymous_transfers_(false)
, dispatcher_(dispatcher)
{ }
@@ -59,6 +61,15 @@ public:
iface_mask_ = iface_mask;
}
/**
* 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 anonymous transfers from passive mode.
*/
void allowAnonymousTransfers() { allow_anonymous_transfers_ = true; }
/**
* Send with explicit Transfer ID.
* Should be used only for service responses, where response TID should match request TID.