forked from Archive/PX4-Autopilot
micrortps_client_main: use new module documentation & check param range
This commit is contained in:
parent
e7d19f0a1a
commit
de8e0b54b6
|
@ -43,6 +43,7 @@
|
||||||
#include <px4_posix.h>
|
#include <px4_posix.h>
|
||||||
#include <px4_tasks.h>
|
#include <px4_tasks.h>
|
||||||
#include <px4_time.h>
|
#include <px4_time.h>
|
||||||
|
#include <px4_module.h>
|
||||||
|
|
||||||
extern "C" __EXPORT int micrortps_client_main(int argc, char *argv[]);
|
extern "C" __EXPORT int micrortps_client_main(int argc, char *argv[]);
|
||||||
|
|
||||||
|
@ -53,17 +54,23 @@ struct options _options;
|
||||||
|
|
||||||
static void usage(const char *name)
|
static void usage(const char *name)
|
||||||
{
|
{
|
||||||
PX4_INFO("usage: %s start|stop [options]\n\n"
|
PRINT_MODULE_USAGE_NAME("micrortps_client", "communication");
|
||||||
" -t <transport> [UART|UDP] Default UART\n"
|
PRINT_MODULE_USAGE_COMMAND("start");
|
||||||
" -d <device> UART device. Default /dev/ttyACM0\n"
|
|
||||||
" -u <update_time_ms> Time in ms for uORB subscribed topics update. Default 0\n"
|
PRINT_MODULE_USAGE_PARAM_STRING('t', "UART", "UART|UDP", "Transport protocol", true);
|
||||||
" -l <loops> How many iterations will this program have. -1 for infinite. Default 10000\n"
|
PRINT_MODULE_USAGE_PARAM_STRING('d', "/dev/ttyACM0", "<file:dev>", "Select Serial Device", true);
|
||||||
" -w <sleep_time_ms> Time in ms for which each iteration sleep. Default 1ms\n"
|
PRINT_MODULE_USAGE_PARAM_INT('b', 460800, 9600, 3000000, "Baudrate", true);
|
||||||
" -b <baudrate> UART device baudrate. Default 460800\n"
|
PRINT_MODULE_USAGE_PARAM_INT('p', 1, 1, 1000, "Poll timeout for UART in ms", true);
|
||||||
" -p <poll_ms> Time in ms to poll over UART. Default 1ms\n"
|
PRINT_MODULE_USAGE_PARAM_INT('u', 0, 0, 10000,
|
||||||
" -r <reception port> UDP port for receiving. Default 2019\n"
|
"Interval in ms to limit the update rate of all sent topics (0=unlimited)", true);
|
||||||
" -s <sending port> UDP port for sending. Default 2020\n",
|
PRINT_MODULE_USAGE_PARAM_INT('l', 10000, -1, 100000, "Limit number of iterations until the program exits (-1=infinite)",
|
||||||
name);
|
true);
|
||||||
|
PRINT_MODULE_USAGE_PARAM_INT('w', 1, 1, 1000, "Time in ms for which each iteration sleeps", true);
|
||||||
|
PRINT_MODULE_USAGE_PARAM_INT('r', 2019, 0, 65536, "Select UDP Network Port for receiving (local)", true);
|
||||||
|
PRINT_MODULE_USAGE_PARAM_INT('s', 2020, 0, 65536, "Select UDP Network Port for sending (remote)", true);
|
||||||
|
|
||||||
|
PRINT_MODULE_USAGE_COMMAND("stop");
|
||||||
|
PRINT_MODULE_USAGE_COMMAND("status");
|
||||||
}
|
}
|
||||||
|
|
||||||
static int parse_options(int argc, char *argv[])
|
static int parse_options(int argc, char *argv[])
|
||||||
|
@ -100,6 +107,16 @@ static int parse_options(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_options.sleep_ms < 1) {
|
||||||
|
_options.sleep_ms = 1;
|
||||||
|
PX4_ERR("sleep time too low, using 1 ms");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_options.poll_ms < 1) {
|
||||||
|
_options.poll_ms = 1;
|
||||||
|
PX4_ERR("poll timeout too low, using 1 ms");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue