Changeset 2736


Ignore:
Timestamp:
08/17/07 12:02:26 (6 years ago)
Author:
laforge
Message:

Add a flag to allow LFCR as a valid linebreak. (Alex Osborne)

Location:
trunk/src/target/gsm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/gsm/include/gsmd/gsmd.h

    r2732 r2736  
    1818#define LGSM_ATCMD_F_EXTENDED   0x01    /* as opposed to basic */ 
    1919#define LGSM_ATCMD_F_PARAM      0x02    /* as opposed to action */ 
     20#define LGSM_ATCMD_F_LFCR       0x04    /* accept LFCR as a line terminator */ 
    2021 
    2122struct gsmd_atcmd { 
     
    3839        LLPARSE_STATE_RESULT,           /* within result payload */ 
    3940        LLPARSE_STATE_RESULT_CR,        /* CR after result */ 
     41        LLPARSE_STATE_RESULT_LF,        /* LF after result */ 
    4042        LLPARSE_STATE_PROMPT,           /* within a "> " prompt */ 
    4143        LLPARSE_STATE_PROMPT_SPC,       /* a complete "> " prompt */ 
  • trunk/src/target/gsm/src/gsmd/atcmd.c

    r2732 r2736  
    7777} 
    7878 
     79static inline void llparse_endline(struct llparser *llp) 
     80{ 
     81        /* re-set cursor to start of buffer */ 
     82        llp->cur = llp->buf; 
     83        llp->state = LLPARSE_STATE_IDLE; 
     84        memset(llp->buf, 0, LLPARSE_BUF_SIZE); 
     85} 
     86 
    7987static int llparse_byte(struct llparser *llp, char byte) 
    8088{ 
     
    122130                if (byte == '\r') 
    123131                        llp->state = LLPARSE_STATE_RESULT_CR; 
     132                else if ((llp->flags & LGSM_ATCMD_F_LFCR) && byte == '\n') 
     133                        llp->state = LLPARSE_STATE_RESULT_LF; 
    124134                else 
    125135                        ret = llparse_append(llp, byte); 
    126136                break; 
    127137        case LLPARSE_STATE_RESULT_CR: 
    128                 if (byte == '\n') { 
    129                         /* re-set cursor to start of buffer */ 
    130                         llp->cur = llp->buf; 
    131                         llp->state = LLPARSE_STATE_IDLE; 
    132                         memset(llp->buf, 0, LLPARSE_BUF_SIZE); 
    133                 } 
     138                if (byte == '\n') 
     139                        llparse_endline(llp); 
     140                break; 
     141        case LLPARSE_STATE_RESULT_LF: 
     142                if (byte == '\r') 
     143                        llparse_endline(llp); 
    134144                break; 
    135145        case LLPARSE_STATE_PROMPT: 
  • trunk/src/target/gsm/src/gsmd/vendor_bcm.c

    r2734 r2736  
    9999        struct gsmd_atcmd *cmd; 
    100100 
     101        /* bcm sometimes sends LFCR instead of CRLF (eg *MTSMENU message) */ 
     102        g->llp.flags |= LGSM_ATCMD_F_LFCR; 
     103 
    101104        /* TODO */ 
    102105        return rc; 
Note: See TracChangeset for help on using the changeset viewer.