format src/systemcmds/motor_test

This commit is contained in:
Daniel Agar 2015-09-05 12:21:11 -04:00
parent 1cca86e8b5
commit 7527026b89
1 changed files with 16 additions and 13 deletions

View File

@ -69,13 +69,14 @@ void motor_test(unsigned channel, float value)
_test_motor.timestamp = hrt_absolute_time();
_test_motor.value = value;
if (_test_motor_pub != nullptr) {
/* 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);
}
if (_test_motor_pub != nullptr) {
/* 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)
@ -85,10 +86,10 @@ static void usage(const char *reason)
}
errx(1,
"usage:\n"
"motor_test\n"
" -m <channel> Motor to test (0..7)\n"
" -p <power> Power (0..100)\n");
"usage:\n"
"motor_test\n"
" -m <channel> Motor to test (0..7)\n"
" -p <power> Power (0..100)\n");
}
int motor_test_main(int argc, char *argv[])
@ -114,11 +115,13 @@ int motor_test_main(int argc, char *argv[])
/* Read in power value */
lval = strtoul(optarg, NULL, 0);
if (lval > 100)
if (lval > 100) {
usage("value invalid");
}
value = ((float)lval)/100.f;
value = ((float)lval) / 100.f;
break;
default:
usage(NULL);
}