Naming: TransferSender::allowRogueTransfers()

This commit is contained in:
Pavel Kirienko
2015-04-06 19:11:21 +03:00
parent de33cf9250
commit 7aa30e9cdc
3 changed files with 12 additions and 12 deletions
@@ -25,7 +25,7 @@ class UAVCAN_EXPORT TransferSender
const TransferCRC crc_base_; const TransferCRC crc_base_;
CanIOFlags flags_; CanIOFlags flags_;
uint8_t iface_mask_; uint8_t iface_mask_;
bool allow_broadcasting_in_passive_mode_; bool allow_rogue_transfers_;
Dispatcher& dispatcher_; Dispatcher& dispatcher_;
@@ -47,7 +47,7 @@ public:
, crc_base_(data_type.getSignature().toTransferCRC()) , crc_base_(data_type.getSignature().toTransferCRC())
, flags_(CanIOFlags(0)) , flags_(CanIOFlags(0))
, iface_mask_(AllIfacesMask) , iface_mask_(AllIfacesMask)
, allow_broadcasting_in_passive_mode_(false) , allow_rogue_transfers_(false)
, dispatcher_(dispatcher) , dispatcher_(dispatcher)
{ } { }
@@ -62,11 +62,13 @@ public:
} }
/** /**
* By default, this class will return an error on any attempt to publish a message while the * Rogue transfers (i.e. transfers that don't carry a valid Source Node ID) can be sent if
* dispatcher is configured in passive mode. This method allows to permanently enable sending * the local node is configured in passive mode (i.e. the node doesn't have a valid Node ID).
* broadcast transfers in passive mode for this class instance. * 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.
*/ */
void allowBroadcastingInPassiveMode() { allow_broadcasting_in_passive_mode_ = true; } void allowRogueTransfers() { allow_rogue_transfers_ = true; }
/** /**
* Send with explicit Transfer ID. * Send with explicit Transfer ID.
@@ -29,14 +29,12 @@ int TransferSender::send(const uint8_t* payload, unsigned payload_len, Monotonic
UAVCAN_TRACE("TransferSender", "%s", frame.toString().c_str()); UAVCAN_TRACE("TransferSender", "%s", frame.toString().c_str());
/* /*
* Checking if we're allowed to send. In passive mode we can send only if: * Checking if we're allowed to send.
* - Passive broadcasting is enabled * In passive mode we can send only rogue transfers, if they are enabled.
* - Transfer type is broadcast
* - Transfer payload fits one CAN frame
*/ */
if (dispatcher_.isPassiveMode()) if (dispatcher_.isPassiveMode())
{ {
const bool allow = allow_broadcasting_in_passive_mode_ && const bool allow = allow_rogue_transfers_ &&
(transfer_type == TransferTypeMessageBroadcast) && (transfer_type == TransferTypeMessageBroadcast) &&
(int(payload_len) <= frame.getMaxPayloadLen()); (int(payload_len) <= frame.getMaxPayloadLen());
if (!allow) if (!allow)
+1 -1
View File
@@ -241,7 +241,7 @@ TEST(TransferSender, PassiveMode)
uavcan::TransferTypeMessageBroadcast, uavcan::NodeID::Broadcast)); uavcan::TransferTypeMessageBroadcast, uavcan::NodeID::Broadcast));
// Overriding the default // Overriding the default
sender.allowBroadcastingInPassiveMode(); sender.allowRogueTransfers();
// OK, now we can broadcast in any mode // OK, now we can broadcast in any mode
ASSERT_LE(0, sender.send(Payload, sizeof(Payload), tsMono(1000), uavcan::MonotonicTime(), ASSERT_LE(0, sender.send(Payload, sizeof(Payload), tsMono(1000), uavcan::MonotonicTime(),