Add extra_pdu_crlf quirk
authorDenis Kenzior <denkenz@gmail.com>
Wed, 15 Jul 2009 20:44:23 +0000 (15:44 -0500)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 16 Jul 2009 00:49:08 +0000 (02:49 +0200)
gatchat/gatchat.c
gatchat/gatchat.h

index 3c21e06..616f843 100644 (file)
@@ -675,7 +675,15 @@ static void new_bytes(GAtChat *p)
                        len -= p->read_so_far;
                        wrap -= p->read_so_far;
 
-                       have_pdu(p);
+                       /* Some modems like the TI Calypso send a CMT style
+                        * notification with an extra CRLF thrown in
+                        */
+                       if ((p->flags & G_AT_CHAT_FLAG_EXTRA_PDU_CRLF) &&
+                                       p->read_so_far == 2) {
+                               p->state = PARSER_STATE_PDU;
+                               ring_buffer_drain(p->buf, p->read_so_far);
+                       } else
+                               have_pdu(p);
 
                        p->read_so_far = 0;
                } else if (p->state == PARSER_STATE_INITIAL_CR) {
index ff0994b..969f6f4 100644 (file)
@@ -39,6 +39,7 @@ typedef void (*GAtDisconnectFunc)(gpointer user_data);
 
 enum _GAtChatFlags {
        G_AT_CHAT_FLAG_NO_LEADING_CRLF = 1,     /* Some emulators are broken */
+       G_AT_CHAT_FLAG_EXTRA_PDU_CRLF = 2,
 };
 
 typedef enum _GAtChatFlags GAtChatFlags;