Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 30 Apr 2009 21:35:35 +0200
From:      Milan Obuch <freebsd-usb@dino.sk>
To:        "M. Warner Losh" <imp@bsdimp.com>
Cc:        freebsd-usb@freebsd.org
Subject:   Re: u3g serial device name query
Message-ID:  <200904302135.36565.freebsd-usb@dino.sk>
In-Reply-To: <20090430.084146.-1784899405.imp@bsdimp.com>
References:  <200904301221.44674.freebsd-usb@dino.sk> <200904301412.38313.freebsd-usb@dino.sk> <20090430.084146.-1784899405.imp@bsdimp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thursday 30 April 2009 16:41:46 M. Warner Losh wrote:
> In message: <200904301412.38313.freebsd-usb@dino.sk>

[ snip ]

> : > USB serial devices have their own unit management. There is however a
> : > way to override the unit number through the "usb2_com_tty_name"
> : > callback, which requires some code changes to the u3g driver.
> : >
> : > All USB modems and serial adapters end up with the same naming
> : > prefix: /dev/cuaU%d.%d, so the assigned numbers must be serialised.
> : >
> : > What we could do is to have a separate naming prefix for 3G modems, and
> : > use the device_get_unit() for unit number.
> : >
> : > See: src/sys/dev/usb/serial and usb_serial.c
> :
> : I looked over usb2_com_attach_tty function in usb_serial.c, and somewhere
> : after call to tty_makedev (where a DPRINT is too) I could put a devctl
> : call.
> :
> : All I need for it would be device name. In /var/log/message file I see a
> : line telling 'u3g0 : Found 2 ports' just after usb2_com_attach_tty
> : function is called. If you could tell me how I can get 'u3g0' name via sc
> : argument in usb2_com_attach_tty function, I can solve this with no other
> : change.
>
> While I have issues with the names of the new ttys, since they are
> gratuitously different than the past, it isn't the fundamental
> problem.
>
> What we really need in devd is the ability to tie events to /dev
> entries appearing rather than at device attach time, since the two can
> be different...
>
> What you really need to do is to take the u3g0 attach, find out what
> its children are and use that to figure out things...
>
> Warner

First I tried simple patch

--- usb_serial.c.orig   2009-04-07 11:15:03.000000000 +0200
+++ usb_serial.c        2009-04-30 14:41:38.000000000 +0200
@@ -328,6 +328,7 @@
        sc->sc_tty = tp;

        DPRINTF("ttycreate: %s\n", buf);
+       devctl_notify("UCOM",buf,"ATTACH",NULL);
        usb2_cv_init(&sc->sc_cv, "usb2_com");

 done:

It shows me 'U0.0', 'U0.1' or 'U0' etc, but no parent class like u3g0 or 
uplcom. I tried to find to way how to get it, but it was not easy and 
universal.

My second try is

--- u3g.c.orig  2009-04-07 11:15:03.000000000 +0200
+++ u3g.c       2009-04-30 21:15:53.000000000 +0200
@@ -50,6 +50,8 @@

 #include <dev/usb/serial/usb_serial.h>

+#include <sys/conf.h>
+
 #if USB_DEBUG
 static int u3g_debug = 0;

@@ -529,6 +531,10 @@
                device_printf(dev, "Found %u ports.\n",
                    (unsigned int)sc->sc_numports);
        }
+
+       for (i = 0; i < sc->sc_numports; i++)
+               device_printf(dev, "%d %s\n", i, 
sc->sc_ucom[i].sc_tty->t_dev->si_name);
+
        return (0);

 detach:

which does almost what I want, just shows 'u3g0: 0 ttyU0.0', but... You need 
cuaU0.0 in ppp.conf :( I can replace device_printf with devctl_notify and 
change it a little, simplest would be to use 'si_name + 3' so the 'tty' part 
would be stripped, but this is not so nice. And, again, it is not universal.
If I like to do something similar with uplcom, uark or other serial USB 
device, their drivers need to be modified too...

In any case I would like to get some more opinion on this problem and my 
simple test patches, too.

Regards,
Milan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200904302135.36565.freebsd-usb>