From 8d21764dec36edc400d09fcd3c8f17c1a996c2f9 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Thu, 24 Aug 2017 15:18:31 -1000 Subject: [PATCH] ist8310:Use px4_getops --- src/drivers/ist8310/ist8310.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/drivers/ist8310/ist8310.cpp b/src/drivers/ist8310/ist8310.cpp index 3fecc7b3bf..ed26773afc 100644 --- a/src/drivers/ist8310/ist8310.cpp +++ b/src/drivers/ist8310/ist8310.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include @@ -1568,26 +1569,27 @@ usage() int ist8310_main(int argc, char *argv[]) { - int ch; - IST8310_BUS i2c_busid = IST8310_BUS_ALL; int i2c_addr = IST8310_BUS_I2C_ADDR; /* 7bit */ enum Rotation rotation = ROTATION_NONE; bool calibrate = false; + int myoptind = 1; + int ch; + const char *myoptarg = nullptr; - while ((ch = getopt(argc, argv, "R:Ca:b:")) != EOF) { + while ((ch = px4_getopt(argc, argv, "R:Ca:b:", &myoptind, &myoptarg)) != EOF) { switch (ch) { case 'R': - rotation = (enum Rotation)atoi(optarg); + rotation = (enum Rotation)atoi(myoptarg); break; case 'a': - i2c_addr = (int)strtol(optarg, NULL, 0); + i2c_addr = (int)strtol(myoptarg, NULL, 0); break; case 'b': - i2c_busid = (IST8310_BUS)strtol(optarg, NULL, 0); + i2c_busid = (IST8310_BUS)strtol(myoptarg, NULL, 0); break; case 'C': @@ -1600,12 +1602,12 @@ ist8310_main(int argc, char *argv[]) } } - if (optind >= argc) { + if (myoptind >= argc) { ist8310::usage(); exit(1); } - const char *verb = argv[optind]; + const char *verb = argv[myoptind]; /* * Start/load the driver.