Skip to content

Commit

Permalink
Merge pull request #8 from tiiuae/fix_memory_corruption
Browse files Browse the repository at this point in the history
fixed memorry corruption
  • Loading branch information
Ilia-Loginov authored Jun 24, 2024
2 parents 02fd3d4 + 03d7aa1 commit f2da227
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
26 changes: 13 additions & 13 deletions include/mavlink_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class MavlinkInterface {
struct pollfd fds_[N_FDS];
bool use_tcp_{false};
bool tcp_client_mode_{false};
bool close_conn_{false};
std::atomic<bool> close_conn_{false};

in_addr_t mavlink_addr_;
std::string mavlink_addr_str_{"INADDR_ANY"};
Expand Down Expand Up @@ -230,18 +230,18 @@ class MavlinkInterface {
std::atomic<bool> tx_in_progress_;
std::deque<MsgBuffer> tx_q_{};

bool baro_updated_;
bool diff_press_updated_;
bool mag_updated_;
bool imu_updated_;

double temperature_;
double pressure_alt_;
double abs_pressure_;
double diff_pressure_;
Eigen::Vector3d mag_b_;
Eigen::Vector3d accel_b_;
Eigen::Vector3d gyro_b_;
bool baro_updated_{};
bool diff_press_updated_{};
bool mag_updated_{};
bool imu_updated_{};

double temperature_{};
double pressure_alt_{};
double abs_pressure_{};
double diff_pressure_{};
Eigen::Vector3d mag_b_{};
Eigen::Vector3d accel_b_{};
Eigen::Vector3d gyro_b_{};

//std::vector<HILData, Eigen::aligned_allocator<HILData>> hil_data_;
std::atomic<bool> gotSigInt_ {false};
Expand Down
10 changes: 6 additions & 4 deletions src/mavlink_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void MavlinkInterface::ReceiveWorker() {
}
}
}
std::cout << "[" << thrd_name << "] shutdown" << std::endl;
std::cout << "The thread [" << thrd_name << "] was shutdown." << std::endl;

}

Expand Down Expand Up @@ -264,8 +264,10 @@ void MavlinkInterface::SendWorker() {
return close_conn_ || gotSigInt_ || !sender_buffer_.empty();
});

std::shared_ptr<mavlink_message_t> msg;
msg = sender_buffer_.front();
if (sender_buffer_.empty())
continue;

auto msg = sender_buffer_.front();
if (msg) {
sender_buffer_.pop();
lock.unlock();
Expand All @@ -275,7 +277,7 @@ void MavlinkInterface::SendWorker() {
}
}

std::cout << "[" << thrd_name << "] Shutdown.." << std::endl;
std::cout << "The thread [" << thrd_name << "] was shutdown." << std::endl;
}

void MavlinkInterface::SendSensorMessages(uint64_t time_usec) {
Expand Down

0 comments on commit f2da227

Please sign in to comment.