[PATCH] Huawei MU609 resets with AT^GETPORTMODE
David McCullough
david.mccullough at accelecon.com
Fri Mar 21 03:43:18 PDT 2014
Hi all,
Sorry for the possible repost, using the correct email address now :-)
Here is a follow up revised patch to my previous patch for thsi modem.
This one does not crash or misbehave. It works around the problem I am
having where a Huawei MU609 (12d1:1573) restarts about 15 seconds after
the AT^GETPORTMODE command is issued.
As other Huawei modems share the 12d1:1572 ID, we must identify the modem
before we can decide on issuing the AT^GETPORTMODE command. I could not
find any safer way to get this info at init time so perhaps someone can
provide a nicer solution.
Cheers,
Davidm
diff --git a/plugins/huawei/mm-plugin-huawei.c b/plugins/huawei/mm-plugin-huawei.c
index 89fe0fc..10163fc 100644
--- a/plugins/huawei/mm-plugin-huawei.c
+++ b/plugins/huawei/mm-plugin-huawei.c
@@ -79,6 +79,8 @@ typedef struct {
GSimpleAsyncResult *result;
gboolean curc_done;
guint curc_retries;
+ gboolean model_done;
+ guint model_retries;
gboolean getportmode_done;
guint getportmode_retries;
} HuaweiCustomInitContext;
@@ -206,6 +208,38 @@ out:
}
static void
+model_ready (MMPortSerialAt *port,
+ GAsyncResult *res,
+ HuaweiCustomInitContext *ctx)
+{
+ const gchar *response;
+ GError *error = NULL;
+
+ response = mm_port_serial_at_command_finish (port, res, &error);
+ if (error) {
+ /* Retry if we get a timeout error */
+ if (g_error_matches (error,
+ MM_SERIAL_ERROR,
+ MM_SERIAL_ERROR_RESPONSE_TIMEOUT))
+ goto out;
+ mm_dbg ("(Huawei) couldn't determine model: '%s'", error->message);
+ } else {
+ /* do any model checks here now we have a safe copy */
+ if (g_str_equal (response, "MU609"))
+ ctx->getportmode_done = TRUE; /* DAVIDM - for now */
+ mm_dbg ("(Huawei) model: '%s'", response);
+ }
+
+ ctx->model_done = TRUE;
+
+out:
+ if (error)
+ g_error_free (error);
+
+ huawei_custom_init_step (ctx);
+}
+
+static void
try_next_usbif (MMDevice *device)
{
FirstInterfaceContext *fi_ctx;
@@ -260,6 +294,31 @@ huawei_custom_init_step (HuaweiCustomInitContext *ctx)
return;
}
+ if (!ctx->model_done) {
+ if (ctx->model_retries == 0) {
+ /* All retries consumed, probably not an AT port */
+ mm_port_probe_set_result_at (ctx->probe, FALSE);
+ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE);
+ /* Try with next */
+ try_next_usbif (mm_port_probe_peek_device (ctx->probe));
+ huawei_custom_init_context_complete_and_free (ctx);
+ return;
+ }
+
+ ctx->model_retries--;
+ /* Determine model number to help with decisions */
+ mm_port_serial_at_command (
+ ctx->port,
+ "AT+CGMM",
+ 3,
+ FALSE, /* raw */
+ FALSE, /* allow_cached */
+ ctx->cancellable,
+ (GAsyncReadyCallback)model_ready,
+ ctx);
+ return;
+ }
+
if (!ctx->curc_done) {
if (ctx->curc_retries == 0) {
/* All retries consumed, probably not an AT port */
@@ -380,6 +439,8 @@ huawei_custom_init (MMPortProbe *probe,
ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;
ctx->curc_done = FALSE;
ctx->curc_retries = 3;
+ ctx->model_done = FALSE;
+ ctx->model_retries = 3;
ctx->getportmode_done = FALSE;
ctx->getportmode_retries = 3;
Signed-Off-By: David McCullough <ucdevel at gmail.com>
--
David McCullough, david.mccullough at accelecon.com, Ph: 0410 560 763
More information about the ModemManager-devel
mailing list