sf0x: add -d param to pass the serial port

This commit is contained in:
Beat Küng
2018-09-25 07:53:29 +02:00
parent 0ebf821db4
commit 91a1ac1b60
+8 -8
View File
@@ -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);
}
} }
/* /*