In the serial port example, what will happen if the incoming data doesn't have a newline character? Asio::streambuf will be allocating more and more memory and will eventually run out of it? Or the handler will be invoked with an error?
In my example, I control the data that is being generated on the serial port, so I know that it will contain a newline without causing large amounts of buffering on the receiver side. If the amount of data coming in is unknown, you can call async_read_some instead of async_read_until and it will tell you how many bytes it read. (async_read_until also tells you how many bytes were read, but we didn't need that information directly in my example.)
Fantastic, this helped me out in my GUI application reading Data from Arduino, thank you so much!
Fantastic examples and very comprehensive explanations! Thanks you so much for making these videos!
This is fantastic! I was having a hard time grokking asio due to the rather obtuse documentation bits, but this brings it together nicely!
thanks for making this!
In the serial port example, what will happen if the incoming data doesn't have a newline character? Asio::streambuf will be allocating more and more memory and will eventually run out of it? Or the handler will be invoked with an error?
In my example, I control the data that is being generated on the serial port, so I know that it will contain a newline without causing large amounts of buffering on the receiver side.
If the amount of data coming in is unknown, you can call async_read_some instead of async_read_until and it will tell you how many bytes it read. (async_read_until also tells you how many bytes were read, but we didn't need that information directly in my example.)
Serial ports begins at 45m:30s.