[PATCH] huawei: handle unquoted strings in ^SYSINFOEX response

Aleksander Morgado aleksander at lanedo.com
Fri Oct 11 12:06:21 PDT 2013


On 11/10/13 19:44, Ben Chan wrote:
> The patch modifies sysinfoex_parse() in MMBroadbandModemHuawei to handle
> unquoted <sysmode_name> and <submode_name> fields in ^SYSINFOEX
> responses, which are seen on some Huawei modems (e.g. E303).
> ---


Could you move the whole parsing method to mm-modem-helpers-huawei.[h|c]
and setup some unit tests in test-modem-helpers-huawei,c? We should
really be doing that with all response parsing methods.


> After applying this patch, here's what I observed on E303 and MU736:
> 
> E303:
>   [mm-at-serial-port.c:436] debug_log(): (ttyUSB2): --> 'AT^SYSINFOEX<CR>'
>   [mm-at-serial-port.c:436] debug_log(): (ttyUSB2): <-- '<CR><LF>^SYSINFOEX:2,3,0,1,,1,GSM,3,EDGE<CR><LF><CR><LF>OK<CR><LF>'
>   [huawei/mm-broadband-modem-huawei.c:674] load_access_technologies_finish(): Access Technology: 'edge'
> 
> MU736:
>   [mm-at-serial-port.c:436] debug_log(): (ttyUSB0): --> 'AT^SYSINFOEX<CR>'
>   [mm-at-serial-port.c:436] debug_log(): (ttyUSB0): <-- '<CR><LF>^SYSINFOEX:2,3,0,1,0,3,"WCDMA",44,"HSPA"<CR><LF><CR><LF>OK<CR><LF>'
>   [huawei/mm-broadband-modem-huawei.c:674] load_access_technologies_finish(): Access Technology: 'hspa'
> 
>  plugins/huawei/mm-broadband-modem-huawei.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c
> index 4f231df..1629b58 100644
> --- a/plugins/huawei/mm-broadband-modem-huawei.c
> +++ b/plugins/huawei/mm-broadband-modem-huawei.c
> @@ -202,11 +202,13 @@ sysinfoex_parse (const char *reply,
>      /* Format:
>       *
>       * ^SYSINFOEX: <srv_status>,<srv_domain>,<roam_status>,<sim_state>,<reserved>,<sysmode>,<sysmode_name>,<submode>,<submode_name>
> +     *
> +     * <sysmode_name> and <submode_name> may not be quoted on some Huawei modems (e.g. E303).
>       */
>  
>      /* ^SYSINFOEX:2,3,0,1,,3,"WCDMA",41,"HSPA+" */
>  
> -    r = g_regex_new ("\\^SYSINFOEX:\\s*(\\d+),(\\d+),(\\d+),(\\d+),?(\\d*),(\\d+),\"(.*)\",(\\d+),\"(.*)\"$", 0, 0, NULL);
> +    r = g_regex_new ("\\^SYSINFOEX:\\s*(\\d+),(\\d+),(\\d+),(\\d+),?(\\d*),(\\d+),\"?([^\"]*)\"?,(\\d+),\"?([^\"]*)\"?$", 0, 0, NULL);
>      g_assert (r != NULL);
>  
>      matched = g_regex_match_full (r, reply, -1, 0, 0, &match_info, &match_error);
> 


-- 
Aleksander


More information about the ModemManager-devel mailing list