Re: network manager and GSM IrDA connection



On Tue, 2009-11-17 at 23:56 +0100, Ferry Toth wrote:
> I have Ubuntu Karmic which comes with 0.8.
> 
> The serial port driver is ks_959 (Kingsun dongle). The driver loads
> automatically, then I need to irattach and load ircomm_tty and sir
> stuff.
> 
> I have seen that modprobing these drivers does not trigger
> modemmanager. However it the dongle is plugged in on boot modemmanager
> does start and starts to probe the ircomm port. This is the wrong one
> as the Kingsun only supports sir and not fir. And apparently the
> init.d scripts do a little extra so that modemmanager starts.

ModemManager enforces a few rules about the device, basically whether it
has the right sysfs links set up.  We may not handle the bustype for
your device yet.  To test this, plug your device in and:

Build the attached file with:

gcc -o lsudev `pkg-config --libs --cflags glib-2.0 gudev-1.0` lsudev.c

(make sure you have headers for libgudev and glib installed)

and then run it like:

sudo ./lsudev tty

and then reply with the output?

Dan

> But I'll try your suggestions and report back.
> 
> Thanks,
> 
> 
> -- 
> Ferry Toth 
> 
> 
> -----Oorspronkelijke bericht-----
> Van: Dan Williams <dcbw redhat com>
> Aan: Ferry Toth <ftoth telfort nl>
> Cc: networkmanager-list gnome org
> Onderwerp: Re: network manager and GSM IrDA connection
> Datum: Tue, 17 Nov 2009 14:04:10 -0800
> 
> On Thu, 2009-11-12 at 22:07 +0100, Ferry Toth wrote:
> > I have a GSM with GPRS that connects using IrDA.
> > 
> > I can setup a connection manually, but I need it to be done by network
> > manager as that notifies my applications an internet connection is
> > available.
> > 
> > I can not find how to configure nm so that it is notified that irda is
> > up, so that nm can start the pppd.
> > 
> > What I am trying to achieve is let udev do the work for setting up the
> > irda connection, but don't know how nm is triggered. Do I need to send
> > a dbus message? 
> 
> NM 0.7 or 0.8?
> 
> With NM 0.7, a callout helper is used to probe the device for its
> capabilities when the serial port shows up.  But the prober is limited
> to known mobile broadband devices, and IrDA isn't one of them.  You'll
> need to find out the driver for your irda serial port (it's probably
> "ircomm_tty") and then add that to this line
> in /lib/udev/rules.d/77-nm-probe-modem-capabilities.rules :
> 
> # Only probe known mobile broadband drivers
> DRIVERS=="option|sierra|hso|cdc_acm|qcserial|moto-modem", GOTO="probe"
> 
> That will cause NM to probe the port for mobile broadband support when
> the port shows up, so make sure your phone is on and it's all connected
> and everything.
> 
> For NM 0.8, ModemManager is used and it'll just probe every serial port
> at the moment (we'll fix that).  Here, make sure it all works by
> stopping NM and modem-manager, then run "modem-manager --debug" and get
> the irda port set up and see if ModemManager find it.  If not, we can
> try to debug from there.
> 
> I'm not sure about natively supporting IrDA since that seems to be going
> out, but if the patches aren't huge it's probably a win.
> 
> Dan
> 
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; 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 option) 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.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Copyright (C) 2009 Red Hat, Inc.
 */

#include <glib.h>
#define G_UDEV_API_IS_SUBJECT_TO_CHANGE
#include <gudev/gudev.h>

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <signal.h>

static GMainLoop *loop = NULL;

static void
signal_handler (int signo)
{
	if (signo == SIGINT || signo == SIGTERM) {
		g_message ("Caught signal %d, shutting down...", signo);
		g_main_loop_quit (loop);
	}
}

static void
setup_signals (void)
{
	struct sigaction action;
	sigset_t mask;

	sigemptyset (&mask);
	action.sa_handler = signal_handler;
	action.sa_mask = mask;
	action.sa_flags = 0;
	sigaction (SIGTERM,  &action, NULL);
	sigaction (SIGINT,  &action, NULL);
}

static void
println (guint indent, const char *fmt, ...)
{
	va_list args;
	char real_fmt[1000];
	int i;

	g_return_if_fail (fmt != NULL);
	g_return_if_fail (indent < sizeof (real_fmt) - 2 - strlen (fmt));

	for (i = 0; i < indent; i++)
		real_fmt[i] = ' ';
	strcpy (&real_fmt[i], fmt);
	real_fmt[i + strlen (fmt)] = '\n';
	real_fmt[i + strlen (fmt) + 1] = '\0';

	va_start (args, fmt);
	vprintf (real_fmt, args);
	va_end (args);
}

static void
dump_device_and_parent (GUdevDevice *device, guint indent)
{
	const char **list, **iter;
	GUdevDevice *parent;
	char propstr[500];
	guint32 namelen = 0, i;

	println (indent, "------------------------------------------------------");
	println (indent, "Name:     %s", g_udev_device_get_name (device));
	println (indent, "Type:     %s", g_udev_device_get_devtype (device));
	println (indent, "Subsys:   %s", g_udev_device_get_subsystem (device));
	println (indent, "Number:   %s", g_udev_device_get_number (device));
	println (indent, "Path:     %s", g_udev_device_get_sysfs_path (device));
	println (indent, "Driver:   %s", g_udev_device_get_driver (device));
	println (indent, "Action:   %s", g_udev_device_get_action (device));
	println (indent, "Seq Num:  %s", g_udev_device_get_seqnum (device));
	println (indent, "Dev File: %s", g_udev_device_get_device_file (device));

	println (indent, "");
	println (indent, "Properties:");

	/* Get longest property name length for alignment */
	list = g_udev_device_get_property_keys (device);
	for (iter = list; iter && *iter; iter++) {
		if (strlen (*iter) > namelen)
			namelen = strlen (*iter);
	}
	namelen++;

	for (iter = list; iter && *iter; iter++) {
		strcpy (propstr, *iter);
		strcat (propstr, ":");
		for (i = 0; i < namelen - strlen (*iter); i++)
			strcat (propstr, " ");
		strcat (propstr, g_udev_device_get_property (device, *iter));
		println (indent + 2, "%s", propstr);
	}

	println (indent, "");

	parent = g_udev_device_get_parent (device);
	if (parent) {
		dump_device_and_parent (parent, indent + 4);
		g_object_unref (parent);
	}
}

static void
handle_uevent (GUdevClient *client,
               const char *action,
               GUdevDevice *device,
               gpointer user_data)
{
	const char *expected_subsys = user_data;
	const char *subsys;

	g_return_if_fail (client != NULL);
	g_return_if_fail (action != NULL);
	g_return_if_fail (device != NULL);

	/* A bit paranoid */
	subsys = g_udev_device_get_subsystem (device);
	g_return_if_fail (subsys != NULL);

	g_return_if_fail (!strcmp (subsys, expected_subsys));

	g_print ("---- (EVENT: %s) ----\n", action);
	dump_device_and_parent (device, 0);
	g_print ("\n");
}

int
main (int argc, char *argv[])
{
	GUdevClient *client;	
	const char *subsys[2] = { NULL, NULL };
	GList *list, *iter;

	if (argc != 2) {
		g_warning ("Usage: %s [subsystem]", argv[0]);
		return 1;
	}

	g_type_init ();

	loop = g_main_loop_new (NULL, FALSE);

	setup_signals ();

	subsys[0] = argv[1];
	client = g_udev_client_new (subsys);
	g_signal_connect (client, "uevent", G_CALLBACK (handle_uevent), (gpointer) subsys[0]);

	list = g_udev_client_query_by_subsystem (client, subsys[0]);
	for (iter = list; iter; iter = g_list_next (iter)) {
		dump_device_and_parent (G_UDEV_DEVICE (iter->data), 0);
		g_print ("\n");
		g_object_unref (G_UDEV_DEVICE (iter->data));
	}

	g_main_loop_run (loop);

	return 0;
}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]