summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-07-07 14:31:11 -0500
committerMarcel Holtmann <marcel@holtmann.org>2009-07-07 13:41:07 -0700
commitd696ef5626e686368f170ce0d0090af2476b83bc (patch)
tree764be3eb7cb7ecac321102c4517570a0a8b66dd5
parent10ff6c2658957d0d57b4b5f110e4d401f167a4bb (diff)
downloadconnman-d696ef5626e686368f170ce0d0090af2476b83bc.tar.gz
connman-d696ef5626e686368f170ce0d0090af2476b83bc.tar.bz2
connman-d696ef5626e686368f170ce0d0090af2476b83bc.zip
Fix case where CMGS returns an error before pdu
Commands like CMGS might return an error before the entire command has been submitted. This results in gatchat stalling completely.
-rw-r--r--gatchat/gatchat.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index dc0d7c9c..32f0b592 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -466,9 +466,21 @@ static void have_line(GAtChat *p, gboolean strip_preceding)
cmd = g_queue_peek_head(p->command_queue);
- if (cmd && p->cmd_bytes_written == strlen(cmd->cmd) &&
- g_at_chat_handle_command_response(p, cmd, str))
- return;
+ if (cmd) {
+ char c = cmd->cmd[p->cmd_bytes_written - 1];
+
+ /* We check that we have submitted a terminator, in which case
+ * a command might have failed or completed successfully
+ *
+ * In the generic case, \r is at the end of the command, so we
+ * know the entire command has been submitted. In the case of
+ * commands like CMGS, every \r or Ctrl-Z might result in a
+ * final response from the modem, so we check this as well.
+ */
+ if ((c == '\r' || c == 26) &&
+ g_at_chat_handle_command_response(p, cmd, str))
+ return;
+ }
if (g_at_chat_match_notify(p, str) == TRUE)
return;