gatchat: add a GARBAGE state to handle random crud from a terminal adapter
PATCH 2/2 gatchat: add a GARBAGE state to handle random crud from a terminal adapter
I've got a version of this that works w/ denkenz's new parser stuff; let me know if I should send that instead.
From d6e942c2e0e2f51c5391e61aa7b5ac7326de28ea Mon Sep 17 00:00:00 2001
From: Andres Salomon <[email protected]>
Date: Tue, 4 Aug 2009 21:33:09 -0400
Subject: [PATCH 2/2] gatchat: add a GARBAGE state to handle random crud from a terminal adapter
When the TA sends random crap, oFono's parser gets confused and doesn't process the next few results (which causes oFono not to send further commands, and thus initialization never finishes). This is less than ideal.
This patch adds a new state; when the parser gets something that doesn't look like a proper response, it will simply ignore the entire line. This allows initialization to continue when the TA does send spurious lines.
--- gatchat/gatchat.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-)
gatchat/gatchat.c +10 -2
@@ -55,7 +55,8 @@ enum chat_state {PARSER_STATE_PDU_CR ,PARSER_STATE_PDU_COMPLETE ,PARSER_STATE_PROMPT , -PARSER_STATE_PROMPT_COMPLETE +PARSER_STATE_PROMPT_COMPLETE , + PARSER_STATE_GARBAGE, }; struct at_command {
@@ -555,7 +556,9 @@ static inline void parse_char(GAtChat *chat, char byte) chat->state =PARSER_STATE_PROMPT ; else chat->state = PARSER_STATE_RESPONSE; - } + }else +/* TA sent something we don't understand; ignore it */ + chat->state =PARSER_STATE_GARBAGE ;break ;case PARSER_STATE_INITIAL_CR :
@@ -623,6 +626,11 @@ static inline void parse_char(GAtChat *chat, char byte) chat->state =PARSER_STATE_RESPONSE ;break ; +case PARSER_STATE_GARBAGE : +if (byte =='\n' ) + chat->state =PARSER_STATE_IDLE ; +break ; +case PARSER_STATE_RESPONSE_COMPLETE :case PARSER_STATE_PDU_COMPLETE :case PARSER_STATE_MULTILINE_COMPLETE :
Signature · 1 line
1.6.3.3
Hi Andres,
Quoted 11 lines
I've got a version of this that works w/ denkenz's new parser stuff; let me know if I should send that instead.
From
d6e942c2e0e2f51c5391e61aa7b5ac7326de28eaMon Sep 17 00:00:00 2001
From: Andres Salomon <[email protected]>
Date: Tue, 4 Aug 2009 21:33:09 -0400
Subject: [PATCH 2/2] gatchat: add a GARBAGE state to handle random crud from a terminal adapter
Quoted 8 lines
When the TA sends random crap, oFono's parser gets confused and doesn't process the next few results (which causes oFono not to send further commands, and thus initialization never finishes). This is less than ideal.
This patch adds a new state; when the parser gets something that doesn't look like a proper response, it will simply ignore the entire line. This allows initialization to continue when the TA does send spurious lines.
I've incorporated a modified version of this into the new default gsmv1 parser as part of the customizable parser patch. This is now upstream, and I'd like to hear about how well it works.
Regards,
-Denis