Skip to content

Commit

Permalink
fix(modem): Fixed inconsistent state on data after OK
Browse files Browse the repository at this point in the history
If we received response in two chunks and the first one completes the
command (result=OK or FAIL), and the second chunk pre-empts command processing,
then we performed processing again rewritting the result back to
TIMEOUT. This would invalidate the command, but also causes an
exception: ESP_MODEM_THROW_IF_ERROR(ESP_ERR_INVALID_STATE)
Fixed by checking if the processing already finished in process_line().

Closes #426
  • Loading branch information
david-cermak committed Nov 29, 2023
1 parent 909e8d9 commit bf99f28
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions components/esp_modem/src/esp_modem_dte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ void DTE::on_read(got_line_cb on_read_cb)

bool DTE::command_cb::process_line(uint8_t *data, size_t consumed, size_t len)
{
if (result != command_result::TIMEOUT) {
return false; // this line has been processed already (got OK or FAIL previously)
}
if (memchr(data + consumed, separator, len)) {
result = got_line(data, consumed + len);
if (result == command_result::OK || result == command_result::FAIL) {
Expand Down

0 comments on commit bf99f28

Please sign in to comment.