Requesting help mapping a USB descriptor to its USB-serial device.

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

 



Short version:

I need to know how, from a USB device descriptor associated with a
USB-serial device, I can get the USB-serial device's minor number.

I'm using Ubuntu 9.10 and have libusb-1.0.0 available. I have
successfully written code to walk the enumerated-devices list.

Long version:

I lead the GPSD project, which maintains a service daemon for managing
GPS and AIS sensors. The daemon acts as a device multiplexer so
multiple location-aware apps won't contend for the same serial GPS
device, and also specializes in knowing about GPS reporting protocols
far too various and horrible to be inflicted on application
developers.

Some of our supported device use USB. Most simulate a plain serial
device over USB; GPSD handles those nicely, using hotplug and protocol
autodetection to configure them in and out without user intervention.

There is, however, one bizarre special case, which is Garmin GPSes
identified as 091e:0003. This family of devices emits USB natively;
packet boundaries are indicated to the software on the other end of
the wire by zero-length reads.  If one attempts to treat this as
a normal USB-serial device, hilarity will ensue.

There is a shim, a kernel module called garmin_gps, that handles the
USB reading and pretends to be a plain serial device. It aggregates
each packet, surrounds it with leading/trailing DLEs, DLE-stuffs the
contant. This happens to match what an RS232 Garmin does.

All this is relevant because, by design, gpsd has no prior knowledge
about what is on the other end of a tty port when the hotplug system
tells it one has gone live and might be GPS. The port could be
connected to a conventional serial device, a USB-serial interface, or
a Garmin GPS via the shim.  These require slightly different
initializations, so gpsd has to figure out what it's dealing with
in order to proceed.

To detect Garmin GPSes, we have a function that grovels through
the deprecated /proc/bus/usb/devices interface. Today I replaced
this with a simple device-list check using libusb.

Both probes have the same drawback.  They only can tell us if a Garmin USB
GPS, 091e:0003, is connected to the host.  They can't tell us if it's
connected to *the /dev/tty/USB device we just opened*.  So this
probe will give good results only if there is exactly one USB GPS
attached.

So: I have the pathname of a USB-serial device, and thus its minor
number.  I have a list of USB device descriptors from libusb. How
do I tell which device descriptor correspons to my /dev/ttyUSB*?
-- 
		<a href="http://www.catb.org/~esr/";>Eric S. Raymond</a>

The direct use of physical force is so poor a solution to the problem of
limited resources that it is commonly employed only by small children and
great nations.		-- David Friedman
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux