mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 07:03:33 +08:00
TransferSender is now capable of broadcasting in passive mode; Frame::isValid() was modified to accept SFT broadcasts with zero SNID
This commit is contained in:
@@ -162,7 +162,18 @@ TEST(Frame, FrameParsing)
|
||||
|
||||
can.id = CanFrame::FlagEFF | // cppcheck-suppress duplicateExpression
|
||||
(2 << 0) | (1 << 3) | (0 << 4) | (0 << 10) | (uavcan::TransferTypeMessageUnicast << 17) | (456 << 19);
|
||||
ASSERT_FALSE(frame.parse(can)); // Broadcast Src Node ID
|
||||
ASSERT_FALSE(frame.parse(can)); // Broadcast Src Node ID with unicast transfer
|
||||
|
||||
can.id = CanFrame::FlagEFF | // cppcheck-suppress duplicateExpression
|
||||
(2 << 0) | (0 << 3) | (0 << 4) | (0 << 10) | (uavcan::TransferTypeMessageBroadcast << 17) | (456 << 19);
|
||||
ASSERT_FALSE(frame.parse(can)); // Broadcast Src Node ID with multiframe broadcast transfer
|
||||
|
||||
/*
|
||||
* Broadcast SNID exceptions
|
||||
*/
|
||||
can.id = CanFrame::FlagEFF | // cppcheck-suppress duplicateExpression
|
||||
(2 << 0) | (1 << 3) | (0 << 4) | (0 << 10) | (uavcan::TransferTypeMessageBroadcast << 17) | (456 << 19);
|
||||
ASSERT_TRUE(frame.parse(can)); // Broadcast Src Node ID with single frame broadcast transfer
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -235,11 +235,24 @@ TEST(TransferSender, PassiveMode)
|
||||
|
||||
static const uint8_t Payload[] = {1, 2, 3, 4, 5};
|
||||
|
||||
// By default, sending in passive mode is not enabled
|
||||
ASSERT_EQ(-uavcan::ErrPassiveMode,
|
||||
sender.send(Payload, sizeof(Payload), tsMono(1000), uavcan::MonotonicTime(),
|
||||
uavcan::TransferTypeMessageBroadcast, uavcan::NodeID::Broadcast));
|
||||
|
||||
// Overriding the default
|
||||
sender.allowBroadcastingInPassiveMode();
|
||||
|
||||
// OK, now we can broadcast in any mode
|
||||
ASSERT_LE(0, sender.send(Payload, sizeof(Payload), tsMono(1000), uavcan::MonotonicTime(),
|
||||
uavcan::TransferTypeMessageBroadcast, uavcan::NodeID::Broadcast));
|
||||
|
||||
// ...but not unicast or anything else
|
||||
ASSERT_EQ(-uavcan::ErrPassiveMode,
|
||||
sender.send(Payload, sizeof(Payload), tsMono(1000), uavcan::MonotonicTime(),
|
||||
uavcan::TransferTypeMessageUnicast, uavcan::NodeID(42)));
|
||||
|
||||
EXPECT_EQ(0, dispatcher.getTransferPerfCounter().getErrorCount());
|
||||
EXPECT_EQ(0, dispatcher.getTransferPerfCounter().getTxTransferCount());
|
||||
EXPECT_EQ(1, dispatcher.getTransferPerfCounter().getTxTransferCount());
|
||||
EXPECT_EQ(0, dispatcher.getTransferPerfCounter().getRxTransferCount());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user