mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-27 15:33:34 +08:00
teraranger: add argc check and fix argv index
This commit is contained in:
@@ -950,14 +950,18 @@ teraranger_main(int argc, char *argv[])
|
|||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'R':
|
case 'R':
|
||||||
rotation = (uint8_t)atoi(myoptarg);
|
rotation = (uint8_t)atoi(myoptarg);
|
||||||
PX4_INFO("Setting sensor orientation to %d", (int)rotation);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PX4_WARN("Unknown option!");
|
PX4_WARN("Unknown option!");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (myoptind >= argc) {
|
||||||
|
goto out_error;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start/load the driver.
|
* Start/load the driver.
|
||||||
*/
|
*/
|
||||||
@@ -989,10 +993,11 @@ teraranger_main(int argc, char *argv[])
|
|||||||
/*
|
/*
|
||||||
* Print driver information.
|
* Print driver information.
|
||||||
*/
|
*/
|
||||||
if (!strcmp(argv[myoptind], "info") || !strcmp(argv[1], "status")) {
|
if (!strcmp(argv[myoptind], "info") || !strcmp(argv[myoptind], "status")) {
|
||||||
teraranger::info();
|
teraranger::info();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
out_error:
|
||||||
PX4_ERR("unrecognized command, try 'start', 'test', 'reset' or 'info'");
|
PX4_ERR("unrecognized command, try 'start', 'test', 'reset' or 'info'");
|
||||||
return PX4_ERROR;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user