Skip to content

Commit

Permalink
mavlink_passthrough: also test unregistering
Browse files Browse the repository at this point in the history
  • Loading branch information
julianoes committed May 8, 2019
1 parent 85e57ae commit 9e0bec3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions integration_tests/mavlink_passthrough.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,25 @@ TEST_F(SitlTest, MavlinkPassthrough)
std::promise<void> prom;
std::future<void> fut = prom.get_future();
unsigned counter = 0;
bool stopped = false;

mavlink_passthrough->subscribe_message_async(
MAVLINK_MSG_ID_HIGHRES_IMU, [&prom, &counter](const mavlink_message_t &message) {
MAVLINK_MSG_ID_HIGHRES_IMU,
[&prom, &counter, &stopped, mavlink_passthrough](const mavlink_message_t &message) {
mavlink_highres_imu_t highres_imu;
mavlink_msg_highres_imu_decode(&message, &highres_imu);

LogInfo() << "HIGHRES_IMU.temperature: " << highres_imu.temperature << " degrees C";
LogInfo() << "HIGHRES_IMU.temperature [1] (" << counter << ")"
<< highres_imu.temperature << " degrees C";
if (++counter > 100) {
prom.set_value();
EXPECT_FALSE(stopped);
if (!stopped) {
stopped = true;
// Unsubscribe again
mavlink_passthrough->subscribe_message_async(MAVLINK_MSG_ID_HIGHRES_IMU,
nullptr);
prom.set_value();
}
};
});

Expand Down

0 comments on commit 9e0bec3

Please sign in to comment.