62 for (
size_t i = 0; i < len; i++)
64 std::printf(
"Received byte: %d\n", buf[i]);
69 int main(
int argc,
char** argv)
75 std::printf(
"USAGE: %s PORT\n", argv[0]);
80 std::printf(
"Using port %s\n", argv[1]);
90 std::printf(
"Failed to initialize serial port\n");
97 std::printf(
"Transmit individual bytes:\n");
105 std::this_thread::sleep_for(std::chrono::milliseconds(500));
108 std::printf(
"Bulk transmit:\n");
112 std::this_thread::sleep_for(std::chrono::milliseconds(500));
Asynchronous communication class for a serial port.
int main(int argc, char **argv)
void callback(const uint8_t *buf, size_t len)
Callback function for the async_comm library.
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 send_byte(uint8_t data)
Send a single byte over 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 close()
Closes the port.