aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJulian Oes <julian@oes.ch>2013-10-11 16:33:52 +0200
committerJulian Oes <julian@oes.ch>2013-10-11 16:33:52 +0200
commit3cbe1ee1a8308e2efc017374a6d297761c6c5226 (patch)
treeb4640ad97d66fdf6ee60ab8fa70fa99a29745304 /src
parent2d23d5fd4ec3a00ae18c63304a3b1b3905d7de66 (diff)
downloadpx4-firmware-3cbe1ee1a8308e2efc017374a6d297761c6c5226.tar.gz
px4-firmware-3cbe1ee1a8308e2efc017374a6d297761c6c5226.tar.bz2
px4-firmware-3cbe1ee1a8308e2efc017374a6d297761c6c5226.zip
Revert "Set the PWM values only once or continuous if specified"
This reverts commit 9cd3c40606f023a7943b1418a748abb046e36ecb.
Diffstat (limited to 'src')
-rw-r--r--src/systemcmds/pwm/pwm.c63
1 files changed, 23 insertions, 40 deletions
diff --git a/src/systemcmds/pwm/pwm.c b/src/systemcmds/pwm/pwm.c
index b3975de9d..25f8c4e75 100644
--- a/src/systemcmds/pwm/pwm.c
+++ b/src/systemcmds/pwm/pwm.c
@@ -72,7 +72,7 @@ usage(const char *reason)
warnx("%s", reason);
errx(1,
"usage:\n"
- "pwm arm|disarm|rate|min|max|disarmed|set|info ...\n"
+ "pwm arm|disarm|rate|min|max|disarmed|test|info ...\n"
"\n"
" arm Arm output\n"
" disarm Disarm output\n"
@@ -91,11 +91,10 @@ usage(const char *reason)
" [-a] Configure all outputs\n"
" -p <pwm value> PWM value\n"
"\n"
- " set ... Directly set PWM values\n"
+ " test ... Directly set PWM values\n"
" [-c <channels>] Supply channels (e.g. 1234)\n"
" [-m <chanmask> ] Directly supply channel mask (e.g. 0xF)\n"
" [-a] Configure all outputs\n"
- " [-e] Repeat setting the values until stopped\n"
" -p <pwm value> PWM value\n"
"\n"
" info Print information about the PWM device\n"
@@ -114,7 +113,6 @@ pwm_main(int argc, char *argv[])
uint32_t alt_channel_groups = 0;
bool alt_channels_set = false;
bool print_verbose = false;
- bool repeated_pwm_output = false;
int ch;
int ret;
char *ep;
@@ -127,7 +125,7 @@ pwm_main(int argc, char *argv[])
if (argc < 1)
usage(NULL);
- while ((ch = getopt(argc-1, &argv[1], "d:vc:g:m:ap:r:e")) != EOF) {
+ while ((ch = getopt(argc-1, &argv[1], "d:vc:g:m:ap:r:")) != EOF) {
switch (ch) {
case 'd':
@@ -184,9 +182,6 @@ pwm_main(int argc, char *argv[])
if (*ep != '\0')
usage("bad alternative rate provided");
break;
- case 'e':
- repeated_pwm_output = true;
- break;
default:
break;
}
@@ -362,7 +357,7 @@ pwm_main(int argc, char *argv[])
}
exit(0);
- } else if (!strcmp(argv[1], "set")) {
+ } else if (!strcmp(argv[1], "test")) {
if (set_mask == 0) {
usage("no channels set");
@@ -372,38 +367,14 @@ pwm_main(int argc, char *argv[])
/* perform PWM output */
- if (repeated_pwm_output) {
-
- /* Open console directly to grab CTRL-C signal */
- struct pollfd fds;
- fds.fd = 0; /* stdin */
- fds.events = POLLIN;
-
- warnx("Press CTRL-C or 'c' to abort.");
+ /* Open console directly to grab CTRL-C signal */
+ struct pollfd fds;
+ fds.fd = 0; /* stdin */
+ fds.events = POLLIN;
- while (1) {
- for (unsigned i = 0; i < servo_count; i++) {
- if (set_mask & 1<<i) {
- ret = ioctl(fd, PWM_SERVO_SET(i), pwm_value);
- if (ret != OK)
- err(1, "PWM_SERVO_SET(%d)", i);
- }
- }
-
- /* abort on user request */
- char c;
- ret = poll(&fds, 1, 0);
- if (ret > 0) {
+ warnx("Press CTRL-C or 'c' to abort.");
- read(0, &c, 1);
- if (c == 0x03 || c == 0x63 || c == 'q') {
- warnx("User abort\n");
- exit(0);
- }
- }
- }
- } else {
- /* only set the values once */
+ while (1) {
for (unsigned i = 0; i < servo_count; i++) {
if (set_mask & 1<<i) {
ret = ioctl(fd, PWM_SERVO_SET(i), pwm_value);
@@ -411,6 +382,18 @@ pwm_main(int argc, char *argv[])
err(1, "PWM_SERVO_SET(%d)", i);
}
}
+
+ /* abort on user request */
+ char c;
+ ret = poll(&fds, 1, 0);
+ if (ret > 0) {
+
+ read(0, &c, 1);
+ if (c == 0x03 || c == 0x63 || c == 'q') {
+ warnx("User abort\n");
+ exit(0);
+ }
+ }
}
exit(0);
@@ -493,7 +476,7 @@ pwm_main(int argc, char *argv[])
exit(0);
}
- usage("specify arm|disarm|rate|min|max|disarmed|set|info");
+ usage("specify arm|disarm|rate|min|max|disarmed|test|info");
return 0;
}