aboutsummaryrefslogtreecommitdiff
path: root/apps/drivers/px4io/px4io.cpp
diff options
context:
space:
mode:
authorpx4dev <px4@purgatory.org>2013-03-12 00:40:22 -0700
committerpx4dev <px4@purgatory.org>2013-03-12 22:22:50 -0700
commit7011fe563b583d7940247a7a01265b7f8675fee8 (patch)
treea497bcf8ba9eb4ad20f70185efe1d9df88f7ba99 /apps/drivers/px4io/px4io.cpp
parent57429fd12cc4277c88948c1819b245d9e83523d2 (diff)
downloadpx4-firmware-7011fe563b583d7940247a7a01265b7f8675fee8.tar.gz
px4-firmware-7011fe563b583d7940247a7a01265b7f8675fee8.tar.bz2
px4-firmware-7011fe563b583d7940247a7a01265b7f8675fee8.zip
Move PWM rate configuration, etc. into a separate utility and out of the individual drivers.
Diffstat (limited to 'apps/drivers/px4io/px4io.cpp')
-rw-r--r--apps/drivers/px4io/px4io.cpp50
1 files changed, 22 insertions, 28 deletions
diff --git a/apps/drivers/px4io/px4io.cpp b/apps/drivers/px4io/px4io.cpp
index 803e74469..9854402f0 100644
--- a/apps/drivers/px4io/px4io.cpp
+++ b/apps/drivers/px4io/px4io.cpp
@@ -1502,6 +1502,26 @@ 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)
{
int fd;
@@ -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")) {