mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 14:58:53 +08:00
irlock driver: fix bus selection argument (-b)
This commit is contained in:
committed by
Lorenz Meier
parent
988ce71ee0
commit
b83b588fc5
@@ -54,6 +54,8 @@
|
|||||||
#include <drivers/drv_irlock.h>
|
#include <drivers/drv_irlock.h>
|
||||||
#include <drivers/drv_hrt.h>
|
#include <drivers/drv_hrt.h>
|
||||||
|
|
||||||
|
#include <px4_getopt.h>
|
||||||
|
|
||||||
#include <nuttx/clock.h>
|
#include <nuttx/clock.h>
|
||||||
#include <nuttx/wqueue.h>
|
#include <nuttx/wqueue.h>
|
||||||
#include <systemlib/err.h>
|
#include <systemlib/err.h>
|
||||||
@@ -449,17 +451,28 @@ int irlock_main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int i2cdevice = IRLOCK_I2C_BUS;
|
int i2cdevice = IRLOCK_I2C_BUS;
|
||||||
|
|
||||||
/** jump over start/off/etc and look at options first **/
|
int ch;
|
||||||
if (getopt(argc, argv, "b:") != EOF) {
|
int myoptind = 1;
|
||||||
i2cdevice = (int)strtol(optarg, NULL, 0);
|
const char *myoptarg = nullptr;
|
||||||
|
|
||||||
|
while ((ch = px4_getopt(argc, argv, "b:", &myoptind, &myoptarg)) != EOF) {
|
||||||
|
switch (ch) {
|
||||||
|
case 'b':
|
||||||
|
i2cdevice = (uint8_t)atoi(myoptarg);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
PX4_WARN("Unknown option!");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind >= argc) {
|
if (myoptind >= argc) {
|
||||||
irlock_usage();
|
irlock_usage();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *command = argv[optind];
|
const char *command = argv[myoptind];
|
||||||
|
|
||||||
/** start driver **/
|
/** start driver **/
|
||||||
if (!strcmp(command, "start")) {
|
if (!strcmp(command, "start")) {
|
||||||
|
|||||||
Reference in New Issue
Block a user