<div dir="ltr"><div class="gmail_default" style="font-family:arial,helvetica,sans-serif">Awesome! Thank you!<br><br><br>Carlo</div></div><div class="gmail_extra"><br><div class="gmail_quote">On 29 May 2017 at 12:27, Aleksander Morgado <span dir="ltr"><<a href="mailto:aleksander@aleksander.es" target="_blank">aleksander@aleksander.es</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 29/05/17 09:48, Carlo Lobrano wrote:<br>
> Currently Dell plugin implements a retry logic of three commands<br>
> (AT+GMI, AT+CGMI, ATI1I2I3) to detect modem's vendor string.<br>
> Moreover, since Telit modems always reply to the first command, to speed<br>
> the probing time up, those modem are tagged with an Udev rule so that we<br>
> can avoid sending the other two commands at all.<br>
><br>
> However, the retry logic is in case a port needs some time to reply, so<br>
> it makes sense to apply it only to the first command. Then if the port still<br>
> does not respond with any kind of reply, that probably means that it is not<br>
> AT capable and we can skip the other AT commands as well.<br>
><br>
> Then, this patch:<br>
> - sets a maximum number of timeouts for AT+GMI to 3. After this<br>
>   timeouts, the port is considered not AT-capable.<br>
> - sets AT+CGMI and ATI1I2I3 to be sent only once.<br>
> - removes Dell udev rule for tagging Telit Modems.<br>
><br>
> ---<br>
><br>
> Patch v2:<br>
><br>
> As per Aleksander's code review<br>
><br>
> - mm_port_probe_set_result_at set to false when run out of retries for manufacturer (and yes, I do confirm that without this line, I saw other "AT" commands sent to the ports).<br>
> - fixed debug logs<br>
><br>
> @Aleksander I'm going to reply to this email with the logs you requested.<br>
><br>
<br>
</span>Pushed to git master, thanks!<br>
<br>
The logs look good to be, btw, thanks for sending them.<br>
<div><div class="h5"><br>
> ---<br>
>  plugins/dell/77-mm-dell-port-<wbr>types.rules |  4 ----<br>
>  plugins/dell/mm-plugin-dell.c            | 29 ++++++++++++++++++-----------<br>
>  2 files changed, 18 insertions(+), 15 deletions(-)<br>
><br>
> diff --git a/plugins/dell/77-mm-dell-<wbr>port-types.rules b/plugins/dell/77-mm-dell-<wbr>port-types.rules<br>
> index bbb59b9..206fb6e 100644<br>
> --- a/plugins/dell/77-mm-dell-<wbr>port-types.rules<br>
> +++ b/plugins/dell/77-mm-dell-<wbr>port-types.rules<br>
> @@ -8,9 +8,5 @@ GOTO="mm_dell_port_types_end"<br>
>  LABEL="mm_dell_vendorcheck"<br>
>  SUBSYSTEMS=="usb", ATTRS{bInterfaceNumber}=="?*", ENV{.MM_USBIFNUM}="$attr{<wbr>bInterfaceNumber}"<br>
><br>
> -# DW5580 is a Dell-branded Telit modem<br>
> -# tag is needed here for dynamic port recognition<br>
> -ATTRS{idVendor}=="413c", ATTRS{idProduct}=="81ba", ENV{ID_MM_TELIT_PORTS_TAGGED}=<wbr>"1"<br>
> -<br>
>  GOTO="mm_dell_port_types_end"<br>
>  LABEL="mm_dell_port_types_end"<br>
> diff --git a/plugins/dell/mm-plugin-dell.<wbr>c b/plugins/dell/mm-plugin-dell.<wbr>c<br>
> index f9dfd1a..fbb0a9c 100644<br>
> --- a/plugins/dell/mm-plugin-dell.<wbr>c<br>
> +++ b/plugins/dell/mm-plugin-dell.<wbr>c<br>
> @@ -45,6 +45,8 @@<br>
>  #include "mm-broadband-modem-mbim.h"<br>
>  #endif<br>
><br>
> +#define MAX_PORT_PROBE_TIMEOUTS 3<br>
> +<br>
>  G_DEFINE_TYPE (MMPluginDell, mm_plugin_dell, MM_TYPE_PLUGIN)<br>
><br>
>  MM_PLUGIN_DEFINE_MAJOR_VERSION<br>
> @@ -70,6 +72,7 @@ typedef struct {<br>
>      guint gmi_retries;<br>
>      guint cgmi_retries;<br>
>      guint ati_retries;<br>
> +    guint timeouts;<br>
>  } CustomInitContext;<br>
><br>
>  static void<br>
> @@ -140,6 +143,8 @@ static void custom_init_step (CustomInitContext *ctx);<br>
>  static void<br>
>  custom_init_step_next_command (CustomInitContext *ctx)<br>
>  {<br>
> +    ctx->timeouts = 0;<br>
> +<br>
>      if (ctx->gmi_retries > 0)<br>
>          ctx->gmi_retries = 0;<br>
>      else if (ctx->cgmi_retries > 0)<br>
> @@ -169,6 +174,7 @@ response_ready (MMPortSerialAt *port,<br>
>              return;<br>
>          }<br>
>          /* Directly retry same command on timeout */<br>
> +        ctx->timeouts++;<br>
>          custom_init_step (ctx);<br>
>          g_error_free (error);<br>
>          return;<br>
> @@ -269,6 +275,13 @@ custom_init_step (CustomInitContext *ctx)<br>
>      }<br>
>  #endif<br>
><br>
> +    if (ctx->timeouts >= MAX_PORT_PROBE_TIMEOUTS) {<br>
> +        mm_dbg ("(Dell) couldn't detect real manufacturer in (%s): too many timeouts",<br>
> +                mm_port_get_device (MM_PORT (ctx->port)));<br>
> +        mm_port_probe_set_result_at (ctx->probe, FALSE);<br>
> +        goto out;<br>
> +    }<br>
> +<br>
>      if (ctx->gmi_retries > 0) {<br>
>          ctx->gmi_retries--;<br>
>          mm_port_serial_at_command (ctx->port,<br>
> @@ -309,9 +322,10 @@ custom_init_step (CustomInitContext *ctx)<br>
>          return;<br>
>      }<br>
><br>
> -    /* Finish custom_init */<br>
> -    mm_dbg ("(Dell) couldn't flip secondary port to AT in (%s): all retries consumed",<br>
> +    mm_dbg ("(Dell) couldn't detect real manufacturer in (%s): all retries consumed",<br>
>              mm_port_get_device (MM_PORT (ctx->port)));<br>
> +out:<br>
> +    /* Finish custom_init */<br>
>      g_simple_async_result_set_op_<wbr>res_gboolean (ctx->result, TRUE);<br>
>      custom_init_context_complete_<wbr>and_free (ctx);<br>
>  }<br>
> @@ -337,15 +351,8 @@ dell_custom_init (MMPortProbe *probe,<br>
>      ctx->port = g_object_ref (port);<br>
>      ctx->cancellable = cancellable ? g_object_ref (cancellable) : NULL;<br>
>      ctx->gmi_retries = 3;<br>
> -    ctx->cgmi_retries = 3;<br>
> -    ctx->ati_retries = 3;<br>
> -<br>
> -    /* Dell-branded Telit modems always answer to +GMI<br>
> -     * Avoid +CGMI and ATI sending for minimizing port probing time */<br>
> -    if (mm_kernel_device_get_global_<wbr>property_as_boolean (port_device, "ID_MM_TELIT_PORTS_TAGGED")) {<br>
> -        ctx->cgmi_retries = 0;<br>
> -        ctx->ati_retries = 0;<br>
> -    }<br>
> +    ctx->cgmi_retries = 1;<br>
> +    ctx->ati_retries = 1;<br>
><br>
>      custom_init_step (ctx);<br>
>  }<br>
><br>
<br>
<br>
--<br>
</div></div>Aleksander<br>
<a href="https://aleksander.es" rel="noreferrer" target="_blank">https://aleksander.es</a><br>
</blockquote></div><br></div>