ModemManager: Handle partial replies in AT+CPIN? (READY without OK)
- From: Aleksander Morgado <aleksander lanedo com>
- To: "Network Manager (Devel)" <networkmanager-list gnome org>
- Subject: ModemManager: Handle partial replies in AT+CPIN? (READY without OK)
- Date: Tue, 29 Mar 2011 14:40:25 +0200
Hi all,
So we have this "AirLink Fastrack Xtend" Sierra Wireless modem [1],
ModemManager uses the generic GSM plugin to handle it.
On PIN check the following flow happens:
--> 'AT+CPIN?'
<-- '<CR><LF>+CPIN: READY<CR><LF>'
(see [2] for the logs reported by Thomas Bechtold a while ago).
Once that is received, response is parsed but no successful response is
found, as there is no "<CR><LF>OK<CR><LF>" after the READY [3]. Thus,
ModemManager will wait for more data to come, and ends up timing out
("Serial command timed out").
Once timed out, pin_check_done() gets called in mm-generic-gsm.c, where
both the response GString (with the partial reply) and the GError are
set. If a GError is set in pin_check_done(), the contents of the GString
are fully discarded, and therefore, the pin check is retried up to 3
times and never succeeds.
Now, what would be the proper way to handle this situation? One option
is to make the OK on the reply to AT+CPIN? optional, by parsing partial
replies. See attached patch.
Another option, I guess, is to write a new plugin to handle this
specific case. Maybe there is some other plugin handling it?
Which would be the preferred way to handle this specific issue?
Cheers,
[1]
https://www.sierrawireless.com/productsandservices/AirLink/Programmable%
20and%20Simple%20Modems/Fastrack%20Series/Fastrack_Xtend_EDGE.aspx
[2]
http://mail.gnome.org/archives/networkmanager-list/2011-March/msg00127.html
[3] According to section 9.1.2 of the "AT Commands Interface Guide for
Firmware 7.45" of Sierra Wireless, the AT+CPIN? query reply will never
have an "OK" (quoting here):
Read command
AT+CPIN?
+CPIN: <code>
Note: No OK
--
Aleksander
>From 220c331a23c29e262d807435b1120e96f17c7eea Mon Sep 17 00:00:00 2001
From: Aleksander Morgado <aleksander lanedo com>
Date: Tue, 29 Mar 2011 14:20:15 +0200
Subject: [PATCH] generic-gsm: handle partial AT+CPIN? replies
---
src/mm-generic-gsm.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index 98713b0..a727f00 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -261,8 +261,21 @@ pin_check_done (MMAtSerialPort *port,
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
gboolean parsed = FALSE;
+ gboolean partial = FALSE;
- if (error)
+ /* Some Sierra Wireless modems like the 'AirLink Fastrack Xtend'
+ * will send back the READY without an OK, and therefore the
+ * command will time out. Try to handle this. */
+ if (error &&
+ error->domain == MM_SERIAL_ERROR &&
+ error->code == MM_SERIAL_ERROR_RESPONSE_TIMEOUT &&
+ response) {
+ g_warning ("%s: got a partial reply, will try to process it",
+ __func__);
+ partial = TRUE;
+ }
+
+ if (error && !partial)
info->error = g_error_copy (error);
else if (response && strstr (response->str, "+CPIN: ")) {
const char *str = strstr (response->str, "+CPIN: ") + 7;
@@ -307,7 +320,8 @@ pin_check_done (MMAtSerialPort *port,
if (!info->error) {
info->error = g_error_new (MM_MODEM_ERROR,
MM_MODEM_ERROR_GENERAL,
- "Could not parse PIN request response '%s'",
+ "Could not parse %sPIN request response '%s'",
+ partial ? "partial " : "",
response->str);
}
}
--
1.7.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]