mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 11:23:34 +08:00
sf0x: add -d param to pass the serial port
This commit is contained in:
@@ -934,17 +934,22 @@ info()
|
|||||||
int
|
int
|
||||||
sf0x_main(int argc, char *argv[])
|
sf0x_main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int ch;
|
|
||||||
uint8_t rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING;
|
uint8_t rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING;
|
||||||
|
const char *device_path = SF0X_DEFAULT_PORT;
|
||||||
|
int ch;
|
||||||
int myoptind = 1;
|
int myoptind = 1;
|
||||||
const char *myoptarg = nullptr;
|
const char *myoptarg = nullptr;
|
||||||
|
|
||||||
while ((ch = px4_getopt(argc, argv, "R:", &myoptind, &myoptarg)) != EOF) {
|
while ((ch = px4_getopt(argc, argv, "R:d:", &myoptind, &myoptarg)) != EOF) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'R':
|
case 'R':
|
||||||
rotation = (uint8_t)atoi(myoptarg);
|
rotation = (uint8_t)atoi(myoptarg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'd':
|
||||||
|
device_path = myoptarg;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PX4_WARN("Unknown option!");
|
PX4_WARN("Unknown option!");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -959,12 +964,7 @@ sf0x_main(int argc, char *argv[])
|
|||||||
* Start/load the driver.
|
* Start/load the driver.
|
||||||
*/
|
*/
|
||||||
if (!strcmp(argv[myoptind], "start")) {
|
if (!strcmp(argv[myoptind], "start")) {
|
||||||
if (argc > myoptind + 1) {
|
return sf0x::start(device_path, rotation);
|
||||||
return sf0x::start(argv[myoptind + 1], rotation);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return sf0x::start(SF0X_DEFAULT_PORT, rotation);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user