Skip to content

Commit

Permalink
Merge pull request #1231 from spark/feature/double-crlf-fix
Browse files Browse the repository at this point in the history
[Electron] Fixes double newline parser issue on G350 introduced in 428835a
  • Loading branch information
technobly committed Jan 18, 2017
2 parents 767e94e + 83cb530 commit 93be3ca
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
1 change: 1 addition & 0 deletions hal/src/electron/modem/enums_hal.h
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
25 changes: 19 additions & 6 deletions hal/src/electron/modem/mdm_hal.cpp
Expand Up @@ -2253,27 +2253,40 @@ 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
{ "\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 ++) {
pipe->set(unkn);
int ln = _parseFormated(pipe, len, lutF[i].fmt);
if (ln == WAIT && fr)
if (ln == WAIT && fr) {
return WAIT;
if ((ln != NOT_FOUND) && (unkn > 0))
}
if ((ln != NOT_FOUND) && (unkn > 0)) {
return TYPE_UNKNOWN | pipe->get(buf, unkn);
if (ln > 0)
}
if (ln > 0) {
return lutF[i].type | pipe->get(buf, ln);
}
}
for (int i = 0; i < (int)(sizeof(lut)/sizeof(*lut)); i ++) {
pipe->set(unkn);
int ln = _parseMatch(pipe, len, lut[i].sta, lut[i].end);
if (ln == WAIT && fr)
if (ln == WAIT && fr) {
return WAIT;
if ((ln != NOT_FOUND) && (unkn > 0))
}
// Double CRLF detected, discard it.
// 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 parseable.
if ((ln > 0) && (lut[i].type == TYPE_DBLNEWLINE) && (unkn == 0)) {
return TYPE_UNKNOWN | pipe->get(buf, 2);
}
if ((ln != NOT_FOUND) && (unkn > 0)) {
return TYPE_UNKNOWN | pipe->get(buf, unkn);
if (ln > 0)
}
if (ln > 0) {
return lut[i].type | pipe->get(buf, ln);
}
}
// UNKNOWN
unkn ++;
Expand Down

0 comments on commit 93be3ca

Please sign in to comment.