-
-
Notifications
You must be signed in to change notification settings - Fork 525
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backend: add connection URL as arg to backend_bin
This allows backend_bin to accept the connection URL as an argument, as well as -h or --help to show the usage.
- Loading branch information
1 parent
96f8ba7
commit 7d75c16
Showing
1 changed file
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,42 @@ | ||
#include "backend_api.h" | ||
#include <iostream> | ||
#include <string> | ||
|
||
static void usage(); | ||
|
||
static auto constexpr default_connection = "udp://:14540"; | ||
|
||
int main(int argc, char **argv) | ||
{ | ||
runBackend("udp://14540", nullptr, nullptr); | ||
if (argc > 2) { | ||
usage(); | ||
return 1; | ||
} | ||
|
||
if (argc == 2) { | ||
const std::string positional_arg = argv[1]; | ||
if (positional_arg.compare("-h") == 0 || positional_arg.compare("--help") == 0) { | ||
usage(); | ||
return 0; | ||
} | ||
runBackend(positional_arg.c_str(), nullptr, nullptr); | ||
} | ||
|
||
runBackend(default_connection, nullptr, nullptr); | ||
} | ||
|
||
void usage() | ||
{ | ||
std::cout << "Usage: backend_bin [-h | --help]" << std::endl | ||
<< " backend_bin [Connection URL]" << std::endl | ||
<< std::endl | ||
<< "Connection URL format should be:" << std::endl | ||
<< " Serial: serial:///path/to/serial/dev[:baudrate]" << std::endl | ||
<< " UDP: udp://[bind_host][:bind_port]" << std::endl | ||
<< " TCP: tcp://[server_host][:server_port]" << std::endl | ||
<< std::endl | ||
<< "For example to connect to SITL use: udp://:14540" << std::endl | ||
<< std::endl | ||
<< "Options:" << std::endl | ||
<< " -h | --help : show this help" << std::endl; | ||
} |