Class hal::read_upto
Discard received bytes until the sequence is found.
#include <serial_coroutines.hpp>
Public Functions
Type | Name |
---|---|
result< work_state > | operator() () read data into the buffer. |
read_upto (serial & p_serial, std::span< const hal::byte > p_sequence, std::span< hal::byte > p_buffer, size_t p_read_limit=32) Construct a new skip beyond object. |
Public Functions Documentation
function operator()
read data into the buffer.
inline result< work_state > hal::read_upto::operator() ()
This function will return if the read limit is reached or if there are no more bytes in the serial port.
Call this function again to resume reading from the port.
Returns:
result<work_state> - work_state::in_progress if the sequence hasn't been met and the buffer still has space.
Returns:
result<work_state> - work_state::failed if the sequence wasn't found before the buffer was filled completely.
Returns:
result<work_state> - work_state::finished if the sequence was found before the buffer was filled completely.
function read_upto
Construct a new skip beyond object.
inline hal::read_upto::read_upto (
serial & p_serial,
std::span< const hal::byte > p_sequence,
std::span< hal::byte > p_buffer,
size_t p_read_limit=32
)
Parameters:
p_serial
- serial port to skip throughp_sequence
- sequence to search for. The lifetime of this data pointed to by this span must outlive this object, or not be used when the lifetime of that data is no longer available.p_buffer
- buffer to fill data intop_read_limit
- the maximum number of bytes to read off from the serial port before returning. A value 0 will result in no reads from the serial port.
The documentation for this class was generated from the following file libraries/include/libhal-util/serial_coroutines.hpp