Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ATCmdParser]: Align process_oob() to vrecv()'s newline handling #6303

Merged
merged 1 commit into from
Mar 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions platform/ATCmdParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,19 @@ bool ATCmdParser::process_oob()
if (c < 0) {
return false;
}
// Simplify newlines (borrowed from retarget.cpp)
if ((c == CR && _in_prev != LF) ||
(c == LF && _in_prev != CR)) {
_in_prev = c;
c = '\n';
} else if ((c == CR && _in_prev == LF) ||
(c == LF && _in_prev == CR)) {
_in_prev = c;
// onto next character
continue;
} else {
_in_prev = c;
}
_buffer[i++] = c;
_buffer[i] = 0;

Expand All @@ -411,9 +424,7 @@ bool ATCmdParser::process_oob()

// Clear the buffer when we hit a newline or ran out of space
// running out of space usually means we ran into binary data
if (i+1 >= _buffer_size ||
strcmp(&_buffer[i-_output_delim_size], _output_delimiter) == 0) {

if (((i+1) >= _buffer_size) || (c == '\n')) {
debug_if(_dbg_on, "AT< %s", _buffer);
i = 0;
}
Expand Down