diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-23 12:06:46 +0100 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-11-23 12:06:46 +0100 |
commit | 461e9889b334865f1eec0c1d7a20067ff5a647ea (patch) | |
tree | 2ebcd3c57679153676a6674f60911c28f40c6031 /src/systemcmds/motor_test/motor_test.c | |
parent | 4030b20de7921d5e9673ce18215f76f0820c1ec7 (diff) | |
parent | 138c25ec74f08db6f6759053d0200058a794c196 (diff) | |
download | px4-firmware-461e9889b334865f1eec0c1d7a20067ff5a647ea.tar.gz px4-firmware-461e9889b334865f1eec0c1d7a20067ff5a647ea.tar.bz2 px4-firmware-461e9889b334865f1eec0c1d7a20067ff5a647ea.zip |
Merged master
Diffstat (limited to 'src/systemcmds/motor_test/motor_test.c')
-rw-r--r-- | src/systemcmds/motor_test/motor_test.c | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/systemcmds/motor_test/motor_test.c b/src/systemcmds/motor_test/motor_test.c index 079f99674..1b7ff75f7 100644 --- a/src/systemcmds/motor_test/motor_test.c +++ b/src/systemcmds/motor_test/motor_test.c @@ -54,7 +54,8 @@ #include "systemlib/err.h" -__EXPORT int motor_test_main(int argc, char *argv[]); +__EXPORT int motor_test_main(int argc, char *argv[]); + static void motor_test(unsigned channel, float value); static void usage(const char *reason); @@ -67,19 +68,20 @@ void motor_test(unsigned channel, float value) _test_motor.timestamp = hrt_absolute_time(); _test_motor.value = value; - if (_test_motor_pub > 0) { - /* publish armed state */ - orb_publish(ORB_ID(test_motor), _test_motor_pub, &_test_motor); - } else { - /* advertise and publish */ - _test_motor_pub = orb_advertise(ORB_ID(test_motor), &_test_motor); - } + if (_test_motor_pub > 0) { + /* publish test state */ + orb_publish(ORB_ID(test_motor), _test_motor_pub, &_test_motor); + } else { + /* advertise and publish */ + _test_motor_pub = orb_advertise(ORB_ID(test_motor), &_test_motor); + } } static void usage(const char *reason) { - if (reason != NULL) + if (reason != NULL) { warnx("%s", reason); + } errx(1, "usage:\n" @@ -90,8 +92,9 @@ static void usage(const char *reason) int motor_test_main(int argc, char *argv[]) { - unsigned long channel, lval; - float value; + unsigned long channel = 0; + unsigned long lval; + float value = 0.0f; int ch; if (argc != 5) { @@ -102,18 +105,18 @@ int motor_test_main(int argc, char *argv[]) switch (ch) { case 'm': - /* Read in channels supplied as one int and convert to mask: 1234 -> 0xF */ + /* Read in motor number */ channel = strtoul(optarg, NULL, 0); break; case 'p': - /* Read in custom low value */ + /* Read in power value */ lval = strtoul(optarg, NULL, 0); if (lval > 100) usage("value invalid"); - value = (float)lval/100.f; + value = ((float)lval)/100.f; break; default: usage(NULL); @@ -122,7 +125,7 @@ int motor_test_main(int argc, char *argv[]) motor_test(channel, value); - printf("motor %d set to %.2f\n", channel, value); + printf("motor %d set to %.2f\n", channel, (double)value); exit(0); } |