sf0x: add -d param to pass the serial port

This commit is contained in:
Beat Küng 2018-06-07 13:42:44 +02:00
parent 0ebf821db4
commit 91a1ac1b60
1 changed files with 8 additions and 8 deletions

View File

@ -934,17 +934,22 @@ info()
int
sf0x_main(int argc, char *argv[])
{
int ch;
uint8_t rotation = distance_sensor_s::ROTATION_DOWNWARD_FACING;
const char *device_path = SF0X_DEFAULT_PORT;
int ch;
int myoptind = 1;
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) {
case 'R':
rotation = (uint8_t)atoi(myoptarg);
break;
case 'd':
device_path = myoptarg;
break;
default:
PX4_WARN("Unknown option!");
return -1;
@ -959,12 +964,7 @@ sf0x_main(int argc, char *argv[])
* Start/load the driver.
*/
if (!strcmp(argv[myoptind], "start")) {
if (argc > myoptind + 1) {
return sf0x::start(argv[myoptind + 1], rotation);
} else {
return sf0x::start(SF0X_DEFAULT_PORT, rotation);
}
return sf0x::start(device_path, rotation);
}
/*