mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 19:13:34 +08:00
parameter_update use uORB::Subscription consistently
This commit is contained in:
@@ -2141,9 +2141,9 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
pthread_mutex_init(&_message_buffer_mutex, nullptr);
|
||||
}
|
||||
|
||||
uORB::Subscription parameter_update_sub{ORB_ID(parameter_update)};
|
||||
|
||||
MavlinkOrbSubscription *cmd_sub = add_orb_subscription(ORB_ID(vehicle_command), 0, true);
|
||||
MavlinkOrbSubscription *param_sub = add_orb_subscription(ORB_ID(parameter_update));
|
||||
uint64_t param_time = 0;
|
||||
MavlinkOrbSubscription *status_sub = add_orb_subscription(ORB_ID(vehicle_status));
|
||||
uint64_t status_time = 0;
|
||||
MavlinkOrbSubscription *ack_sub = add_orb_subscription(ORB_ID(vehicle_command_ack), 0, true);
|
||||
@@ -2239,9 +2239,13 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
|
||||
update_rate_mult();
|
||||
|
||||
parameter_update_s param_update;
|
||||
// check for parameter updates
|
||||
if (parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
parameter_update_sub.copy(&pupdate);
|
||||
|
||||
if (param_sub->update(¶m_time, ¶m_update)) {
|
||||
// update parameters from storage
|
||||
mavlink_update_parameters();
|
||||
|
||||
#if defined(CONFIG_NET)
|
||||
@@ -2250,7 +2254,7 @@ Mavlink::task_main(int argc, char *argv[])
|
||||
_src_addr_initialized = false;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // CONFIG_NET
|
||||
}
|
||||
|
||||
check_radio_config();
|
||||
|
||||
@@ -2569,9 +2569,15 @@ MavlinkReceiver::Run()
|
||||
hrt_abstime last_send_update = 0;
|
||||
|
||||
while (!_mavlink->_task_should_exit) {
|
||||
// Check for updated parameters.
|
||||
if (_param_update_sub.updated()) {
|
||||
update_params();
|
||||
|
||||
// check for parameter updates
|
||||
if (_parameter_update_sub.updated()) {
|
||||
// clear update
|
||||
parameter_update_s pupdate;
|
||||
_parameter_update_sub.copy(&pupdate);
|
||||
|
||||
// update parameters from storage
|
||||
updateParams();
|
||||
}
|
||||
|
||||
if (poll(&fds[0], 1, timeout) > 0) {
|
||||
@@ -2718,11 +2724,3 @@ MavlinkReceiver::receive_start(pthread_t *thread, Mavlink *parent)
|
||||
|
||||
pthread_attr_destroy(&receiveloop_attr);
|
||||
}
|
||||
|
||||
void
|
||||
MavlinkReceiver::update_params()
|
||||
{
|
||||
parameter_update_s param_update;
|
||||
_param_update_sub.update(¶m_update);
|
||||
updateParams();
|
||||
}
|
||||
|
||||
@@ -259,7 +259,7 @@ private:
|
||||
// ORB subscriptions
|
||||
uORB::Subscription _actuator_armed_sub{ORB_ID(actuator_armed)};
|
||||
uORB::Subscription _control_mode_sub{ORB_ID(vehicle_control_mode)};
|
||||
uORB::Subscription _param_update_sub{ORB_ID(parameter_update)};
|
||||
uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};
|
||||
uORB::Subscription _vehicle_attitude_sub{ORB_ID(vehicle_attitude)};
|
||||
uORB::Subscription _vehicle_local_position_sub{ORB_ID(vehicle_local_position)};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user