simulator: bring -t argument back

The -t argument had been deleted because I didn't realize that it was
actually being used. Therefore, this brings it back and we now use -c
for TCP.
This commit is contained in:
Julian Oes
2018-12-09 12:19:05 +01:00
parent f03e938953
commit 73578a593f
2 changed files with 33 additions and 23 deletions

View File

@@ -182,7 +182,7 @@ sh "$autostart_file"
dataman start
replay tryapplyparams
simulator start -s -t $simulator_tcp_port
simulator start -s -c $simulator_tcp_port
tone_alarm start
gyrosim start
accelsim start

View File

@@ -157,7 +157,7 @@ int Simulator::start(int argc, char *argv[])
port = atoi(argv[4]);
}
if (argc == 5 && strcmp(argv[3], "-t") == 0) {
if (argc == 5 && strcmp(argv[3], "-c") == 0) {
ip = InternetProtocol::TCP;
port = atoi(argv[4]);
}
@@ -175,6 +175,7 @@ int Simulator::start(int argc, char *argv[])
} else {
_instance->initializeSensorData();
_instance->_initialized = true;
}
return 0;
@@ -187,11 +188,12 @@ int Simulator::start(int argc, char *argv[])
static void usage()
{
PX4_WARN("Usage: simulator {start -[sp] [-u udp_port / -t tcp_port] |stop}");
PX4_WARN("Usage: simulator {start -[spt] [-u udp_port / -c tcp_port] |stop}");
PX4_WARN("Simulate raw sensors: simulator start -s");
PX4_WARN("Publish sensors combined: simulator start -p");
PX4_WARN("Connect using UDP: simulator start -u udp_port");
PX4_WARN("Connect using TCP: simulator start -t tcp_port");
PX4_WARN("Connect using TCP: simulator start -c tcp_port");
PX4_WARN("Dummy unit test data: simulator start -t");
}
__BEGIN_DECLS
@@ -202,7 +204,10 @@ extern "C" {
int simulator_main(int argc, char *argv[])
{
if (argc == 5 && strcmp(argv[1], "start") == 0) {
if (argc > 2 && strcmp(argv[1], "start") == 0) {
if (strcmp(argv[2], "-s") == 0 ||
strcmp(argv[2], "-p") == 0 ||
strcmp(argv[2], "-t") == 0) {
if (g_sim_task >= 0) {
PX4_WARN("Simulator already started");
@@ -225,6 +230,11 @@ extern "C" {
}
}
} else {
usage();
return 1;
}
} else if (argc == 2 && strcmp(argv[1], "stop") == 0) {
if (g_sim_task < 0) {
PX4_WARN("Simulator not running");