| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,76 +12,18 @@ | |||
| 12 | 12 | // See the License for the specific language governing permissions and | |
| 13 | 13 | // limitations under the License. | |
| 14 | 14 | ||
| 15 | - #include <uxr/agent/utils/CLI.hpp> | ||
| 16 | - #include <csignal> | ||
| 15 | + #include <uxr/agent/AgentInstance.hpp> | ||
| 17 | 16 | ||
| 18 | 17 | int main(int argc, char** argv) | |
| 19 | 18 | { | |
| 20 | - #ifndef _WIN32 | ||
| 21 | - sigset_t signals; | ||
| 22 | - sigemptyset(&signals); | ||
| 23 | - if(sigaddset(&signals, SIGINT) && sigaddset(&signals, SIGTERM)) | ||
| 24 | - { | ||
| 25 | - std::cerr << "Wrong signalset" << std::endl; | ||
| 26 | - std::exit(EXIT_FAILURE); | ||
| 27 | - } | ||
| 28 | - sigprocmask( SIG_BLOCK, &signals, nullptr ); | ||
| 29 | - #endif | ||
| 30 | - | ||
| 31 | - | ||
| 32 | - /* CLI application. */ | ||
| 33 | - CLI::App app("micro-ROS Agent"); | ||
| 34 | - app.require_subcommand(1, 1); | ||
| 35 | - app.get_formatter()->column_width(42); | ||
| 36 | - | ||
| 37 | - /* CLI subcommands. */ | ||
| 38 | - eprosima::uxr::cli::UDPv4Subcommand udpv4_subcommand(app); | ||
| 39 | - eprosima::uxr::cli::UDPv6Subcommand udpv6_subcommand(app); | ||
| 40 | - eprosima::uxr::cli::TCPv4Subcommand tcpv4_subcommand(app); | ||
| 41 | - eprosima::uxr::cli::TCPv6Subcommand tcpv6_subcommand(app); | ||
| 42 | - #ifndef _WIN32 | ||
| 43 | - eprosima::uxr::cli::TermiosSubcommand serial_subcommand(app); | ||
| 44 | - eprosima::uxr::cli::PseudoTerminalSubcommand pseudo_serial_subcommand(app); | ||
| 45 | - #endif | ||
| 46 | - eprosima::uxr::cli::ExitSubcommand exit_subcommand(app); | ||
| 19 | + eprosima::uxr::AgentInstance& xrce_dds_agent_instance = | ||
| 20 | + xrce_dds_agent_instance.getInstance(); | ||
| 47 | 21 | ||
| 48 | - /* CLI parse. */ | ||
| 49 | - std::string cli_input{}; | ||
| 50 | - for (int i = 1; i < argc; ++i) | ||
| 22 | + if (!xrce_dds_agent_instance.create(argc, argv)) | ||
| 51 | 23 | { | |
| 52 | - cli_input.append(argv[i]); | ||
| 53 | - cli_input.append(" "); | ||
| 24 | + return 1; | ||
| 54 | 25 | } | |
| 26 | + xrce_dds_agent_instance.run(); | ||
| 55 | 27 | ||
| 56 | - while (true) | ||
| 57 | - { | ||
| 58 | - try | ||
| 59 | - { | ||
| 60 | - app.parse(cli_input); | ||
| 61 | - break; | ||
| 62 | - } | ||
| 63 | - catch (const CLI::ParseError& e) | ||
| 64 | - { | ||
| 65 | - app.exit(e); | ||
| 66 | - std::cin.clear(); | ||
| 67 | - std::cout << std::endl; | ||
| 68 | - std::cout << "Enter command: "; | ||
| 69 | - std::getline(std::cin, cli_input); | ||
| 70 | - } | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - #ifdef _WIN32 | ||
| 74 | - /* Waiting until exit. */ | ||
| 75 | - std::cin.clear(); | ||
| 76 | - char exit_flag = 0; | ||
| 77 | - while ('q' != exit_flag) | ||
| 78 | - { | ||
| 79 | - std::cin >> exit_flag; | ||
| 80 | - } | ||
| 81 | - #else | ||
| 82 | - /* Wait for SIGTERM/SIGINT instead, as reading from stdin may be redirected to /dev/null. */ | ||
| 83 | - int n_signal = 0; | ||
| 84 | - sigwait(&signals, &n_signal); | ||
| 85 | - #endif | ||
| 86 | 28 | return 0; | |
| 87 | 29 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments