Skip to content

Commit cd9c28b

Browse files
authored
Merge pull request #6303 from betzw/betzw_process_oob_wb
[ATCmdParser]: Align `process_oob()` to `vrecv()`'s newline handling
2 parents 842a86a + 3057aa7 commit cd9c28b

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

platform/ATCmdParser.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,19 @@ bool ATCmdParser::process_oob()
394394
if (c < 0) {
395395
return false;
396396
}
397+
// Simplify newlines (borrowed from retarget.cpp)
398+
if ((c == CR && _in_prev != LF) ||
399+
(c == LF && _in_prev != CR)) {
400+
_in_prev = c;
401+
c = '\n';
402+
} else if ((c == CR && _in_prev == LF) ||
403+
(c == LF && _in_prev == CR)) {
404+
_in_prev = c;
405+
// onto next character
406+
continue;
407+
} else {
408+
_in_prev = c;
409+
}
397410
_buffer[i++] = c;
398411
_buffer[i] = 0;
399412

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

412425
// Clear the buffer when we hit a newline or ran out of space
413426
// running out of space usually means we ran into binary data
414-
if (i+1 >= _buffer_size ||
415-
strcmp(&_buffer[i-_output_delim_size], _output_delimiter) == 0) {
416-
427+
if (((i+1) >= _buffer_size) || (c == '\n')) {
417428
debug_if(_dbg_on, "AT< %s", _buffer);
418429
i = 0;
419430
}

0 commit comments

Comments
 (0)