62 for (
size_t i = 0; i < len; i++)
80 std::cout <<
"Failed to initialize UDP ports" << std::endl;
85 char message1[] =
"hello world 1!";
86 udp2.
send_bytes((uint8_t*) message1, std::strlen(message1));
89 std::this_thread::sleep_for(std::chrono::milliseconds(500));
90 std::cout << std::endl << std::flush;
93 char message2[] =
"hello world 2!";
94 udp1.
send_bytes((uint8_t*) message2, std::strlen(message2));
97 std::this_thread::sleep_for(std::chrono::milliseconds(500));
98 std::cout << std::endl << std::flush;
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.
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 callback(const uint8_t *buf, size_t len)
Callback function for the async_comm library.
void close()
Closes the port.
Asynchronous communication class for a UDP socket.