diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2010-10-19 22:59:21 +0200 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-10-19 22:59:21 +0200 |
commit | 2475d8826cc6b8c8c8935cb6a4d5afef7caf818f (patch) | |
tree | c039f8f4850b3dadf6b36cc0a5a241c3621f383b | |
parent | b92662634d59752b5b80ce67f8cde5185b0f3105 (diff) | |
download | ofono-2475d8826cc6b8c8c8935cb6a4d5afef7caf818f.tar.gz |
ifx: Wait for DLC creation to settle (internal multiplexer)
When driving the Infineon modem with the builtin multiplexer there is
a small race condition with setting up the channels and sending the
first AT commands. The window here is pretty small, but it seems to be
a modem firmware issue. In case the AT command is send right away it can
happen that the modem does not process any further AT commands. In that
case the setup is stuck and enabling the modem fails.
Just adding a 10 milliseconds delay after DLC creation and before
sending the first AT commands is enough to make this work smoothly.
-rw-r--r-- | plugins/ifx.c | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/plugins/ifx.c b/plugins/ifx.c index c0937e0d..b427842b 100644 --- a/plugins/ifx.c +++ b/plugins/ifx.c @@ -83,6 +83,7 @@ struct ifx_data { GAtChat *dlcs[NUM_DLC]; guint dlc_poll_count; guint dlc_poll_source; + guint dlc_init_source; guint frame_size; int mux_ldisc; int saved_ldisc; @@ -198,9 +199,6 @@ static GAtChat *create_chat(GIOChannel *channel, char *debug) if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, ifx_debug, debug); - g_at_chat_send(chat, "ATE0 +CMEE=1", NULL, - NULL, NULL, NULL); - return chat; } @@ -210,6 +208,11 @@ static void shutdown_device(struct ifx_data *data) DBG(""); + if (data->dlc_init_source > 0) { + g_source_remove(data->dlc_init_source); + data->dlc_init_source = 0; + } + for (i = 0; i < NUM_DLC; i++) { if (!data->dlcs[i]) continue; @@ -338,6 +341,26 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data) xgendata_query, modem, NULL); } +static gboolean dlc_setup(gpointer user_data) +{ + struct ofono_modem *modem = user_data; + struct ifx_data *data = ofono_modem_get_data(modem); + int i; + + DBG(""); + + for (i = 0; i < NUM_DLC; i++) + g_at_chat_send(data->dlcs[i], "ATE0 +CMEE=1", NULL, + NULL, NULL, NULL); + + g_at_chat_send(data->dlcs[AUX_DLC], "AT+CFUN=4", NULL, + cfun_enable, modem, NULL); + + data->dlc_init_source = 0; + + return FALSE; +} + static gboolean dlc_ready_check(gpointer user_data) { struct ofono_modem *modem = user_data; @@ -367,11 +390,11 @@ static gboolean dlc_ready_check(gpointer user_data) } } - g_at_chat_send(data->dlcs[AUX_DLC], "AT+CFUN=4", NULL, - cfun_enable, modem, NULL); - data->dlc_poll_source = 0; + /* iterate through mainloop */ + data->dlc_init_source = g_timeout_add_seconds(0, dlc_setup, modem); + return FALSE; error: @@ -416,8 +439,8 @@ static void setup_internal_mux(struct ofono_modem *modem) } } - g_at_chat_send(data->dlcs[AUX_DLC], "AT+CFUN=4", NULL, - cfun_enable, modem, NULL); + /* wait for DLC creation to settle */ + data->dlc_init_source = g_timeout_add(10, dlc_setup, modem); return; |