int sdp3x_airspeed_main(int argc, char *argv[]) { int i2c_bus = PX4_I2C_BUS_DEFAULT; for (int i = 1; i < argc; i++) { if (strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "--bus") == 0) { if (argc > i + 1) { i2c_bus = atoi(argv[i + 1]); } } } /* * Start/load the driver. */ if (!strcmp(argv[1], "start")) { return sdp3x_airspeed::start(i2c_bus); } /* * Stop the driver */ if (!strcmp(argv[1], "stop")) { return sdp3x_airspeed::stop(); } /* * Test the driver/device. */ if (!strcmp(argv[1], "test")) { return sdp3x_airspeed::test(); } /* * Reset the driver. */ if (!strcmp(argv[1], "reset")) { return sdp3x_airspeed::reset(); } /* * Print driver information. */ if (!strcmp(argv[1], "info") || !strcmp(argv[1], "status")) { return sdp3x_airspeed::info(); } sdp3x_airspeed_usage(); return PX4_OK; }
int sdp3x_airspeed_main(int argc, char *argv[]) { uint8_t i2c_bus = PX4_I2C_BUS_DEFAULT; int myoptind = 1; int ch; const char *myoptarg = nullptr; bool start_all = false; while ((ch = px4_getopt(argc, argv, "ab:", &myoptind, &myoptarg)) != EOF) { switch (ch) { case 'b': i2c_bus = atoi(myoptarg); break; case 'a': start_all = true; break; default: sdp3x_airspeed_usage(); return 0; } } if (myoptind >= argc) { sdp3x_airspeed_usage(); return -1; } /* * Start/load the driver. */ if (!strcmp(argv[myoptind], "start")) { if (start_all) { return sdp3x_airspeed::start(); } else { return sdp3x_airspeed::start_bus(i2c_bus); } } /* * Stop the driver */ if (!strcmp(argv[myoptind], "stop")) { return sdp3x_airspeed::stop(); } /* * Reset the driver. */ if (!strcmp(argv[myoptind], "reset")) { return sdp3x_airspeed::reset(); } sdp3x_airspeed_usage(); return 0; }