Skip to content

Commit

Permalink
fixes double newline parser issue on G350 introduced in 428835a
Browse files Browse the repository at this point in the history
  • Loading branch information
technobly committed Jan 17, 2017
1 parent 767e94e commit ede3370
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions hal/src/electron/modem/enums_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ enum {
TYPE_PLUS = 0x400000,
TYPE_TEXT = 0x500000,
TYPE_ABORTED = 0x600000,
TYPE_DBLNEWLINE = 0x700000,

// special timout constant
TIMEOUT_BLOCKING = 0xffffffff
Expand Down
9 changes: 9 additions & 0 deletions hal/src/electron/modem/mdm_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2253,6 +2253,7 @@ int MDMParser::_getLine(Pipe<char>* pipe, char* buf, int len)
{ "\r\n>", NULL, TYPE_PROMPT }, // SMS
{ "\n>", NULL, TYPE_PROMPT }, // File
{ "\r\nABORTED\r\n", NULL, TYPE_ABORTED }, // Current command aborted
{ "\r\n\r\n", "\r\n", TYPE_DBLNEWLINE }, // Double CRLF detected, discard one and reprocess line
{ "\r\n", "\r\n", TYPE_UNKNOWN }, // If all else fails, break up generic strings
};
for (int i = 0; i < (int)(sizeof(lutF)/sizeof(*lutF)); i ++) {
Expand All @@ -2270,6 +2271,14 @@ int MDMParser::_getLine(Pipe<char>* pipe, char* buf, int len)
int ln = _parseMatch(pipe, len, lut[i].sta, lut[i].end);
if (ln == WAIT && fr)
return WAIT;
// Double CRLF detected, discard one and reprocess line.
// This resolves a case on G350 where "\r\n" is generated after +USORF response, but missing
// on U260/U270, which would otherwise generate "\r\n\r\nOK\r\n" which is not parsable.
if ((ln > 0) && (lut[i].type == TYPE_DBLNEWLINE) && (unkn == 0)) {
char tmp[2];
pipe->get(tmp, 2);
break;
}
if ((ln != NOT_FOUND) && (unkn > 0))
return TYPE_UNKNOWN | pipe->get(buf, unkn);
if (ln > 0)
Expand Down

0 comments on commit ede3370

Please sign in to comment.