I use boost asio async_read_some, the data I want to read STXdataETXlrc, if it were not for lrc I would use async_read_until, how can I continue reading until I get ETXlrc? appreciate all the help.
/huvcbo
I use boost asio async_read_some, the data I want to read STXdataETXlrc, if it were not for lrc I would use async_read_until, how can I continue reading until I get ETXlrc? appreciate all the help.
/huvcbo
From the very sparse information, I'm assuming you are talking in the context of serial comms.
In that case, the simplest way to get started might be to use Asio's composed read operations (like
read,read_untiletc).With a bit of syntactic sugar you can write more expressively:
E.g.:
You could then proceed to to a fixed-length read to get the checksum. More involved overloads of
read_untilallow you to writeMatchConditioninstead so you can combine it all in a single call: https://www.boost.org/doc/libs/1_78_0/doc/html/boost_asio/reference/read_until.html.Here's an example that uses the
boost::regexoverload, that shows the message and whether the checksum verifies:Live On Compiler Explorer
Tested locally using
socat: