Files
ModemManager/plugins/option/mm-plugin-hso.c
Aleksander Morgado a29610f25d plugin,port-probe: always cast SEND_DELAY value to guint64
Program received signal SIGSEGV, Segmentation fault.
    strchr () at ../sysdeps/arm/armv6/strchr.S:28
    28    ../sysdeps/arm/armv6/strchr.S: No such file or directory.
    (gdb) bt
    #0  strchr () at ../sysdeps/arm/armv6/strchr.S:28
    #1  0x76b121c8 in g_param_spec_pool_lookup () from ~/buildroot/output/staging/lib/libgobject-2.0.so.0
    #2  0x76b0cf44 in g_object_new_valist () from ~/buildroot/output/staging/lib/libgobject-2.0.so.0
    #3  0x76b0d39c in g_object_new () from ~/buildroot/output/staging/lib/libgobject-2.0.so.0
    #4  0x75f75e40 in mm_plugin_create () at ublox/mm-plugin-ublox.c:99
    #5  0x00031550 in load_plugin (path=0xe9b68 "/usr/lib/ModemManager/libmm-plugin-ublox.so") at mm-plugin-manager.c:1521
    #6  load_plugins (error=0x7efffa68, self=0xdc4f0) at mm-plugin-manager.c:1574
    #7  initable_init (initable=<optimized out>, cancellable=<optimized out>, error=0x7efffa68) at mm-plugin-manager.c:1679
    #8  0x76b9b278 in g_initable_new_valist () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #9  0x76b9b2e0 in g_initable_new () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #10 0x000324d0 in mm_plugin_manager_new (plugin_dir=0xe9c40 "/usr/lib/ModemManager", error=error@entry=0x7efffa68) at mm-plugin-manager.c:1620
    #11 0x0002da08 in initable_init (initable=0xddb40, cancellable=<optimized out>, error=0x7efffa68) at mm-base-manager.c:1113
    #12 0x76b9b278 in g_initable_new_valist () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #13 0x76b9b2e0 in g_initable_new () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #14 0x0002e81c in mm_base_manager_new (connection=connection@entry=0xe1070, plugin_dir=plugin_dir@entry=0x9efb0 "/usr/lib/ModemManager",
        auto_scan=auto_scan@entry=1, initial_kernel_events=initial_kernel_events@entry=0x0, enable_test=0, error=0x7efffa68, error@entry=0x7efffa60)
        at mm-base-manager.c:957
    #15 0x0002b6ec in bus_acquired_cb (connection=0xe1070, name=<optimized out>, user_data=<optimized out>) at main.c:87
    #16 0x76c26864 in connection_get_cb () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #17 0x76bc76cc in g_task_return_now () from ~/buildroot/output/staging/lib/libgio-2.0.so.0
    #18 0x76bc7d50 in g_task_return () from
    ~/buildroot/output/staging/lib/libgio-2.0.so.0

See similar bug in GStreamer:
https://bugzilla.gnome.org/show_bug.cgi?id=740191
2017-09-05 20:16:18 +02:00

206 lines
7.8 KiB
C

/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your hso) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details:
*
* Copyright (C) 2008 - 2009 Novell, Inc.
* Copyright (C) 2009 - 2012 Red Hat, Inc.
* Copyright (C) 2012 Aleksander Morgado <aleksander@gnu.org>
*/
#include <string.h>
#include <gmodule.h>
#define _LIBMM_INSIDE_MM
#include <libmm-glib.h>
#include "mm-private-boxed-types.h"
#include "mm-plugin-hso.h"
#include "mm-broadband-modem-hso.h"
#include "mm-log.h"
G_DEFINE_TYPE (MMPluginHso, mm_plugin_hso, MM_TYPE_PLUGIN)
MM_PLUGIN_DEFINE_MAJOR_VERSION
MM_PLUGIN_DEFINE_MINOR_VERSION
/*****************************************************************************/
/* Custom init */
#define TAG_HSO_AT_CONTROL "hso-at-control"
#define TAG_HSO_AT_APP "hso-at-app"
#define TAG_HSO_AT_MODEM "hso-at-modem"
#define TAG_HSO_AT_GPS_CONTROL "hso-at-gps-control"
#define TAG_HSO_GPS "hso-gps"
#define TAG_HSO_DIAG "hso-diag"
static gboolean
hso_custom_init_finish (MMPortProbe *probe,
GAsyncResult *result,
GError **error)
{
return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error);
}
static void
hso_custom_init (MMPortProbe *probe,
MMPortSerialAt *port,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
MMKernelDevice *kernel_port;
GSimpleAsyncResult *result;
const gchar *subsys, *sysfs_path;
subsys = mm_port_probe_get_port_subsys (probe);
kernel_port = mm_port_probe_peek_port (probe);
sysfs_path = mm_kernel_device_get_sysfs_path (kernel_port);
if (g_str_equal (subsys, "tty")) {
gchar *hsotype_path;
gchar *contents = NULL;
hsotype_path = g_build_filename (sysfs_path, "hsotype", NULL);
if (g_file_get_contents (hsotype_path, &contents, NULL, NULL)) {
mm_dbg ("HSO port type %s: %s", hsotype_path, contents);
if (g_str_has_prefix (contents, "Control")) {
g_object_set_data (G_OBJECT (probe), TAG_HSO_AT_CONTROL, GUINT_TO_POINTER (TRUE));
mm_port_probe_set_result_at (probe, TRUE);
} else if (g_str_has_prefix (contents, "Application")) {
g_object_set_data (G_OBJECT (probe), TAG_HSO_AT_APP, GUINT_TO_POINTER (TRUE));
mm_port_probe_set_result_at (probe, TRUE);
} else if (g_str_has_prefix (contents, "Modem")) {
g_object_set_data (G_OBJECT (probe), TAG_HSO_AT_MODEM, GUINT_TO_POINTER (TRUE));
mm_port_probe_set_result_at (probe, TRUE);
} else if (g_str_has_prefix (contents, "GPS Control")) {
g_object_set_data (G_OBJECT (probe), TAG_HSO_AT_GPS_CONTROL, GUINT_TO_POINTER (TRUE));
mm_port_probe_set_result_at (probe, TRUE);
} else if (g_str_has_prefix (contents, "GPS")) {
/* Not an AT port, but the port to grab GPS traces */
g_object_set_data (G_OBJECT (probe), TAG_HSO_GPS, GUINT_TO_POINTER (TRUE));
mm_port_probe_set_result_at (probe, FALSE);
mm_port_probe_set_result_qcdm (probe, FALSE);
} else if (g_str_has_prefix (contents, "Diag")) {
g_object_set_data (G_OBJECT (probe), TAG_HSO_DIAG, GUINT_TO_POINTER (TRUE));
mm_port_probe_set_result_at (probe, FALSE);
/* Don't automatically tag as QCDM, as the 'hso' driver reports
* a DIAG port for some Icera-based modems, which don't have
* QCDM ports since they aren't made by Qualcomm.
*/
}
g_free (contents);
}
g_free (hsotype_path);
}
result = g_simple_async_result_new (G_OBJECT (probe),
callback,
user_data,
hso_custom_init);
g_simple_async_result_set_op_res_gboolean (result, TRUE);
g_simple_async_result_complete_in_idle (result);
g_object_unref (result);
}
/*****************************************************************************/
static MMBaseModem *
create_modem (MMPlugin *self,
const gchar *uid,
const gchar **drivers,
guint16 vendor,
guint16 product,
GList *probes,
GError **error)
{
return MM_BASE_MODEM (mm_broadband_modem_hso_new (uid,
drivers,
mm_plugin_get_name (self),
vendor,
product));
}
static gboolean
grab_port (MMPlugin *self,
MMBaseModem *modem,
MMPortProbe *probe,
GError **error)
{
const gchar *subsys;
MMPortSerialAtFlag pflags = MM_PORT_SERIAL_AT_FLAG_NONE;
MMPortType port_type;
subsys = mm_port_probe_get_port_subsys (probe);
port_type = mm_port_probe_get_port_type (probe);
/* Detect AT port types */
if (g_str_equal (subsys, "tty")) {
if (g_object_get_data (G_OBJECT (probe), TAG_HSO_AT_CONTROL))
pflags = MM_PORT_SERIAL_AT_FLAG_PRIMARY;
else if (g_object_get_data (G_OBJECT (probe), TAG_HSO_AT_APP))
pflags = MM_PORT_SERIAL_AT_FLAG_SECONDARY;
else if (g_object_get_data (G_OBJECT (probe), TAG_HSO_AT_GPS_CONTROL))
pflags = MM_PORT_SERIAL_AT_FLAG_GPS_CONTROL;
else if (g_object_get_data (G_OBJECT (probe), TAG_HSO_AT_MODEM))
pflags = MM_PORT_SERIAL_AT_FLAG_PPP;
else if (g_object_get_data (G_OBJECT (probe), TAG_HSO_GPS)) {
/* Not an AT port, but the port to grab GPS traces */
g_assert (port_type == MM_PORT_TYPE_UNKNOWN);
port_type = MM_PORT_TYPE_GPS;
}
}
return mm_base_modem_grab_port (modem,
mm_port_probe_peek_port (probe),
port_type,
pflags,
error);
}
/*****************************************************************************/
G_MODULE_EXPORT MMPlugin *
mm_plugin_create (void)
{
static const gchar *subsystems[] = { "tty", "net", NULL };
static const gchar *drivers[] = { "hso", NULL };
static const MMAsyncMethod custom_init = {
.async = G_CALLBACK (hso_custom_init),
.finish = G_CALLBACK (hso_custom_init_finish),
};
return MM_PLUGIN (
g_object_new (MM_TYPE_PLUGIN_HSO,
MM_PLUGIN_NAME, "Option High-Speed",
MM_PLUGIN_ALLOWED_SUBSYSTEMS, subsystems,
MM_PLUGIN_ALLOWED_DRIVERS, drivers,
MM_PLUGIN_ALLOWED_AT, TRUE,
MM_PLUGIN_ALLOWED_QCDM, TRUE,
MM_PLUGIN_CUSTOM_INIT, &custom_init,
MM_PLUGIN_SEND_DELAY, (guint64) 0,
NULL));
}
static void
mm_plugin_hso_init (MMPluginHso *self)
{
}
static void
mm_plugin_hso_class_init (MMPluginHsoClass *klass)
{
MMPluginClass *plugin_class = MM_PLUGIN_CLASS (klass);
plugin_class->create_modem = create_modem;
plugin_class->grab_port = grab_port;
}