aboutsummaryrefslogtreecommitdiff
path: root/src/systemcmds/esc_calib
diff options
context:
space:
mode:
authorJulian Oes <julian@oes.ch>2013-09-22 16:27:52 +0200
committerJulian Oes <julian@oes.ch>2013-09-22 16:27:52 +0200
commit30b151b9a83eed7b41243b31a1ebaf37ee663171 (patch)
tree196faf9b29ef01d46bb0db2e903de1479c7ea3ca /src/systemcmds/esc_calib
parentaf118a3568f2d63219bf97c999912babda588f8c (diff)
downloadpx4-firmware-30b151b9a83eed7b41243b31a1ebaf37ee663171.tar.gz
px4-firmware-30b151b9a83eed7b41243b31a1ebaf37ee663171.tar.bz2
px4-firmware-30b151b9a83eed7b41243b31a1ebaf37ee663171.zip
Improved esc_calib a little, only works on nsh over USB now
Diffstat (limited to 'src/systemcmds/esc_calib')
-rw-r--r--src/systemcmds/esc_calib/esc_calib.c56
1 files changed, 23 insertions, 33 deletions
diff --git a/src/systemcmds/esc_calib/esc_calib.c b/src/systemcmds/esc_calib/esc_calib.c
index 188fa4e37..0d7421842 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 <joes@student.ethz.ch>
*
* 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
+}