diff options
author | laforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-08-17 10:02:26 +0000 |
---|---|---|
committer | laforge <laforge@99fdad57-331a-0410-800a-d7fa5415bdb3> | 2007-08-17 10:02:26 +0000 |
commit | 24a43c94efc45681be1c65ee6c939d698fafe3b6 (patch) | |
tree | d4cff4f1852a370eac6bbe585ffad3a866b7d35c /src | |
parent | bdd62a21ce56cacb4859402565866f1d93694d48 (diff) |
Add a flag to allow LFCR as a valid linebreak. (Alex Osborne)
git-svn-id: http://svn.openmoko.org/trunk/src/target/gsm@2736 99fdad57-331a-0410-800a-d7fa5415bdb3
Diffstat (limited to 'src')
-rw-r--r-- | src/gsmd/atcmd.c | 22 | ||||
-rw-r--r-- | src/gsmd/vendor_bcm.c | 3 |
2 files changed, 19 insertions, 6 deletions
diff --git a/src/gsmd/atcmd.c b/src/gsmd/atcmd.c index 514625b..37c8538 100644 --- a/src/gsmd/atcmd.c +++ b/src/gsmd/atcmd.c @@ -76,6 +76,14 @@ static inline int llparse_append(struct llparser *llp, char byte) } } +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,16 +129,18 @@ static int llparse_byte(struct llparser *llp, char byte) 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 == ' ') diff --git a/src/gsmd/vendor_bcm.c b/src/gsmd/vendor_bcm.c index e8e1584..9bcfa1a 100644 --- a/src/gsmd/vendor_bcm.c +++ b/src/gsmd/vendor_bcm.c @@ -98,6 +98,9 @@ static int bcm_initsettings(struct gsmd *g) 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; } |