Skip to content
Snippets Groups Projects
Commit 0fa3bd46 authored by Beat Küng's avatar Beat Küng Committed by Lorenz Meier
Browse files

ms5611: use px4_getopt instead of getopt

- px4_getopt is threadsafe
- getopt does not do argument reordering (ms5611 start -T 5607 did not work)
parent 1b0f41e3
No related branches found
No related tags found
No related merge requests found
......@@ -66,6 +66,7 @@
#include <systemlib/perf_counter.h>
#include <systemlib/err.h>
#include <platforms/px4_getopt.h>
#include "ms5611.h"
......@@ -1249,9 +1250,11 @@ ms5611_main(int argc, char *argv[])
enum MS5611_BUS busid = MS5611_BUS_ALL;
int device_type = 5611; // Default to MS5611
int ch;
int myoptind = 1;
const char *myoptarg = NULL;
/* jump over start/off/etc and look at options first */
while ((ch = getopt(argc, argv, "T:XISs")) != EOF) {
while ((ch = px4_getopt(argc, argv, "T:XISs", &myoptind, &myoptarg)) != EOF) {
switch (ch) {
case 'X':
busid = MS5611_BUS_I2C_EXTERNAL;
......@@ -1270,7 +1273,7 @@ ms5611_main(int argc, char *argv[])
break;
case 'T':
device_type = atoi(optarg);
device_type = atoi(myoptarg);
if (device_type == 5611 || device_type == 5607) {
break;
......@@ -1284,7 +1287,7 @@ ms5611_main(int argc, char *argv[])
}
const char *verb = argv[optind];
const char *verb = argv[myoptind];
/*
* Start/load the driver.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment