ModemManager: issues with Nokia handset in git master



Hey Dan & everyone,

The recent commit 0f6d1b2 [1] to fix some N900 behaviour in git master
seems to be breaking my Nokia C7 connection. Without the PORT_SEND_DELAY
setting, I seem to get the same strange behaviour as described in commit
46d757f [2]: we get some but not all echo characters back. I tried to
re-enable the PORT_SEND_DELAY property value to 5000 again, and when
that set, the modem now sends all echo-ed characters back (still doesn't
disable the echo anyway).

But, while debugging the issue, I also found that I could properly fully
disable the echo if I first open the port with minicom and run ATE0 in
there. After some more debugging, it seems that if we use ATE1 (which is
part of the minicom initialization commands) and then ATE0 just when
opening the serial connection, the modem ends up properly disabling the
echo completely.

Attached a patch that follows this logic both in the modem enabling
process and in the setup before probing. I tested it with my Nokia C7
and seems to work quite well; no need of PORT_SEND_DELAY and no need of
having the INIT command twice... Can someone test it with a N900 or some
other Nokia handset? If it ends up working properly, we can even skip
using the custom v1_e1 response parser in the Nokia plugin. Or maybe I'm
just too optimistic... :-)

Cheers!

[1]
http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=0f6d1b2b42afe48583c9c3e7c159be4353462d86
[2]
http://cgit.freedesktop.org/ModemManager/ModemManager/commit/?id=46d757faa768db7d7bb23d51cc2af3196f7a7e30

-- 
Aleksander
>From 425cc9294141b83e66a6ed62a3e68674144ca6d8 Mon Sep 17 00:00:00 2001
From: Aleksander Morgado <aleksander lanedo com>
Date: Sat, 20 Aug 2011 17:22:28 +0200
Subject: [PATCH] nokia: use E1 E0 when initializing the modem

Passing E1 and E0 afterwards seems to properly disable the echo in Nokia modems
(N900 and C7 at least)
---
 plugins/mm-modem-nokia.c  |    9 +++++++++
 plugins/mm-plugin-nokia.c |   22 ++++++++++++++++++++++
 src/mm-generic-gsm.c      |    6 ------
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/plugins/mm-modem-nokia.c b/plugins/mm-modem-nokia.c
index 56f4c1b..9476f61 100644
--- a/plugins/mm-modem-nokia.c
+++ b/plugins/mm-modem-nokia.c
@@ -120,6 +120,11 @@ get_property (GObject *object, guint prop_id,
     case MM_GENERIC_GSM_PROP_POWER_DOWN_CMD:
         g_value_set_string (value, "");
         break;
+    case MM_GENERIC_GSM_PROP_INIT_CMD:
+        /* When initializing a Nokia phone, first enable the echo,
+         * and then disable it, so that we get it properly disabled */
+        g_value_set_string (value, "Z E1 E0 V1");
+        break;
     default:
         break;
     }
@@ -136,6 +141,10 @@ mm_modem_nokia_class_init (MMModemNokiaClass *klass)
     object_class->set_property = set_property;
 
     g_object_class_override_property (object_class,
+                                      MM_GENERIC_GSM_PROP_INIT_CMD,
+                                      MM_GENERIC_GSM_INIT_CMD);
+
+    g_object_class_override_property (object_class,
                                       MM_GENERIC_GSM_PROP_POWER_UP_CMD,
                                       MM_GENERIC_GSM_POWER_UP_CMD);
 
diff --git a/plugins/mm-plugin-nokia.c b/plugins/mm-plugin-nokia.c
index f605a23..12a00d3 100644
--- a/plugins/mm-plugin-nokia.c
+++ b/plugins/mm-plugin-nokia.c
@@ -59,6 +59,22 @@ probe_result (MMPluginBase *base,
     mm_plugin_base_supports_task_complete (task, get_level_for_capabilities (capabilities));
 }
 
+static gboolean
+custom_init_response_cb (MMPluginBaseSupportsTask *task,
+                         GString *response,
+                         GError *error,
+                         guint32 tries,
+                         gboolean *out_stop,
+                         guint32 *out_level,
+                         gpointer user_data)
+{
+    if (error)
+        return tries <= 4 ? TRUE : FALSE;
+
+    /* No error, assume success */
+    return FALSE;
+}
+
 static MMPluginSupportsResult
 supports_port (MMPluginBase *base,
                MMModem *existing,
@@ -95,6 +111,12 @@ supports_port (MMPluginBase *base,
         return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED;
     }
 
+    mm_plugin_base_supports_task_add_custom_init_command (task,
+                                                          "ATE1 E0",
+                                                          3,
+                                                          custom_init_response_cb,
+                                                          NULL);
+
     /* Otherwise kick off a probe */
     if (mm_plugin_base_probe_port (base, task, 100000, NULL))
         return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS;
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index be985b1..fb202f4 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -1609,13 +1609,7 @@ enable_flash_done (MMSerialPort *port, GError *error, gpointer user_data)
         return;
     }
 
-    /* Send the init command twice; some devices (Nokia N900) appear to take a
-     * few commands before responding correctly.  Instead of penalizing them for
-     * being stupid the first time by failing to enable the device, just
-     * try again.
-     */
     g_object_get (G_OBJECT (info->modem), MM_GENERIC_GSM_INIT_CMD, &cmd, NULL);
-    mm_at_serial_port_queue_command (MM_AT_SERIAL_PORT (port), cmd, 3, NULL, NULL);
     mm_at_serial_port_queue_command (MM_AT_SERIAL_PORT (port), cmd, 3, init_done, user_data);
     g_free (cmd);
 }
-- 
1.7.4.1



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]