<div dir="ltr"><div>Hi Dan,</div><div><br></div><div>Now that you mentioned it, the issue isn't quite obvious to me by looking at the log. I printed out the "response" passed to mm_huawei_parse_ndisstatqry_response and observed the "^RSSI: 16^M^M" message in front of the "^NDISSTATQRY" response:</div>
<div><br></div><div><debug> [000027.596303] [mm-at-serial-port.c:408] debug_log(): (ttyUSB0): --> 'AT^NDISSTATQRY?<CR>'<br></div><div><debug> [000027.617122] [mm-at-serial-port.c:408] debug_log(): (ttyUSB0): <-- '<CR><LF>^NDISSTATQRY: 0,,,"IPV4"<CR><LF><CR><LF>OK<CR><LF>'</div>
<div><debug> [000027.617316] [mm-serial-port.c:1018] mm_serial_port_close(): (ttyUSB0) device open count is 1 (close)</div><div><debug> [000028.561321] [mm-serial-port.c:972] mm_serial_port_open(): (ttyUSB0) device open count is 2 (open)</div>
<div><debug> [000028.561476] [mm-at-serial-port.c:408] debug_log(): (ttyUSB0): --> 'AT^NDISSTATQRY?<CR>'</div><div><debug> [000028.584342] [mm-at-serial-port.c:408] debug_log(): (ttyUSB0): <-- '<CR><LF>^NDISSTATQRY: 0,,,"IPV4"<CR><LF><CR><LF>OK<CR><LF>'</div>
<div><debug> [000028.584642] [mm-serial-port.c:1018] mm_serial_port_close(): (ttyUSB0) device open count is 1 (close)</div><div><debug> [000029.218829] [mm-at-serial-port.c:408] debug_log(): (ttyUSB0): <-- '<CR><LF>^RSSI: 16<CR><LF><CR><LF>^CSNR:-87,-5<CR><LF>'</div>
<div><debug> [000029.561465] [mm-serial-port.c:972] mm_serial_port_open(): (ttyUSB0) device open count is 2 (open)</div><div><debug> [000029.561841] [mm-at-serial-port.c:408] debug_log(): (ttyUSB0): --> 'AT^NDISSTATQRY?<CR>'</div>
<div><debug> [000029.582647] [mm-at-serial-port.c:408] debug_log(): (ttyUSB0): <-- '<CR><LF>^NDISSTATQRY: 0,,,"IPV4"<CR><LF><CR><LF>OK<CR><LF>'</div>
<div><debug> [000029.582735] [huawei/mm-modem-helpers-huawei.c:42] mm_huawei_parse_ndisstatqry_response(): Missing ^NDISSTATQRY prefix: '^RSSI: 16^M</div><div>^M</div><div>^NDISSTATQRY: 0,,,"IPV4"'</div>
<div><debug> [000029.582747] [huawei/mm-broadband-bearer-huawei.c:133] connect_ndisstatqry_check_ready(): Modem doesn't properly support ^NDISSTATQRY command: Missing ^NDISSTATQRY prefix</div><div><debug> [000029.582767] [mm-serial-port.c:1018] mm_serial_port_close(): (ttyUSB0) device open count is 1 (close)</div>
<div><debug> [000029.582865] [mm-bearer.c:461] connect_ready(): Couldn't connect bearer '/org/freedesktop/ModemManager1/Bearer/0': 'Connection attempt not supported'</div><div><info> [000029.582960] [mm-iface-modem.c:1203] __iface_modem_update_state_internal(): Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connecting -> registered)</div>
<div><debug> [000029.583709] [mm-iface-modem-simple.c:221] connect_bearer_ready(): Couldn't connect bearer: 'Connection attempt not supported'</div><div class="gmail_extra"><br></div><div class="gmail_extra">
Thanks,</div><div class="gmail_extra">Ben<br><br><div class="gmail_quote">On Mon, Aug 5, 2013 at 9:08 PM, Dan Williams <span dir="ltr"><<a href="mailto:dcbw@redhat.com" target="_blank">dcbw@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On Mon, 2013-08-05 at 19:46 -0700, Ben Chan wrote:<br>
> This patch modifies mm_huawei_parse_ndisstatqry_response() to properly<br>
> handle a ^NDISSTATQRY? response when it is mixed with another unsolicited<br>
> response, e.g.<br>
><br>
> ^RSSI: 16\r\n^NDISSTATQRY: 0,,,"IPV4"<br>
<br>
</div>We'd expect the unsolicited responses to be cleared out of the response<br>
string already by the serial parser. Is that not happening? At least<br>
for ^RSSI, the regex expects a leading \r\n though. Are there any logs<br>
you've got that show a more complete command sequence?<br>
<span class=""><font color="#888888"><br>
Dan<br>
</font></span><div class=""><div class="h5"><br>
> This patch is originally developed by:<br>
> Franko Fang <<a href="mailto:fangxiaozhi@huawei.com">fangxiaozhi@huawei.com</a>><br>
><br>
> And then revised by:<br>
> Ben Chan <<a href="mailto:benchan@chromium.org">benchan@chromium.org</a>><br>
> ---<br>
> plugins/huawei/mm-modem-helpers-huawei.c | 6 +-<br>
> plugins/huawei/tests/test-modem-helpers-huawei.c | 70 +++++++++++++++---------<br>
> 2 files changed, 48 insertions(+), 28 deletions(-)<br>
><br>
> diff --git a/plugins/huawei/mm-modem-helpers-huawei.c b/plugins/huawei/mm-modem-helpers-huawei.c<br>
> index d9b038d..e1e05c4 100644<br>
> --- a/plugins/huawei/mm-modem-helpers-huawei.c<br>
> +++ b/plugins/huawei/mm-modem-helpers-huawei.c<br>
> @@ -20,6 +20,7 @@<br>
> #define _LIBMM_INSIDE_MM<br>
> #include <libmm-glib.h><br>
><br>
> +#include "mm-log.h"<br>
> #include "mm-modem-helpers-huawei.h"<br>
><br>
> /*****************************************************************************/<br>
> @@ -37,7 +38,10 @@ mm_huawei_parse_ndisstatqry_response (const gchar *response,<br>
> GMatchInfo *match_info;<br>
> GError *inner_error = NULL;<br>
><br>
> - if (!response || !g_str_has_prefix (response, "^NDISSTATQRY:")) {<br>
> + if (response)<br>
> + response = g_strstr_len (response, -1, "^NDISSTATQRY:");<br>
> +<br>
> + if (!response) {<br>
> g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Missing ^NDISSTATQRY prefix");<br>
> return FALSE;<br>
> }<br>
> diff --git a/plugins/huawei/tests/test-modem-helpers-huawei.c b/plugins/huawei/tests/test-modem-helpers-huawei.c<br>
> index c1bc0ed..5e2e83d 100644<br>
> --- a/plugins/huawei/tests/test-modem-helpers-huawei.c<br>
> +++ b/plugins/huawei/tests/test-modem-helpers-huawei.c<br>
> @@ -17,6 +17,9 @@<br>
> #include <glib-object.h><br>
> #include <locale.h><br>
><br>
> +#include <ModemManager.h><br>
> +<br>
> +#include "mm-errors-types.h"<br>
> #include "mm-modem-helpers-huawei.h"<br>
><br>
> /*****************************************************************************/<br>
> @@ -24,6 +27,7 @@<br>
><br>
> typedef struct {<br>
> const gchar *str;<br>
> + gboolean expected_result;<br>
> gboolean expected_ipv4_available;<br>
> gboolean expected_ipv4_connected;<br>
> gboolean expected_ipv6_available;<br>
> @@ -31,39 +35,48 @@ typedef struct {<br>
> } NdisstatqryTest;<br>
><br>
> static const NdisstatqryTest ndisstatqry_tests[] = {<br>
> - { "^NDISSTATQRY: 1,,,IPV4\r\n", TRUE, TRUE, FALSE, FALSE },<br>
> - { "^NDISSTATQRY: 0,,,IPV4\r\n", TRUE, FALSE, FALSE, FALSE },<br>
> - { "^NDISSTATQRY: 1,,,IPV6\r\n", FALSE, FALSE, TRUE, TRUE },<br>
> - { "^NDISSTATQRY: 0,,,IPV6\r\n", FALSE, FALSE, TRUE, FALSE },<br>
> + { "^NDISSTATQRY: 1,,,IPV4\r\n", TRUE, TRUE, TRUE, FALSE, FALSE },<br>
> + { "^NDISSTATQRY: 0,,,IPV4\r\n", TRUE, TRUE, FALSE, FALSE, FALSE },<br>
> + { "^NDISSTATQRY: 1,,,IPV6\r\n", TRUE, FALSE, FALSE, TRUE, TRUE },<br>
> + { "^NDISSTATQRY: 0,,,IPV6\r\n", TRUE, FALSE, FALSE, TRUE, FALSE },<br>
> { "^NDISSTATQRY: 1,,,IPV4\r\n"<br>
> - "^NDISSTATQRY: 1,,,IPV6\r\n", TRUE, TRUE, TRUE, TRUE },<br>
> + "^NDISSTATQRY: 1,,,IPV6\r\n", TRUE, TRUE, TRUE, TRUE, TRUE },<br>
> { "^NDISSTATQRY: 1,,,IPV4\r\n"<br>
> - "^NDISSTATQRY: 0,,,IPV6\r\n", TRUE, TRUE, TRUE, FALSE },<br>
> + "^NDISSTATQRY: 0,,,IPV6\r\n", TRUE, TRUE, TRUE, TRUE, FALSE },<br>
> { "^NDISSTATQRY: 0,,,IPV4\r\n"<br>
> - "^NDISSTATQRY: 1,,,IPV6\r\n", TRUE, FALSE, TRUE, TRUE },<br>
> + "^NDISSTATQRY: 1,,,IPV6\r\n", TRUE, TRUE, FALSE, TRUE, TRUE },<br>
> { "^NDISSTATQRY: 0,,,IPV4\r\n"<br>
> - "^NDISSTATQRY: 0,,,IPV6\r\n", TRUE, FALSE, TRUE, FALSE },<br>
> - { "^NDISSTATQRY: 1,,,IPV4", TRUE, TRUE, FALSE, FALSE },<br>
> - { "^NDISSTATQRY: 0,,,IPV4", TRUE, FALSE, FALSE, FALSE },<br>
> - { "^NDISSTATQRY: 1,,,IPV6", FALSE, FALSE, TRUE, TRUE },<br>
> - { "^NDISSTATQRY: 0,,,IPV6", FALSE, FALSE, TRUE, FALSE },<br>
> + "^NDISSTATQRY: 0,,,IPV6\r\n", TRUE, TRUE, FALSE, TRUE, FALSE },<br>
> + { "^NDISSTATQRY: 1,,,IPV4", TRUE, TRUE, TRUE, FALSE, FALSE },<br>
> + { "^NDISSTATQRY: 0,,,IPV4", TRUE, TRUE, FALSE, FALSE, FALSE },<br>
> + { "^NDISSTATQRY: 1,,,IPV6", TRUE, FALSE, FALSE, TRUE, TRUE },<br>
> + { "^NDISSTATQRY: 0,,,IPV6", TRUE, FALSE, FALSE, TRUE, FALSE },<br>
> { "^NDISSTATQRY: 1,,,IPV4\r\n"<br>
> - "^NDISSTATQRY: 1,,,IPV6", TRUE, TRUE, TRUE, TRUE },<br>
> + "^NDISSTATQRY: 1,,,IPV6", TRUE, TRUE, TRUE, TRUE, TRUE },<br>
> { "^NDISSTATQRY: 1,,,IPV4\r\n"<br>
> - "^NDISSTATQRY: 0,,,IPV6", TRUE, TRUE, TRUE, FALSE },<br>
> + "^NDISSTATQRY: 0,,,IPV6", TRUE, TRUE, TRUE, TRUE, FALSE },<br>
> { "^NDISSTATQRY: 0,,,IPV4\r\n"<br>
> - "^NDISSTATQRY: 1,,,IPV6", TRUE, FALSE, TRUE, TRUE },<br>
> + "^NDISSTATQRY: 1,,,IPV6", TRUE, TRUE, FALSE, TRUE, TRUE },<br>
> { "^NDISSTATQRY: 0,,,IPV4\r\n"<br>
> - "^NDISSTATQRY: 0,,,IPV6", TRUE, FALSE, TRUE, FALSE },<br>
> - { NULL, FALSE, FALSE, FALSE, FALSE }<br>
> + "^NDISSTATQRY: 0,,,IPV6", TRUE, TRUE, FALSE, TRUE, FALSE },<br>
> + { "^RSSI: 16\r\n"<br>
> + "^NDISSTATQRY: 0,,,IPV4", TRUE, TRUE, FALSE, FALSE, FALSE },<br>
> + { "^RSSI: 16\r\n"<br>
> + "^NDISSTATQRY: 0,,,IPV4\r\n"<br>
> + "^NDISSTATQRY: 0,,,IPV6", TRUE, TRUE, FALSE, TRUE, FALSE },<br>
> + { "^RSSI: 16\r\n", FALSE, FALSE, FALSE, FALSE, FALSE },<br>
> + { "OK\r\n", FALSE, FALSE, FALSE, FALSE, FALSE },<br>
> + { "\r\n", FALSE, FALSE, FALSE, FALSE, FALSE },<br>
> + { "", FALSE, FALSE, FALSE, FALSE, FALSE },<br>
> + { NULL, FALSE, FALSE, FALSE, FALSE, FALSE }<br>
> };<br>
><br>
> static void<br>
> test_ndisstatqry (void)<br>
> {<br>
> - guint i;<br>
> + size_t i;<br>
><br>
> - for (i = 0; ndisstatqry_tests[i].str; i++) {<br>
> + for (i = 0; i < sizeof (ndisstatqry_tests) / sizeof (ndisstatqry_tests[0]); i++) {<br>
> GError *error = NULL;<br>
> gboolean ipv4_available;<br>
> gboolean ipv4_connected;<br>
> @@ -76,15 +89,18 @@ test_ndisstatqry (void)<br>
> &ipv4_connected,<br>
> &ipv6_available,<br>
> &ipv6_connected,<br>
> - &error) == TRUE);<br>
> - g_assert_no_error (error);<br>
> + &error) == ndisstatqry_tests[i].expected_result);<br>
> + if (ndisstatqry_tests[i].expected_result) {<br>
> + g_assert_no_error (error);<br>
> + g_assert (ipv4_available == ndisstatqry_tests[i].expected_ipv4_available);<br>
> + if (ipv4_available)<br>
> + g_assert (ipv4_connected == ndisstatqry_tests[i].expected_ipv4_connected);<br>
> + g_assert (ipv6_available == ndisstatqry_tests[i].expected_ipv6_available);<br>
> + if (ipv6_available)<br>
> + g_assert (ipv6_connected == ndisstatqry_tests[i].expected_ipv6_connected);<br>
> + } else<br>
> + g_assert_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED);<br>
><br>
> - g_assert (ipv4_available == ndisstatqry_tests[i].expected_ipv4_available);<br>
> - if (ipv4_available)<br>
> - g_assert (ipv4_connected == ndisstatqry_tests[i].expected_ipv4_connected);<br>
> - g_assert (ipv6_available == ndisstatqry_tests[i].expected_ipv6_available);<br>
> - if (ipv6_available)<br>
> - g_assert (ipv6_connected == ndisstatqry_tests[i].expected_ipv6_connected);<br>
> }<br>
> }<br>
><br>
<br>
<br>
</div></div></blockquote></div><br></div></div>