r2736 - in trunk/src/target/gsm: include/gsmd src/gsmd

laforge at sita.openmoko.org laforge at sita.openmoko.org
Fri Aug 17 12:02:31 CEST 2007


Author: laforge
Date: 2007-08-17 12:02:26 +0200 (Fri, 17 Aug 2007)
New Revision: 2736

Modified:
   trunk/src/target/gsm/include/gsmd/gsmd.h
   trunk/src/target/gsm/src/gsmd/atcmd.c
   trunk/src/target/gsm/src/gsmd/vendor_bcm.c
Log:
Add a flag to allow LFCR as a valid linebreak. (Alex Osborne)


Modified: trunk/src/target/gsm/include/gsmd/gsmd.h
===================================================================
--- trunk/src/target/gsm/include/gsmd/gsmd.h	2007-08-17 10:02:02 UTC (rev 2735)
+++ trunk/src/target/gsm/include/gsmd/gsmd.h	2007-08-17 10:02:26 UTC (rev 2736)
@@ -17,6 +17,7 @@
 /* Refer to 3GPP TS 07.07 v 7.8.0, Chapter 4.1 */
 #define LGSM_ATCMD_F_EXTENDED	0x01	/* as opposed to basic */
 #define LGSM_ATCMD_F_PARAM	0x02	/* as opposed to action */
+#define LGSM_ATCMD_F_LFCR	0x04	/* accept LFCR as a line terminator */
 
 struct gsmd_atcmd {
 	struct llist_head list;
@@ -37,6 +38,7 @@
 	LLPARSE_STATE_IDLE_LF,		/* LF before response (V1) */
 	LLPARSE_STATE_RESULT,		/* within result payload */
 	LLPARSE_STATE_RESULT_CR,	/* CR after result */
+	LLPARSE_STATE_RESULT_LF,	/* LF after result */
 	LLPARSE_STATE_PROMPT,		/* within a "> " prompt */
 	LLPARSE_STATE_PROMPT_SPC,	/* a complete "> " prompt */
 	LLPARSE_STATE_ERROR,		/* something went wrong */

Modified: trunk/src/target/gsm/src/gsmd/atcmd.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/atcmd.c	2007-08-17 10:02:02 UTC (rev 2735)
+++ trunk/src/target/gsm/src/gsmd/atcmd.c	2007-08-17 10:02:26 UTC (rev 2736)
@@ -76,6 +76,14 @@
 	}
 }
 
+static inline void llparse_endline(struct llparser *llp)
+{
+	/* re-set cursor to start of buffer */
+	llp->cur = llp->buf;
+	llp->state = LLPARSE_STATE_IDLE;
+	memset(llp->buf, 0, LLPARSE_BUF_SIZE);
+}
+
 static int llparse_byte(struct llparser *llp, char byte)
 {
 	int ret = 0;
@@ -121,17 +129,19 @@
 	case LLPARSE_STATE_RESULT:
 		if (byte == '\r')
 			llp->state = LLPARSE_STATE_RESULT_CR;
+		else if ((llp->flags & LGSM_ATCMD_F_LFCR) && byte == '\n')
+			llp->state = LLPARSE_STATE_RESULT_LF;
 		else
 			ret = llparse_append(llp, byte);
 		break;
 	case LLPARSE_STATE_RESULT_CR:
-		if (byte == '\n') {
-			/* re-set cursor to start of buffer */
-			llp->cur = llp->buf;
-			llp->state = LLPARSE_STATE_IDLE;
-			memset(llp->buf, 0, LLPARSE_BUF_SIZE);
-		}
+		if (byte == '\n')
+			llparse_endline(llp);
 		break;
+	case LLPARSE_STATE_RESULT_LF:
+		if (byte == '\r')
+			llparse_endline(llp);
+		break;
 	case LLPARSE_STATE_PROMPT:
 		if (byte == ' ')
 			llp->state = LLPARSE_STATE_PROMPT_SPC;

Modified: trunk/src/target/gsm/src/gsmd/vendor_bcm.c
===================================================================
--- trunk/src/target/gsm/src/gsmd/vendor_bcm.c	2007-08-17 10:02:02 UTC (rev 2735)
+++ trunk/src/target/gsm/src/gsmd/vendor_bcm.c	2007-08-17 10:02:26 UTC (rev 2736)
@@ -98,6 +98,9 @@
 	int rc;
 	struct gsmd_atcmd *cmd;
 
+	/* bcm sometimes sends LFCR instead of CRLF (eg *MTSMENU message) */
+	g->llp.flags |= LGSM_ATCMD_F_LFCR;
+
 	/* TODO */
 	return rc;
 }





More information about the commitlog mailing list