@@ -235,12 +235,15 @@ ModemClass::ParseResult ModemClass::buf_read(const string &prompt, string &data_
235
235
if (c == ' :' || c == ' =' ) {
236
236
commandName += c; // prompt includes also ':'
237
237
238
- if (commandName != DO_NOT_CHECK_CMD && commandName != prompt) {
239
- // state = at_parse_state_t::Begin; // TODO decide whether to return ParseError or realign
238
+ if (prompt != DO_NOT_CHECK_CMD && commandName != prompt) {
239
+ // the response we got is not the one we were expecting, parse the wrong response till the end
240
+ // and start the parse of the next response
240
241
restart = true ;
241
- } else {
242
- state = at_parse_state_t ::Data;
242
+ commandName = " " ;
243
243
}
244
+ state = at_parse_state_t ::Data;
245
+
246
+ data_res = " " ;
244
247
// state = at_parse_state_t::Data;
245
248
} else if (c != ' ' ) { // FIXME should we keep the space?
246
249
commandName += c;
@@ -330,6 +333,7 @@ ModemClass::ParseResult ModemClass::buf_read(const string &prompt, string &data_
330
333
331
334
if (restart) {
332
335
state = at_parse_state_t ::Begin;
336
+ restart = false ;
333
337
} else {
334
338
state = at_parse_state_t ::Completed;
335
339
}
@@ -349,6 +353,7 @@ ModemClass::ParseResult ModemClass::buf_read(const string &prompt, string &data_
349
353
350
354
if (restart) {
351
355
state = at_parse_state_t ::Begin;
356
+ restart = false ;
352
357
} else {
353
358
state = at_parse_state_t ::Completed;
354
359
}
@@ -358,6 +363,7 @@ ModemClass::ParseResult ModemClass::buf_read(const string &prompt, string &data_
358
363
res = ParseError;
359
364
if (restart) {
360
365
state = at_parse_state_t ::Begin;
366
+ restart = false ;
361
367
} else {
362
368
state = at_parse_state_t ::Completed;
363
369
}
0 commit comments