All of lore.kernel.org
 help / color / mirror / Atom feed
* fix for +CMER parser of AT driver (fixes registration)
@ 2013-01-07 20:58 M. Dietrich
  2013-01-17  3:28 ` Denis Kenzior
  0 siblings, 1 reply; 6+ messages in thread
From: M. Dietrich @ 2013-01-07 20:58 UTC (permalink / raw)
  To: ofono

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

Hi All,


i recently noticed that the at driver did not reach the state "registered".
marcel pointer me to the message

	+CMER not supported by this modem.  If this is an error please submit
	patches to support this hardware

and i started digging. problem was parsing of the response

	+CMER: (0,3),(0,2),0,(0-1),0

that expresses the allowed options of CMER. neither (a list of) single integer
"(0,3)" (in opposite to range "(0-1)") nor missing brackets "0" were supported
by ofono so i added this (see patch).

i'm not sure if missing brackets are allowed or espress something different,
maybe a AT-guru can tell. for now "(0)" behaves like "0".

i assume that also other response-parsing flows in ofono have that problem
so either a generic aproach should be implemented or other places be reviewed.

marcel already pointer out that a generic aproach may be unnecessarily complex
where i agree if it comes to strings and nested brackets but for plain integer
cases it would be quite useful to get this done in one place for all. if
interested i could implement such stuff into gatchat/gatresult.c which then can
be used for the integer-only cases. what do you think?


regards,
	michael

-- 
M. Dietrich

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-enhance-parser-for-CMER-response.patch --]
[-- Type: text/x-diff, Size: 2050 bytes --]

>From 2328b03067a0d982ff2ca08f110ac4b0fa23002a Mon Sep 17 00:00:00 2001
From: "M. Dietrich" <mdt@pyneo.org>
Date: Sun, 30 Dec 2012 21:26:33 +0100
Subject: [PATCH] enhance parser for CMER response

---
 drivers/atmodem/network-registration.c |   39 ++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index 19b19b2..3128d5f 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -1615,26 +1615,45 @@ static void at_cmer_query_cb(ofono_bool_t ok, GAtResult *result,
 
 	g_at_result_iter_init(&iter, result);
 
-	if (!g_at_result_iter_next(&iter, "+CMER:"))
+	if (!g_at_result_iter_next(&iter, "+CMER:")) {
+		DBG("parsing error, probably begin tag not found");
 		goto error;
+	}
 
 	for (opt = 0; opt < cmer_opts_cnt; opt++) {
 		int min, max;
 
-		if (!g_at_result_iter_open_list(&iter))
-			goto error;
-
-		while (g_at_result_iter_next_range(&iter, &min, &max)) {
-			for (mode = min; mode <= max; mode++)
-				cmer_opts[opt] |= 1 << mode;
+		if (!g_at_result_iter_open_list(&iter)) {
+			max = -1;
+			while (g_at_result_iter_next_number(&iter, &min)) {
+				if (max < 0)
+					max = min;
+				for (mode = min; mode <= max; mode++)
+					cmer_opts[opt] |= 1 << mode;
+			}
 		}
+		else
+		{
+			max = -1;
+			while (g_at_result_iter_next_range(&iter, &min, &max)
+			|| g_at_result_iter_next_number(&iter, &min)) {
+				if (max < 0)
+					max = min;
+				for (mode = min; mode <= max; mode++)
+					cmer_opts[opt] |= 1 << mode;
+			}
 
-		if (!g_at_result_iter_close_list(&iter))
-			goto error;
+			if (!g_at_result_iter_close_list(&iter)) {
+				DBG("parsing error: end not found");
+				goto error;
+			}
+		}
 	}
 
-	if (build_cmer_string(buf, cmer_opts, nd) == FALSE)
+	if (build_cmer_string(buf, cmer_opts, nd) == FALSE) {
+		DBG("could not build cmer");
 		goto error;
+	}
 
 	g_at_chat_send(nd->chat, buf, cmer_prefix,
 			at_cmer_set_cb, netreg, NULL);
-- 
1.7.10.4


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

end of thread, other threads:[~2013-01-19 19:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-07 20:58 fix for +CMER parser of AT driver (fixes registration) M. Dietrich
2013-01-17  3:28 ` Denis Kenzior
2013-01-18 22:44   ` M. Dietrich
2013-01-19  0:05     ` Denis Kenzior
2013-01-19 18:28       ` M. Dietrich
2013-01-19 19:05         ` 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.