mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-21 04:53:33 +08:00
uavcan_main: use parameter_update to check for param updates
this avoids calling param_get() on every loop iteration.
This commit is contained in:
@@ -58,6 +58,7 @@
|
|||||||
#include <arch/chip/chip.h>
|
#include <arch/chip/chip.h>
|
||||||
|
|
||||||
#include <uORB/topics/esc_status.h>
|
#include <uORB/topics/esc_status.h>
|
||||||
|
#include <uORB/topics/parameter_update.h>
|
||||||
|
|
||||||
#include <drivers/drv_hrt.h>
|
#include <drivers/drv_hrt.h>
|
||||||
#include <drivers/drv_pwm_output.h>
|
#include <drivers/drv_pwm_output.h>
|
||||||
@@ -419,16 +420,14 @@ int UavcanNode::get_param(int remote_node_id, const char *name)
|
|||||||
|
|
||||||
void UavcanNode::update_params()
|
void UavcanNode::update_params()
|
||||||
{
|
{
|
||||||
param_t param_handle;
|
// multicopter air-mode
|
||||||
|
param_t param_handle = param_find("MC_AIRMODE");
|
||||||
|
|
||||||
// multicopter air-mode
|
if (param_handle != PARAM_INVALID) {
|
||||||
param_handle = param_find("MC_AIRMODE");
|
int32_t val;
|
||||||
|
param_get(param_handle, &val);
|
||||||
if (param_handle != PARAM_INVALID) {
|
_airmode = val > 0;
|
||||||
int val;
|
}
|
||||||
param_get(param_handle, &val);
|
|
||||||
_airmode = val > 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int UavcanNode::start_fw_server()
|
int UavcanNode::start_fw_server()
|
||||||
@@ -828,9 +827,21 @@ int UavcanNode::run()
|
|||||||
_actuator_direct_poll_fd_num = add_poll_fd(_actuator_direct_sub);
|
_actuator_direct_poll_fd_num = add_poll_fd(_actuator_direct_sub);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
update_params();
|
||||||
|
|
||||||
|
int params_sub = orb_subscribe(ORB_ID(parameter_update));
|
||||||
|
|
||||||
while (!_task_should_exit) {
|
while (!_task_should_exit) {
|
||||||
|
|
||||||
update_params();
|
/* check for parameter updates */
|
||||||
|
bool param_updated = false;
|
||||||
|
orb_check(params_sub, ¶m_updated);
|
||||||
|
|
||||||
|
if (param_updated) {
|
||||||
|
struct parameter_update_s update;
|
||||||
|
orb_copy(ORB_ID(parameter_update), params_sub, &update);
|
||||||
|
update_params();
|
||||||
|
}
|
||||||
|
|
||||||
switch (_fw_server_action) {
|
switch (_fw_server_action) {
|
||||||
case Start:
|
case Start:
|
||||||
@@ -991,6 +1002,8 @@ int UavcanNode::run()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
orb_unsubscribe(params_sub);
|
||||||
|
|
||||||
(void)::close(busevent_fd);
|
(void)::close(busevent_fd);
|
||||||
|
|
||||||
teardown();
|
teardown();
|
||||||
|
|||||||
Reference in New Issue
Block a user