From 3399ec9e7379b858c899d8e415eb8c421bbbce86 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Mon, 11 Jun 2018 11:45:22 -0400 Subject: [PATCH] move systemlib/rc_check to commander (the only usage) and convert to c++ --- src/modules/commander/CMakeLists.txt | 21 ++++++++++--------- src/modules/commander/PreflightCheck.cpp | 11 +--------- src/modules/commander/commander.cpp | 2 -- .../rc_check.c => commander/rc_check.cpp} | 13 ++++++------ .../{systemlib => commander}/rc_check.h | 7 +------ src/modules/systemlib/CMakeLists.txt | 1 - 6 files changed, 20 insertions(+), 35 deletions(-) rename src/modules/{systemlib/rc_check.c => commander/rc_check.cpp} (97%) rename src/modules/{systemlib => commander}/rc_check.h (93%) diff --git a/src/modules/commander/CMakeLists.txt b/src/modules/commander/CMakeLists.txt index f3e6412790..8c70eca7c0 100644 --- a/src/modules/commander/CMakeLists.txt +++ b/src/modules/commander/CMakeLists.txt @@ -38,20 +38,21 @@ px4_add_module( COMPILE_FLAGS -Wno-sign-compare # TODO: fix all sign-compare SRCS - commander.cpp - state_machine_helper.cpp - commander_helper.cpp - calibration_routines.cpp accelerometer_calibration.cpp - gyro_calibration.cpp - mag_calibration.cpp - baro_calibration.cpp - rc_calibration.cpp airspeed_calibration.cpp - esc_calibration.cpp - PreflightCheck.cpp arm_auth.cpp + baro_calibration.cpp + calibration_routines.cpp + commander.cpp + commander_helper.cpp + esc_calibration.cpp + gyro_calibration.cpp health_flag_helper.cpp + mag_calibration.cpp + PreflightCheck.cpp + rc_calibration.cpp + rc_check.cpp + state_machine_helper.cpp DEPENDS df_driver_framework git_ecl diff --git a/src/modules/commander/PreflightCheck.cpp b/src/modules/commander/PreflightCheck.cpp index 9ad055b1c9..0f17108783 100644 --- a/src/modules/commander/PreflightCheck.cpp +++ b/src/modules/commander/PreflightCheck.cpp @@ -42,18 +42,8 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include #include #include @@ -73,6 +63,7 @@ #include "PreflightCheck.h" #include "health_flag_helper.h" +#include "rc_check.h" #include "DevMgr.hpp" diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index 5ec49c26f4..fe4f47dd36 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -78,8 +78,6 @@ #include #include #include -#include -#include #include #include diff --git a/src/modules/systemlib/rc_check.c b/src/modules/commander/rc_check.cpp similarity index 97% rename from src/modules/systemlib/rc_check.c rename to src/modules/commander/rc_check.cpp index f6f25cce8c..31c164874e 100644 --- a/src/modules/systemlib/rc_check.c +++ b/src/modules/commander/rc_check.cpp @@ -37,6 +37,8 @@ * RC calibration check */ +#include "rc_check.h" + #include #include @@ -45,7 +47,7 @@ #include #include -#include + #include #include #include @@ -54,7 +56,6 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool isVTOL) { - char nbuf[20]; param_t _parameter_handles_min, _parameter_handles_trim, _parameter_handles_max, _parameter_handles_rev, _parameter_handles_dz; @@ -63,7 +64,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i const char *rc_map_mandatory[] = { /*"RC_MAP_MODE_SW",*/ /* needs discussion if this should be mandatory "RC_MAP_POSCTL_SW"*/ - 0 /* end marker */ + nullptr /* end marker */ }; unsigned j = 0; @@ -93,7 +94,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i /* first check channel mappings */ - while (rc_map_mandatory[j] != 0) { + while (rc_map_mandatory[j] != nullptr) { param_t map_parm = param_find(rc_map_mandatory[j]); @@ -110,7 +111,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i int32_t mapping; param_get(map_parm, &mapping); - if (mapping > RC_INPUT_MAX_CHANNELS) { + if (mapping > input_rc_s::RC_INPUT_MAX_CHANNELS) { if (report_fail) { mavlink_log_critical(mavlink_log_pub, "RC ERROR: %s >= NUMBER OF CHANNELS.", rc_map_mandatory[j]); } /* give system time to flush error message in case there are more */ @@ -132,7 +133,7 @@ int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool i unsigned total_fail_count = 0; unsigned channels_failed = 0; - for (unsigned i = 0; i < RC_INPUT_MAX_CHANNELS; i++) { + for (unsigned i = 0; i < input_rc_s::RC_INPUT_MAX_CHANNELS; i++) { /* should the channel be enabled? */ uint8_t count = 0; diff --git a/src/modules/systemlib/rc_check.h b/src/modules/commander/rc_check.h similarity index 93% rename from src/modules/systemlib/rc_check.h rename to src/modules/commander/rc_check.h index 3893baa8d0..c878f9c130 100644 --- a/src/modules/systemlib/rc_check.h +++ b/src/modules/commander/rc_check.h @@ -36,19 +36,14 @@ * * RC calibration check */ -#include #include #pragma once -__BEGIN_DECLS - /** * Check the RC calibration * * @return 0 / OK if RC calibration is ok, index + 1 of the first * channel that failed else (so 1 == first channel failed) */ -__EXPORT int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool isVTOL); - -__END_DECLS +int rc_calibration_check(orb_advert_t *mavlink_log_pub, bool report_fail, bool isVTOL); diff --git a/src/modules/systemlib/CMakeLists.txt b/src/modules/systemlib/CMakeLists.txt index 675cdeb4de..f1e516d48e 100644 --- a/src/modules/systemlib/CMakeLists.txt +++ b/src/modules/systemlib/CMakeLists.txt @@ -43,7 +43,6 @@ set(SRCS otp.c pid/pid.c pwm_limit/pwm_limit.c - rc_check.c ) if(${OS} STREQUAL "nuttx")