61 for (
size_t i = 0; i < len; i++)
74 if (!tcp_client.
init())
76 std::cout <<
"Failed to initialize TCP client" << std::endl;
81 for (
size_t i = 0; i < 10; ++i)
83 std::string msg =
"hello world " + std::to_string(i) +
"!";
84 tcp_client.
send_bytes((uint8_t*) msg.data(), msg.size());
85 std::this_thread::sleep_for(std::chrono::milliseconds(500));
void send_bytes(const uint8_t *src, size_t len)
Send bytes from a buffer over the port.
bool init()
Initializes and opens the port.
Asynchronous communication class for a TCP client.
void register_receive_callback(std::function< void(const uint8_t *, size_t)> fun)
Register a callback function for when bytes are received on the port.
void close()
Closes the port.
void callback(const uint8_t *buf, size_t len)
Callback function for the async_comm library.