From 29c5c25f4712a85cad9d9eecb880ac0708f20d61 Mon Sep 17 00:00:00 2001 From: Roman Date: Wed, 27 Apr 2016 21:40:07 +0200 Subject: [PATCH] fix bug in the logging app: - either sensor combined or the replay topic where copied into the union buffer but at times the memory was overwritten by other topics which updated below - this change makes sure that the two topics are copied into the union buffer at the correct location in the code --- src/modules/sdlog2/sdlog2.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/sdlog2/sdlog2.c b/src/modules/sdlog2/sdlog2.c index e6d8ba0082..6c762bae1a 100644 --- a/src/modules/sdlog2/sdlog2.c +++ b/src/modules/sdlog2/sdlog2.c @@ -1405,17 +1405,17 @@ int sdlog2_thread_main(int argc, char *argv[]) continue; } - // copy topic always - if (record_replay_log) { - orb_copy(ORB_ID(ekf2_replay), subs.replay_sub, &buf.replay); - } else { - orb_copy(ORB_ID(sensor_combined), subs.sensor_sub, &buf.sensor); - } if ((poll_counter + 1) % poll_to_logging_factor == 0) { + // the topic will be copied below poll_counter = 0; } else { - // copy topic + // copy topic here in order to reset the updated flag + if (record_replay_log) { + orb_copy(ORB_ID(ekf2_replay), subs.replay_sub, &buf.replay); + } else { + orb_copy(ORB_ID(sensor_combined), subs.sensor_sub, &buf.sensor); + } poll_counter++; continue; } @@ -1470,7 +1470,7 @@ int sdlog2_thread_main(int argc, char *argv[]) /* --- EKF2 REPLAY --- */ if(record_replay_log) { - // we poll on the replay topic so we know that it was updated + orb_copy(ORB_ID(ekf2_replay), subs.replay_sub, &buf.replay); log_msg.msg_type = LOG_RPL1_MSG; log_msg.body.log_RPL1.time_ref = buf.replay.time_ref; log_msg.body.log_RPL1.gyro_integral_dt = buf.replay.gyro_integral_dt; @@ -1531,7 +1531,7 @@ int sdlog2_thread_main(int argc, char *argv[]) } else { /* !record_replay_log */ - /* we poll on sensor combined, so we know it has updated just now */ + orb_copy(ORB_ID(sensor_combined), subs.sensor_sub, &buf.sensor); for (unsigned i = 0; i < 3; i++) { bool write_IMU = false; bool write_SENS = false;