mirror of https://github.com/ARMmbed/mbed-os.git
Align `ATCmdParser::process_oob()` to `ATCmdParser::vrecv()`'s newline handling
parent
79bd2638b8
commit
3057aa71f9
|
@ -394,6 +394,19 @@ bool ATCmdParser::process_oob()
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
return false;
|
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++] = c;
|
||||||
_buffer[i] = 0;
|
_buffer[i] = 0;
|
||||||
|
|
||||||
|
@ -411,9 +424,7 @@ bool ATCmdParser::process_oob()
|
||||||
|
|
||||||
// Clear the buffer when we hit a newline or ran out of space
|
// Clear the buffer when we hit a newline or ran out of space
|
||||||
// running out of space usually means we ran into binary data
|
// running out of space usually means we ran into binary data
|
||||||
if (i+1 >= _buffer_size ||
|
if (((i+1) >= _buffer_size) || (c == '\n')) {
|
||||||
strcmp(&_buffer[i-_output_delim_size], _output_delimiter) == 0) {
|
|
||||||
|
|
||||||
debug_if(_dbg_on, "AT< %s", _buffer);
|
debug_if(_dbg_on, "AT< %s", _buffer);
|
||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue