From: M. Dietrich <ofono@emdete.de>
To: ofono@ofono.org
Subject: fix for +CMER parser of AT driver (fixes registration)
Date: Mon, 07 Jan 2013 21:58:23 +0100 [thread overview]
Message-ID: <20130107205823.GI7263@emdete.de> (raw)
[-- 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
next reply other threads:[~2013-01-07 20:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-07 20:58 M. Dietrich [this message]
2013-01-17 3:28 ` fix for +CMER parser of AT driver (fixes registration) 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130107205823.GI7263@emdete.de \
--to=ofono@emdete.de \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.