From: M. Dietrich <mdt@emdete.de>
To: ofono@ofono.org
Subject: fix for register of AT driver
Date: Sun, 30 Dec 2012 22:47:18 +0000 [thread overview]
Message-ID: <20121230224659.GA3447@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
reply other threads:[~2012-12-30 22:47 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20121230224659.GA3447@emdete.de \
--to=mdt@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox