driver/at: add option to keep EOL character in readline, and make EOL configurable#9185
Conversation
drivers/at/at.c
Outdated
| } | ||
| } | ||
| if (*resp_pos == '\n') { | ||
| if (*resp_pos == eol[sizeof(eol) - 1]) { |
There was a problem hiding this comment.
Here it should be:
if ((*resp_pos == eol[sizeof(eol) - 1]) ||
((sizeof(eol) == 2) && (*resp_pos == eol[0]))) {And it will work if AT_RECV_EOL_2 is empty and AT_RECV_EOL_1 is \r which is the case for me.
There was a problem hiding this comment.
Changed to if (*resp_pos == eol[sizeof(eol) - 2]). The sizeof(eol) - 1 was a mistake, as it should always be \0. Now the last character of eol[] is used, so either AT_RECV_EOL_2 if both are set or AT_RECV_EOL_1 if the former is empty.
21c394c to
a2b75b9
Compare
|
@vincent-d, is this PR tested on your side ? |
drivers/at/at.c
Outdated
| else if (res > 0) { | ||
| bytes_left -= res; | ||
| if ((res == 2) && (strncmp(pos, "OK", 2) == 0)) { | ||
| if ((res == (2 + (keep_eol ? 1 : 0))) && (strncmp(pos, "OK", 2) == 0)) { |
There was a problem hiding this comment.
here and below: if keep_eol, it has values 0 or 1, thus the ternary operator can be removed. e.g., just use 2 + keep_eol)
|
tested with ublox-c030-u201 |
b7c30c0 to
faa51a2
Compare
|
squashed |
|
@vincent-d, there are failing tests on Murdock ('unknown type name 'bool'', an include is missing I think) |
faa51a2 to
3f620d5
Compare
Sorry, should be fixed (amended directly) |
|
all green, go! |
Contribution description
With modem, I have some use cases where I want to keep all EOL characters in the response when calling
at_send_cmd_get_lines. For instance when reading a file or an HTTP response.This PR add a parameter to
at_send_cmd_get_linesthus toat_readlineto not remove EOL characters. So far '\r' was removed.It also let the user configure the expected response EOL characters with 2 macros.
(this is not yet tested)Issues/PRs references
Follow-up #7084