Unable to initialize GDBusConnection with cellular modem on linux

264 Views Asked by At

I am currently trying to access cellular modem data from within a C application on Linux using mmlib-glib.

When trying to establish a GDBusConnection on a GFileIOStream created from a GFile from path /dev/cdc-wdm0, the call to g_dbus_connection_new_sync() hangs infinitely and gives the following error _g_dbus_worker_do_read_cb: error determining bytes needed: Unable to determine message blob length - given blob is malformed. Also, after this the modem will either become no longer available, or be kicked to a different modem number (i.e. org/freedesktop/ModemManager/Modem/2 will change to 3) I am constructing a GFile with the path /dev/cdc-wdm0, and from that initialize a GDBusConnection.

I have also tried initializing a new GIOStream and passing that to the mm_manager_scan_devices_sync() following instructions from this post but this results in the following errors :

g_dbus_connection_signal_subscribe: assertion 'sender == NULL || (g_dbus_is_name (sender) && (connection->flags & G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION))' failed

I have placed code below followed by mmcli output with modem information

#include <libmm-glib.h>
#include <gio/gio.h>
//#include <gtk/gtk.h>
#include <stdio.h>
#include <stdbool.h>




GDBusConnection *pConnection;


int main (void)
{
    printf("begin\n");

    GFile * pFile = g_file_new_for_path("/dev/cdc-wdm0");

    GFileIOStream *pStream = g_file_open_readwrite(pFile, NULL, NULL);


    pConnection= g_dbus_connection_new_sync(pStream,
                                            guid, // for server auth.
                                            G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
                                            NULL, // observer
                                            NULL, // cancellable,
                                            NULL);



    pManager = mm_manager_new_sync(pConnection,
                      G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION,
                      NULL,
                      NULL);

    mm_manager_scan_devices_sync(pManager,
                                 cancellable,
                                 NULL);

    printf("end\n");
    return(0);
}

Below is the output from modemmanager mmcli --modem=0

 ----------------------------------
  General  |                   path: /org/freedesktop/ModemManager1/Modem/0
           |              device id: 
  ----------------------------------
  Hardware |           manufacturer: Telit
           |                  model: LE910C4-NF
           |      firmware revision: 25.21.660  1  [Mar 04 2021 12:00:00]
           |         carrier config: default
           |           h/w revision: 1.30
           |              supported: gsm-umts, lte
           |                current: gsm-umts, lte
           |           equipment id: 0
  ----------------------------------
  System   |                 device: /sys/devices/platform/soc@0/32c00000.bus/32e50000.usb/ci_hdrc.1/usb1/1-1/1-1.2
           |                drivers: qmi_wwan, option
           |                 plugin: telit
           |           primary port: cdc-wdm0
           |                  ports: cdc-wdm0 (qmi), ttyUSB0 (ignored), ttyUSB1 (gps),
           |                         ttyUSB4 (ignored), wwan0 (net)
  ----------------------------------
  Status   |                   lock: sim-pin2
           |         unlock retries: sim-pin (3), sim-puk (10), sim-pin2 (10), sim-puk2 (10)
           |                  state: connected
           |            power state: on
           |            access tech: lte
           |         signal quality: 75% (cached)
  ----------------------------------
  Modes    |              supported: allowed: 3g; preferred: none
           |                         allowed: 4g; preferred: none
           |                         allowed: 3g, 4g; preferred: 4g
           |                         allowed: 3g, 4g; preferred: 3g
           |                current: allowed: 3g, 4g; preferred: 4g
  ----------------------------------
  Bands    |              supported: utran-4, utran-5, utran-2, eutran-2, eutran-4, eutran-5,
           |                         eutran-12, eutran-13, eutran-14, eutran-66, eutran-71
           |                current: utran-4, utran-5, utran-2, eutran-2, eutran-4, eutran-5,
           |                         eutran-12, eutran-13, eutran-14, eutran-66, eutran-71
  ----------------------------------
  IP       |              supported: ipv4, ipv6, ipv4v6
  ----------------------------------
  3GPP     |                   imei: 3
           |          enabled locks: fixed-dialing
           |            operator id: 311480
           |          operator name: VZW
           |           registration: home
  ----------------------------------
  3GPP EPS |    initial bearer path: /org/freedesktop/ModemManager1/Bearer/0
           |     initial bearer apn: super
           | initial bearer ip type: ipv4
  ----------------------------------
  SIM      |       primary sim path: /org/freedesktop/ModemManager1/SIM/0
           |         sim slot paths: slot 1: /org/freedesktop/ModemManager1/SIM/0 (active)
           |                         slot 2: none
  ----------------------------------
  Bearer   |                  paths: /org/freedesktop/ModemManager1/Bearer/2
           |                         /org/freedesktop/ModemManager1/Bearer/1
0

There are 0 best solutions below