MCPcopy Create free account
hub / github.com/OpenHD/OpenHD / main

Function main

OpenHD/ohd_telemetry/test/test_serial_endpoint.cpp:37–72  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35#include "serial_endpoint_test_helper.h"
36
37int main(int argc, char *argv[]) {
38 const auto serial_options =
39 serial_endpoint_test_helper::parse_args(argc, argv);
40
41 std::cout << "SerialEndpointTest::start with "
42 << serial_endpoint_test_helper::options_to_string(serial_options);
43
44 auto options = SerialEndpoint::HWOptions{};
45 options.linux_filename = serial_options.filename;
46 options.baud_rate = serial_options.baud_rate;
47 options.flow_control = false;
48 options.enable_debug = true;
49
50 auto serial_endpoint = std::make_unique<SerialEndpoint>("ser_test", options);
51 serial_endpoint->registerCallback([](std::vector<MavlinkMessage> messages) {
52 // debugMavlinkMessage(msg.m, "SerialTest3");
53 });
54 // now mavlink messages should come in. Try disconnecting and reconnecting,
55 // and see if messages continue
56 const auto start = std::chrono::steady_clock::now();
57 static bool quit = false;
58 signal(SIGTERM, [](int sig) { quit = true; });
59 while (
60 ((std::chrono::steady_clock::now() - start) < std::chrono::seconds(60)) &&
61 !quit) {
62 std::cout << serial_endpoint->createInfo();
63 // some implementations need a heartbeat before they start sending data.
64 auto msg = MExampleMessage::heartbeat();
65 serial_endpoint->sendMessages({msg});
66 std::this_thread::sleep_for(std::chrono::seconds(1));
67 }
68 serial_endpoint.reset();
69 serial_endpoint = nullptr;
70 std::cout << "SerialEndpointTest3::end" << std::endl;
71 return 0;
72}

Callers

nothing calls this directly

Calls 7

parse_argsFunction · 0.85
options_to_stringFunction · 0.85
heartbeatFunction · 0.85
registerCallbackMethod · 0.80
createInfoMethod · 0.80
sendMessagesMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected