<div dir="ltr"><div dir="ltr"><div>Hi,</div><div>I'm now working on a modem "Cinterion Gemalto ELS61". And I tried to use it with ModemManager.</div><div>ModemManager suggests the "Cinterion" plugin. But somehow, the AT command set and some response message format of "Cinterion Gemalto ELS61" is different from other modems supported by the "Cinterion" plugin. So I wrote a plugin named "G-ELS61" especially for it. </div><div><br></div><div>The question is, both "Cinterion" plugin and "G-ELS61" plugin support modem "Cinterion Gemalto ELS61". ModemManager will select the prior loaded plugin as best-plugin. </div><div>While the order of loading plugins is not fixed in ModemManager (Since "readdir()" returns entries in the order that files are linked in filesystem). That means ModemManager may use different plugin for the same modem on different devices.</div><div><br></div><div>Currently, I use a simple workaround to solve the issue. I sort the loading order by the plugins' filename before loading. So that I can control the loading order of my plugin by its filename. The diff log is attached below:</div><div><br></div><div>---</div><div>--- a/src/mm-plugin-manager.c</div><div>+++ b/src/mm-plugin-manager.c</div><div>@@ -56,6 +56,12 @@</div><div>     GList *device_contexts;</div><div> };</div><div> </div><div>+static gint compare_fname (gconstpointer a, gconstpointer b) {</div><div>+    gchar *fnameA = (gchar *) a;</div><div>+    gchar *fnameB = (gchar *) b;</div><div>+    return strcmp(fnameA, fnameB);</div><div>+}</div><div>+</div><div> /*****************************************************************************/</div><div> /* Build plugin list for a single port */</div><div> </div><div>@@ -1544,6 +1550,7 @@</div><div>     GDir *dir = NULL;</div><div>     const gchar *fname;</div><div>     gchar *plugindir_display = NULL;</div><div>+    GList *plugins_fname = NULL, *iter;</div><div> </div><div>     if (!g_module_supported ()) {</div><div>         g_set_error (error,</div><div>@@ -1568,13 +1575,17 @@</div><div>     }</div><div> </div><div>     while ((fname = g_dir_read_name (dir)) != NULL) {</div><div>-        gchar *path;</div><div>-        MMPlugin *plugin;</div><div>-</div><div>         if (!g_str_has_suffix (fname, G_MODULE_SUFFIX))</div><div>             continue;</div><div>+        plugins_fname = g_list_append(plugins_fname, (gpointer) fname);</div><div>+    }</div><div>+    plugins_fname = g_list_sort (plugins_fname, compare_fname);</div><div>+</div><div>+    for (iter = plugins_fname; iter != NULL; iter = iter->next) {</div><div>+        gchar *path;</div><div>+        MMPlugin *plugin;</div><div> </div><div>-        path = g_module_build_path (self->priv->plugin_dir, fname);</div><div>+        path = g_module_build_path (self->priv->plugin_dir, iter->data);</div><div>         plugin = load_plugin (path);</div><div>         g_free (path);</div><div> </div><div>@@ -1590,6 +1601,7 @@</div><div>             /* Vendor specific plugin */</div><div>             self->priv->plugins = g_list_append (self->priv->plugins, plugin);</div><div>     }</div><div>+    g_list_free (plugins_fname);</div><div> </div><div>     /* Check the generic plugin once all looped */</div><div>     if (!self->priv->generic)</div><div><br></div><div>---</div><div><br></div><div>Any suggestion?</div><div><br></div><div>regards,</div><div>Ken</div></div></div>