No SIM Slot Paths

Eric Caruso ejcaruso at chromium.org
Wed Nov 17 18:59:02 UTC 2021


New enough QMI and MBIM modems have messages to gather all the data for
each connected SIM. It's possible that the message is simply not supported
by your modem, since 1.18.2 should be new enough such that the MBIM
implementation of load_sim_slots, etc. is available.

-Eric

On Wed, Nov 17, 2021 at 12:59 PM Bushman, Jeff <jbushman at ciena.com> wrote:

> I used gdbus to introspect what was published, and It appears that
> ModemManager just doesn’t have this information – is that because of the
> particular modem I have, or the mode the modem is in?
>
>
>
> diag at de-01:/opt/open-src/ModemManager$ gdbus introspect --system --dest
> org.freedesktop.ModemManager1 --object-path
> /org/freedesktop/ModemManager1/Modem/0
>
> node /org/freedesktop/ModemManager1/Modem/0 {
>
>>
>   interface org.freedesktop.ModemManager1.Modem {
>
>>
>     properties:
>
>       readonly o Sim = '/org/freedesktop/ModemManager1/SIM/0';
>
>       readonly ao SimSlots = [];
>
>       readonly u PrimarySimSlot = 0;
>
>
>
> *From:* Bushman, Jeff <jbushman at ciena.com>
> *Sent:* Tuesday, November 16, 2021 11:23 AM
> *To:* Aleksander Morgado <aleksander at aleksander.es>
> *Cc:* modemmanager-devel at lists.freedesktop.org
> *Subject:* Re: No SIM Slot Paths
>
>
>
> Thanks for the reply Aleksander. The calls are made before I start the
> main loop. I used the synchronous code path from mmcli as an example, along
> with the main loop call from the sms-c-sync.c. Below is my demo code and
> program output.
>
>
>
> #define _GNU_SOURCE
>
> #include <stdlib.h>
>
>
>
> #define G_LOG_USE_STRUCTURED
>
> #include <libmm-glib.h>
>
>
>
> static gboolean
>
> loop_is_idle(GMainLoop *loop)
>
> {
>
>     g_print("exiting main loop\n");
>
>     g_main_loop_quit(loop);
>
>     return G_SOURCE_REMOVE;
>
> }
>
>
>
> static void dump_modem_info(gpointer obj, gpointer unused)
>
> {
>
>     /* get the modem interface */
>
>     MMObject *modem = (MMObject *)obj;
>
>     MMModem *modem_if = mm_object_peek_modem(modem);
>
>     if (!modem_if)
>
>     {
>
>         g_printerr("error: modem-interface not found");
>
>         return;
>
>     }
>
>
>
>     const gchar *sim_path = mm_modem_get_sim_path(modem_if);
>
>     g_print("Primary SIM path: %s\n", sim_path ? sim_path : "empty");
>
>
>
>     const gchar * const * sim_paths =
> mm_modem_get_sim_slot_paths(modem_if);
>
>     g_print("SIM Paths:\n");
>
>     gint i;
>
>     for (i = 0; sim_paths[i]; ++i)
>
>         g_print("    [%d] %s\n", i, sim_paths[i]);
>
>     if (i == 0)
>
>         g_print("    No SIM paths found\n");
>
>
>
>     g_print("Primary SIM slot: %u\n",
> mm_modem_get_primary_sim_slot(modem_if));
>
>
>
>     g_autoptr(GError) error = NULL;
>
>     g_autoptr(GPtrArray) sims = mm_modem_list_sim_slots_sync(modem_if,
> NULL, &error);
>
>     if (error)
>
>     {
>
>        g_printerr("error: couldn't get SIM list: %s\n", error->message);
>
>        g_clear_error(&error);
>
>     }
>
>     g_print("SIMS array has %u elements\n", sims->len);
>
> }
>
>
>
> static void
>
> list_current_modems(MMManager *mm_mgr)
>
> {
>
>     GList *modems =
> g_dbus_object_manager_get_objects(G_DBUS_OBJECT_MANAGER(mm_mgr));
>
>     g_list_foreach(modems, dump_modem_info, NULL);
>
>     g_list_free_full(modems, g_object_unref);
>
> }
>
>
>
> gint
>
> main(gint argc, gchar **argv)
>
> {
>
>     g_autoptr(GError) error = NULL;
>
>     g_autoptr(GDBusConnection) dbus_conn =
> g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
>
>     if (!dbus_conn)
>
>     {
>
>         g_printerr("error: couldn't connect to D-Bus: %s\n",
>
>                    error ? error->message : "unknown");
>
>         exit(EXIT_FAILURE);
>
>     }
>
>
>
>     g_autoptr(MMManager) mm_mgr = mm_manager_new_sync(dbus_conn,
>
>
> G_DBUS_OBJECT_MANAGER_CLIENT_FLAGS_DO_NOT_AUTO_START,
>
>                                     NULL,
>
>                                     &error);
>
>
>
>     if (!mm_mgr)
>
>     {
>
>         g_printerr("error: couldn't manager: %s\n",
>
>                    error ? error->message : "unknown");
>
>         exit(EXIT_FAILURE);
>
>     }
>
>
>
>     list_current_modems(mm_mgr);
>
>
>
>     /* Run the main loop to clean up any lingering async tasks */
>
>     {
>
>         g_autoptr(GMainLoop) loop = g_main_loop_new(NULL, FALSE);
>
>         g_idle_add((GSourceFunc)loop_is_idle, loop);
>
>         g_main_loop_run(loop);
>
>     }
>
>
>
>     return EXIT_SUCCESS;
>
> }
>
>
>
>
>
> Primary SIM path: /org/freedesktop/ModemManager1/SIM/0
>
> SIM Paths:
>
>     No SIM paths found
>
> Primary SIM slot: 0
>
> SIMS array has 0 elements
>
> exiting main loop
>
>
>
> *From:* Aleksander Morgado <aleksander at aleksander.es>
> *Sent:* Tuesday, November 16, 2021 12:16 AM
> *To:* Bushman, Jeff <jbushman at ciena.com>
> *Cc:* modemmanager-devel at lists.freedesktop.org
> *Subject:* [**EXTERNAL**] Re: No SIM Slot Paths
>
>
>
> Hey,
>
>
>
> On Tue, Nov 16, 2021 at 12:08 AM Bushman, Jeff <jbushman at ciena.com> wrote:
>
> I’m just getting started with interfacing with the ModemManager via
> mm-glib. I am experimenting with the synchronous SIM slot APIs, and they
> don’t seem to work.
>
> I am running ModemManager 1.18.2 on Ubuntu 20.04 with a Sierra Wireless
> MC7455-based USB modem running in MBIM mode and an AT&T SIM.
>
>
>
> If I call mm_modem_get_sim_path() I do get the primary (only) SIM path
> back.
>
>
>
> If I call mm_modem_get_sim_slot_paths(), I get an empty array back (the
> first element is NULL).
>
> If I call mm_modem_get_primary_sim_slot(), I get an answer of 0, although
> the documentation implies the answer should be [1..N]
>
> If I call mm_modem_list_sim_slots_sync(), I get an empty (len = 0) array
> back with no error message.
>
>
>
> Should I expect these APIs to work? I’m very new to glib and D-Bus
> programming, so debugging tips are very welcome.
>
>
>
>
>
>
>
> Are you running a GLib main loop in some way when using the sync APIs?
> Maybe these properties are not getting properly populated due to the lack
> of main loop. An example snippet of what you're doing would help.
>
>
> --
>
> Aleksander
> https://aleksander.es [aleksander.es]
> <https://urldefense.com/v3/__https:/aleksander.es__;!!OSsGDw!ckmQxfB3rnRMfXfZpbMUj00O-0rX0wz8qAVZm9buCMT-GPtp-orsXrkp_SDOGQ$>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/modemmanager-devel/attachments/20211117/55ff21f1/attachment-0001.htm>


More information about the ModemManager-devel mailing list