diff options
author | Dan Williams <dan@ioncontrol.co> | 2025-05-16 11:19:59 -0500 |
---|---|---|
committer | Dan Williams <dan@ioncontrol.co> | 2025-05-22 08:05:58 -0500 |
commit | 24f9309d6ecd559d24c54391fadef76cdbde1097 (patch) | |
tree | f8238a7806bb76739bc74df4aa697a6c3c231eaa /src/mm-serial-parsers.c | |
parent | 7f014add61da3e0411d742756ce372fc0e2aee30 (diff) |
serial-parsers,port-serial-at: move echo removal into serial parser
Mainly because we need somewhere to stash the call end regex, and
it's silly to have a 3rd instance of that in MMPortSerialAt when
we already have one in the serial parsers that MMPortSerialAt
relies on pretty heavily.
Signed-off-by: Dan Williams <dan@ioncontrol.co>
Diffstat (limited to 'src/mm-serial-parsers.c')
-rw-r--r-- | src/mm-serial-parsers.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/mm-serial-parsers.c b/src/mm-serial-parsers.c index a577faee..d8dc1e5d 100644 --- a/src/mm-serial-parsers.c +++ b/src/mm-serial-parsers.c @@ -160,6 +160,27 @@ mm_serial_parser_v1_add_filter (gpointer data, parser->filter_user_data = user_data; } +void +mm_serial_parser_v1_remove_echo (gpointer data, + GByteArray *response) +{ + guint i; + + if (response->len <= 2) + return; + + for (i = 0; i < (response->len - 1); i++) { + /* If there is any content before the first + * <CR><LF>, assume it's echo or garbage, and skip it */ + if (response->data[i] == '\r' && response->data[i + 1] == '\n') { + if (i > 0) + g_byte_array_remove_range (response, 0, i); + /* else, good, we're already started with <CR><LF> */ + break; + } + } +} + gboolean mm_serial_parser_v1_parse (gpointer data, GString *response, |