No SIM Slot Paths

Bushman, Jeff jbushman at
Wed Nov 17 17:59:27 UTC 2021

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 {
      readonly o Sim = '/org/freedesktop/ModemManager1/SIM/0';
      readonly ao SimSlots = [];
      readonly u PrimarySimSlot = 0;

From: Bushman, Jeff <jbushman at>
Sent: Tuesday, November 16, 2021 11:23 AM
To: Aleksander Morgado <aleksander at>
Cc: modemmanager-devel at
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>

#include <libmm-glib.h>

static gboolean
loop_is_idle(GMainLoop *loop)
    g_print("exiting main loop\n");
    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");

    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_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);

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");

    g_autoptr(MMManager) mm_mgr = mm_manager_new_sync(dbus_conn,

    if (!mm_mgr)
        g_printerr("error: couldn't manager: %s\n",
                   error ? error->message : "unknown");


    /* 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);

    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<mailto:aleksander at>>
Sent: Tuesday, November 16, 2021 12:16 AM
To: Bushman, Jeff <jbushman at<mailto:jbushman at>>
Cc: modemmanager-devel at<mailto:modemmanager-devel at>
Subject: [**EXTERNAL**] Re: No SIM Slot Paths


On Tue, Nov 16, 2021 at 12:08 AM Bushman, Jeff <jbushman at<mailto:jbushman at>> 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 []<;!!OSsGDw!ckmQxfB3rnRMfXfZpbMUj00O-0rX0wz8qAVZm9buCMT-GPtp-orsXrkp_SDOGQ$>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ModemManager-devel mailing list