mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 09:33:34 +08:00
mavlink: move thread handling into MavlinkReceiver
In my opinion this makes it much cleaner and will allow mavlink main to directly call the receiver.
This commit is contained in:
@@ -94,7 +94,8 @@ hrt_abstime Mavlink::_first_start_time = {0};
|
||||
bool Mavlink::_boot_complete = false;
|
||||
|
||||
Mavlink::Mavlink() :
|
||||
ModuleParams(nullptr)
|
||||
ModuleParams(nullptr),
|
||||
_receiver(this)
|
||||
{
|
||||
// initialise parameter cache
|
||||
mavlink_update_parameters();
|
||||
@@ -2229,8 +2230,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
send_autopilot_capabilities();
|
||||
}
|
||||
|
||||
/* start the MAVLink receiver last to avoid a race */
|
||||
MavlinkReceiver::receive_start(&_receive_thread, this);
|
||||
_receiver.start();
|
||||
|
||||
_mavlink_start_time = hrt_absolute_time();
|
||||
|
||||
@@ -2513,8 +2513,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
perf_end(_loop_perf);
|
||||
}
|
||||
|
||||
/* first wait for threads to complete before tearing down anything */
|
||||
pthread_join(_receive_thread, nullptr);
|
||||
_receiver.stop();
|
||||
|
||||
delete _subscribe_to_stream;
|
||||
_subscribe_to_stream = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user