All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] gatchat: add a GARBAGE state to handle random crud from a terminal adapter
@ 2009-08-05 21:51 Andres Salomon
  2009-08-06 22:06 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Andres Salomon @ 2009-08-05 21:51 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1996 bytes --]

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 <dilinger@collabora.co.uk>
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(-)

diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index 15cc934..8f00862 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -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:
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 2/2] gatchat: add a GARBAGE state to handle random crud from a terminal adapter
  2009-08-05 21:51 [PATCH 2/2] gatchat: add a GARBAGE state to handle random crud from a terminal adapter Andres Salomon
@ 2009-08-06 22:06 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2009-08-06 22:06 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1095 bytes --]

Hi Andres,

> 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 <dilinger@collabora.co.uk>
> 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.

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-06 22:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-05 21:51 [PATCH 2/2] gatchat: add a GARBAGE state to handle random crud from a terminal adapter Andres Salomon
2009-08-06 22:06 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.