Move PWM rate configuration, etc. into a separate utility and out of the individual drivers.

This commit is contained in:
px4dev
2013-03-12 22:22:50 -07:00
parent 57429fd12c
commit 7011fe563b
6 changed files with 289 additions and 92 deletions
+22 -28
View File
@@ -1501,6 +1501,26 @@ extern "C" __EXPORT int px4io_main(int argc, char *argv[]);
namespace
{
void
start(int argc, char *argv[])
{
if (g_dev != nullptr)
errx(1, "already loaded");
/* create the driver - it will set g_dev */
(void)new PX4IO();
if (g_dev == nullptr)
errx(1, "driver alloc failed");
if (OK != g_dev->init()) {
delete g_dev;
errx(1, "driver init failed");
}
exit(0);
}
void
test(void)
{
@@ -1595,34 +1615,8 @@ px4io_main(int argc, char *argv[])
if (argc < 2)
goto out;
if (!strcmp(argv[1], "start")) {
if (g_dev != nullptr)
errx(1, "already loaded");
/* create the driver - it will set g_dev */
(void)new PX4IO();
if (g_dev == nullptr)
errx(1, "driver alloc failed");
if (OK != g_dev->init()) {
delete g_dev;
errx(1, "driver init failed");
}
/* look for the optional pwm update rate for the supported modes */
if ((argc > 2) && (strcmp(argv[2], "-u") == 0 || strcmp(argv[2], "--update-rate") == 0)) {
if (argc > 2 + 1) {
#warning implement this
} else {
fprintf(stderr, "missing argument for pwm update rate (-u)\n");
return 1;
}
}
exit(0);
}
if (!strcmp(argv[1], "start"))
start(argc - 1, argv + 1);
if (!strcmp(argv[1], "recovery")) {