diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-08 12:45:43 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2015-01-08 12:45:43 +0100 |
commit | aa2a00b56a0be0e20abfa54c311575f9e055f212 (patch) | |
tree | 7c13065632d45486c31eee5c08b8de58c36335fc /src | |
parent | 1df7939072f87a5f3f3cc05ff57f545db7c144ad (diff) | |
parent | e405fafe882c95345ccf88ea5f372f353aa4c21f (diff) | |
download | px4-firmware-aa2a00b56a0be0e20abfa54c311575f9e055f212.tar.gz px4-firmware-aa2a00b56a0be0e20abfa54c311575f9e055f212.tar.bz2 px4-firmware-aa2a00b56a0be0e20abfa54c311575f9e055f212.zip |
Merge branch 'MixerNaming' of github.com:anton-matosov/Firmware
Diffstat (limited to 'src')
-rw-r--r-- | src/drivers/px4fmu/fmu.cpp | 20 | ||||
-rw-r--r-- | src/systemcmds/tests/test_mixer.cpp | 2 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index 3d3e1b0eb..436672040 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -128,7 +128,7 @@ private: orb_advert_t _outputs_pub; actuator_armed_s _armed; unsigned _num_outputs; - bool _primary_pwm_device; + int _class_instance; volatile bool _task_should_exit; bool _servo_armed; @@ -141,6 +141,7 @@ private: int _control_subs[NUM_ACTUATOR_CONTROL_GROUPS]; actuator_controls_s _controls[NUM_ACTUATOR_CONTROL_GROUPS]; orb_id_t _control_topics[NUM_ACTUATOR_CONTROL_GROUPS]; + orb_id_t _actuator_output_topic; pollfd _poll_fds[NUM_ACTUATOR_CONTROL_GROUPS]; unsigned _poll_fds_num; @@ -247,7 +248,7 @@ PX4FMU::PX4FMU() : _outputs_pub(-1), _armed{}, _num_outputs(0), - _primary_pwm_device(false), + _class_instance(0), _task_should_exit(false), _servo_armed(false), _pwm_on(false), @@ -255,6 +256,7 @@ PX4FMU::PX4FMU() : _groups_required(0), _groups_subscribed(0), _control_subs{-1}, + _actuator_output_topic(nullptr), _poll_fds_num(0), _pwm_limit{}, _failsafe_pwm{0}, @@ -300,8 +302,7 @@ PX4FMU::~PX4FMU() } /* clean up the alternate device node */ - if (_primary_pwm_device) - unregister_driver(PWM_OUTPUT_DEVICE_PATH); + unregister_class_devname(PWM_OUTPUT_DEVICE_PATH, _class_instance); g_fmu = nullptr; } @@ -320,13 +321,14 @@ PX4FMU::init() return ret; /* try to claim the generic PWM output device node as well - it's OK if we fail at this */ - ret = register_driver(PWM_OUTPUT_DEVICE_PATH, &fops, 0666, (void *)this); + _class_instance = register_class_devname(PWM_OUTPUT_DEVICE_PATH); - if (ret == OK) { + if (_class_instance == CLASS_DEVICE_PRIMARY) { log("default PWM output device"); - _primary_pwm_device = true; } + _actuator_output_topic = ORB_ID_DOUBLE(actuator_outputs_, _class_instance); + /* reset GPIOs */ gpio_reset(); @@ -677,10 +679,10 @@ PX4FMU::task_main() /* publish mixed control outputs */ if (_outputs_pub < 0) { - _outputs_pub = orb_advertise(_primary_pwm_device ? ORB_ID_VEHICLE_CONTROLS : ORB_ID(actuator_outputs_1), &outputs); + _outputs_pub = orb_advertise(_actuator_output_topic, &outputs); } else { - orb_publish(_primary_pwm_device ? ORB_ID_VEHICLE_CONTROLS : ORB_ID(actuator_outputs_1), _outputs_pub, &outputs); + orb_publish(_actuator_output_topic, _outputs_pub, &outputs); } } } diff --git a/src/systemcmds/tests/test_mixer.cpp b/src/systemcmds/tests/test_mixer.cpp index 8ab8fa2d6..2896a8e40 100644 --- a/src/systemcmds/tests/test_mixer.cpp +++ b/src/systemcmds/tests/test_mixer.cpp @@ -343,7 +343,7 @@ int test_mixer(int argc, char *argv[]) if (argc > 2) filename = argv[2]; else - filename = "/etc/mixers/FMU_quad_w.mix"; + filename = "/etc/mixers/quad_w.main.mix"; load_mixer_file(filename, &buf[0], sizeof(buf)); loaded = strlen(buf); |