mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-04 04:00:34 +08:00
Fixed bug with fd leak in rc_calibration_check
This commit is contained in:
@@ -687,7 +687,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
|
||||
bool updated = false;
|
||||
|
||||
bool rc_calibration_ok = (OK == rc_calibration_check());
|
||||
bool rc_calibration_ok = (OK == rc_calibration_check(mavlink_fd));
|
||||
|
||||
/* Subscribe to safety topic */
|
||||
int safety_sub = orb_subscribe(ORB_ID(safety));
|
||||
@@ -802,7 +802,7 @@ int commander_thread_main(int argc, char *argv[])
|
||||
status_changed = true;
|
||||
|
||||
/* re-check RC calibration */
|
||||
rc_calibration_ok = (OK == rc_calibration_check());
|
||||
rc_calibration_ok = (OK == rc_calibration_check(mavlink_fd));
|
||||
|
||||
/* navigation parameters */
|
||||
param_get(_param_takeoff_alt, &takeoff_alt);
|
||||
|
||||
@@ -47,14 +47,12 @@
|
||||
#include <mavlink/mavlink_log.h>
|
||||
#include <uORB/topics/rc_channels.h>
|
||||
|
||||
int rc_calibration_check(void) {
|
||||
int rc_calibration_check(int mavlink_fd) {
|
||||
|
||||
char nbuf[20];
|
||||
param_t _parameter_handles_min, _parameter_handles_trim, _parameter_handles_max,
|
||||
_parameter_handles_rev, _parameter_handles_dz;
|
||||
|
||||
int mavlink_fd = open(MAVLINK_LOG_DEVICE, 0);
|
||||
|
||||
float param_min, param_max, param_trim, param_rev, param_dz;
|
||||
|
||||
/* first check channel mappings */
|
||||
|
||||
@@ -47,6 +47,6 @@
|
||||
* @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(void);
|
||||
__EXPORT int rc_calibration_check(int mavlink_fd);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
@@ -140,7 +140,7 @@ int preflight_check_main(int argc, char *argv[])
|
||||
|
||||
/* ---- RC CALIBRATION ---- */
|
||||
|
||||
bool rc_ok = (OK == rc_calibration_check());
|
||||
bool rc_ok = (OK == rc_calibration_check(mavlink_fd));
|
||||
|
||||
/* warn */
|
||||
if (!rc_ok)
|
||||
@@ -227,4 +227,4 @@ static int led_off(int leds, int led)
|
||||
static int led_on(int leds, int led)
|
||||
{
|
||||
return ioctl(leds, LED_ON, led);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user