mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 02:03:33 +08:00
Enabled UDP in NuttX microRTPS build
Added commandline argument to change microRTPS ip address
This commit is contained in:
committed by
Nuno Marques
parent
375fc4a75c
commit
07eb3d301b
@@ -62,6 +62,7 @@
|
||||
#endif
|
||||
#define DEVICE "/dev/ttyACM0"
|
||||
#define POLL_MS 1
|
||||
#define IP "127.0.0.1"
|
||||
#define DEFAULT_RECV_PORT 2019
|
||||
#define DEFAULT_SEND_PORT 2020
|
||||
|
||||
@@ -85,6 +86,7 @@ struct options {
|
||||
int sleep_ms = SLEEP_MS;
|
||||
struct baudtype baudrate = {.code = BAUDRATE, .val = BAUDRATE_VAL};
|
||||
int poll_ms = POLL_MS;
|
||||
char ip[16] = IP;
|
||||
uint16_t recv_port = DEFAULT_RECV_PORT;
|
||||
uint16_t send_port = DEFAULT_SEND_PORT;
|
||||
};
|
||||
|
||||
@@ -84,6 +84,7 @@ static void usage(const char *name)
|
||||
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_PARAM_STRING('i', "127.0.0.1", "<x.x.x.x>", "Select IP address (remote)", true);
|
||||
|
||||
PRINT_MODULE_USAGE_COMMAND("stop");
|
||||
PRINT_MODULE_USAGE_COMMAND("status");
|
||||
@@ -108,7 +109,7 @@ static int parse_options(int argc, char *argv[])
|
||||
int myoptind = 1;
|
||||
const char *myoptarg = nullptr;
|
||||
|
||||
while ((ch = px4_getopt(argc, argv, "t:d:u:l:w:b:p:r:s:", &myoptind, &myoptarg)) != EOF) {
|
||||
while ((ch = px4_getopt(argc, argv, "t:d:u:l:w:b:p:r:s:i:", &myoptind, &myoptarg)) != EOF) {
|
||||
switch (ch) {
|
||||
case 't': _options.transport = strcmp(myoptarg, "UDP") == 0 ?
|
||||
options::eTransports::UDP
|
||||
@@ -130,6 +131,8 @@ static int parse_options(int argc, char *argv[])
|
||||
|
||||
case 's': _options.send_port = strtoul(myoptarg, nullptr, 10); break;
|
||||
|
||||
case 'i': if (nullptr != myoptarg) strcpy(_options.ip, myoptarg); break;
|
||||
|
||||
default:
|
||||
usage(argv[1]);
|
||||
return -1;
|
||||
@@ -166,9 +169,9 @@ static int micrortps_start(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case options::eTransports::UDP: {
|
||||
transport_node = new UDP_node(_options.recv_port, _options.send_port);
|
||||
PX4_INFO("UDP transport: recv port: %u; send port: %u; sleep: %dms",
|
||||
_options.recv_port, _options.send_port, _options.sleep_ms);
|
||||
transport_node = new UDP_node(_options.ip, _options.recv_port, _options.send_port);
|
||||
PX4_INFO("UDP transport: ip address: %s; recv port: %u; send port: %u; sleep: %dms",
|
||||
_options.ip, _options.recv_port, _options.send_port, _options.sleep_ms);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user