mavlink: properly cleanup instance on exit

This commit is contained in:
Daniel Agar 2021-06-07 09:05:15 -04:00
parent 9f87702074
commit 328c5cb1cf
2 changed files with 7 additions and 1 deletions

View File

@ -147,6 +147,10 @@ Mavlink::~Mavlink()
} while (_task_running);
}
if (_instance_id >= 0) {
mavlink_module_instances[_instance_id] = nullptr;
}
perf_free(_loop_perf);
perf_free(_loop_interval_perf);
perf_free(_send_byte_error_perf);
@ -2546,6 +2550,8 @@ Mavlink::task_main(int argc, char *argv[])
pthread_mutex_destroy(&_send_mutex);
_task_running = false;
PX4_INFO("exiting channel %i", (int)_channel);
return OK;

View File

@ -529,7 +529,7 @@ public:
private:
MavlinkReceiver _receiver;
int _instance_id{0};
int _instance_id{-1};
bool _transmitting_enabled{true};
bool _transmitting_enabled_commanded{false};