From af118a3568f2d63219bf97c999912babda588f8c Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sat, 21 Sep 2013 17:32:07 +0200 Subject: [PATCH 1/2] Add esc_calib systemcmd to FMUv2 --- makefiles/config_px4fmu-v2_default.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/makefiles/config_px4fmu-v2_default.mk b/makefiles/config_px4fmu-v2_default.mk index ba0beec3e1..ca99f84ccf 100644 --- a/makefiles/config_px4fmu-v2_default.mk +++ b/makefiles/config_px4fmu-v2_default.mk @@ -51,6 +51,7 @@ MODULES += systemcmds/param MODULES += systemcmds/perf MODULES += systemcmds/preflight_check MODULES += systemcmds/pwm +MODULES += systemcmds/esc_calib MODULES += systemcmds/reboot MODULES += systemcmds/top MODULES += systemcmds/tests From 30b151b9a83eed7b41243b31a1ebaf37ee663171 Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Sun, 22 Sep 2013 16:27:52 +0200 Subject: [PATCH 2/2] Improved esc_calib a little, only works on nsh over USB now --- src/systemcmds/esc_calib/esc_calib.c | 56 ++++++++++++---------------- 1 file changed, 23 insertions(+), 33 deletions(-) diff --git a/src/systemcmds/esc_calib/esc_calib.c b/src/systemcmds/esc_calib/esc_calib.c index 188fa4e371..0d74218422 100644 --- a/src/systemcmds/esc_calib/esc_calib.c +++ b/src/systemcmds/esc_calib/esc_calib.c @@ -1,6 +1,7 @@ /**************************************************************************** * * Copyright (C) 2013 PX4 Development Team. All rights reserved. + * Author: Julian Oes * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -63,7 +64,7 @@ static void usage(const char *reason); __EXPORT int esc_calib_main(int argc, char *argv[]); -#define MAX_CHANNELS 8 +#define MAX_CHANNELS 14 static void usage(const char *reason) @@ -97,7 +98,7 @@ esc_calib_main(int argc, char *argv[]) case 'd': dev = optarg; - argc--; + argc=-2; break; default: @@ -124,15 +125,18 @@ esc_calib_main(int argc, char *argv[]) } /* Wait for confirmation */ - int console = open("/dev/console", O_NONBLOCK | O_RDONLY | O_NOCTTY); + int console = open("/dev/ttyACM0", O_NONBLOCK | O_RDONLY | O_NOCTTY); if (!console) err(1, "failed opening console"); - warnx("ATTENTION, please remove or fix props before starting calibration!\n" + printf("\nATTENTION, please remove or fix propellers before starting calibration!\n" "\n" - "Also press the arming switch first for safety off\n" + "Make sure\n" + "\t - that the ESCs are not powered\n" + "\t - that safety is off (two short blinks)\n" + "\t - that the controllers are stopped\n" "\n" - "Do you really want to start calibration: y or n?\n"); + "Do you want to start calibration now: y or n?\n"); /* wait for user input */ while (1) { @@ -142,15 +146,15 @@ esc_calib_main(int argc, char *argv[]) break; } else if (c == 0x03 || c == 0x63 || c == 'q') { - warnx("ESC calibration exited"); + printf("ESC calibration exited\n"); close(console); exit(0); } else if (c == 'n' || c == 'N') { - warnx("ESC calibration aborted"); + printf("ESC calibration aborted\n"); close(console); exit(0); } else { - warnx("Unknown input, ESC calibration aborted"); + printf("Unknown input, ESC calibration aborted\n"); close(console); exit(0); } @@ -163,23 +167,14 @@ esc_calib_main(int argc, char *argv[]) int fd = open(dev, 0); if (fd < 0) err(1, "can't open %s", dev); - - // XXX arming not necessaire at the moment - // /* Then arm */ - // ret = ioctl(fd, PWM_SERVO_SET_ARM_OK, 0); - // if (ret != OK) - // err(1, "PWM_SERVO_SET_ARM_OK"); - - // ret = ioctl(fd, PWM_SERVO_ARM, 0); - // if (ret != OK) - // err(1, "PWM_SERVO_ARM"); - - /* Wait for user confirmation */ - warnx("Set high PWM\n" - "Connect battery now and hit ENTER after the ESCs confirm the first calibration step"); + printf("\nHigh PWM set\n" + "\n" + "Connect battery now and hit ENTER after the ESCs confirm the first calibration step\n" + "\n"); + fflush(stdout); while (1) { @@ -209,7 +204,8 @@ esc_calib_main(int argc, char *argv[]) /* we don't need any more user input */ - warnx("Set low PWM, hit ENTER when finished"); + printf("Low PWM set, hit ENTER when finished\n" + "\n"); while (1) { @@ -227,7 +223,7 @@ esc_calib_main(int argc, char *argv[]) break; } else if (c == 0x03 || c == 0x63 || c == 'q') { - warnx("ESC calibration exited"); + printf("ESC calibration exited\n"); close(console); exit(0); } @@ -237,14 +233,8 @@ esc_calib_main(int argc, char *argv[]) } - warnx("ESC calibration finished"); + printf("ESC calibration finished\n"); close(console); - // XXX disarming not necessaire at the moment - /* Now disarm again */ - // ret = ioctl(fd, PWM_SERVO_DISARM, 0); - - - exit(0); -} \ No newline at end of file +}