diff --git a/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_main.cpp b/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_main.cpp index da6851f8be..78eabe48e8 100644 --- a/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_main.cpp +++ b/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_main.cpp @@ -43,6 +43,7 @@ #include #include #include +#include extern "C" __EXPORT int micrortps_client_main(int argc, char *argv[]); @@ -53,17 +54,23 @@ struct options _options; static void usage(const char *name) { - PX4_INFO("usage: %s start|stop [options]\n\n" - " -t [UART|UDP] Default UART\n" - " -d UART device. Default /dev/ttyACM0\n" - " -u Time in ms for uORB subscribed topics update. Default 0\n" - " -l How many iterations will this program have. -1 for infinite. Default 10000\n" - " -w Time in ms for which each iteration sleep. Default 1ms\n" - " -b UART device baudrate. Default 460800\n" - " -p Time in ms to poll over UART. Default 1ms\n" - " -r UDP port for receiving. Default 2019\n" - " -s UDP port for sending. Default 2020\n", - name); + PRINT_MODULE_USAGE_NAME("micrortps_client", "communication"); + PRINT_MODULE_USAGE_COMMAND("start"); + + PRINT_MODULE_USAGE_PARAM_STRING('t', "UART", "UART|UDP", "Transport protocol", true); + PRINT_MODULE_USAGE_PARAM_STRING('d', "/dev/ttyACM0", "", "Select Serial Device", true); + PRINT_MODULE_USAGE_PARAM_INT('b', 460800, 9600, 3000000, "Baudrate", true); + PRINT_MODULE_USAGE_PARAM_INT('p', 1, 1, 1000, "Poll timeout for UART in ms", true); + PRINT_MODULE_USAGE_PARAM_INT('u', 0, 0, 10000, + "Interval in ms to limit the update rate of all sent topics (0=unlimited)", true); + PRINT_MODULE_USAGE_PARAM_INT('l', 10000, -1, 100000, "Limit number of iterations until the program exits (-1=infinite)", + 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[]) @@ -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; }