Current-Users archive

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

Re: umodem(4) with "no pointer to data interface"



On Tue, Jan 21, 2014 at 06:55:47PM +0900, Ryo ONODERA wrote:
> 
> Without my modification, my USB modem is recognized as single ugen(4).
> 

ok, clearly not correct :)

> Here is output of usbdevs(8) without my modification.
> 
>    port 1 addr 11: full speed, power 100 mA, config 1, USB Modem(0x1329), 
> Conexant(0x0572), rev 1.00, serial 24680246
>      ugen0
> 
> and output of dmesg.
> 
> ugen0 at uhub4 port 1
> ugen0: Conexant USB Modem, rev 1.10/1.00, addr 11
> 
> 
> How to get class and subclass value for USB device?
> 

build the attached code and run that with a /dev/ugen0.00 argument.  It
should print out a bunch of information about the device.  Post the
output here and we can work out what it claims to be.

-- 
Brett Lymn
Staple Guns: because duct tape doesn't make that KerCHUNK sound - xkcd.com
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <dev/usb/usb.h>

main(int argc, char **argv)
{
        struct usb_config_desc desc;
        int fd, i, j;
        struct usb_interface_desc int_desc;
        struct usb_endpoint_desc end_desc;

        fd = open(argv[1], O_RDONLY, 0);

        if (fd < 0) {
                printf("open failed %d\n", errno);
                exit(0);
        }

        desc.ucd_config_index = USB_CURRENT_CONFIG_INDEX;

        if (ioctl(fd, USB_GET_CONFIG_DESC, &desc) < 0) {
                printf("ioctl failed, %d\n", errno);
                exit(0);
        }

        printf("length: %d\n", desc.ucd_desc.bLength);
        printf("descriptor type: %d\n", desc.ucd_desc.bDescriptorType);
        printf("total length: %d\n", desc.ucd_desc.wTotalLength);
        printf("num interface: %d\n", desc.ucd_desc.bNumInterface);
        printf("config value: %d\n", desc.ucd_desc.bConfigurationValue);
        printf("configuration: %d\n", desc.ucd_desc.iConfiguration);
        printf("Attributes: (0x%x) ", desc.ucd_desc.bmAttributes);
/*        if ((desc.ucd_desc.bmAttributes & UC_BUS_POWERED) == UC_BUS_POWERED)
                printf("Bus powered ");*/
        if ((desc.ucd_desc.bmAttributes & UC_SELF_POWERED) == UC_SELF_POWERED)
                printf("Self powered ");
        if ((desc.ucd_desc.bmAttributes & UC_REMOTE_WAKEUP)
            == UC_REMOTE_WAKEUP)
                printf("Remote Wakeup ");
        printf("\n");
        printf("max power: %d mA\n",
               desc.ucd_desc.bMaxPower * UC_POWER_FACTOR);

        int_desc.uid_config_index = USB_CURRENT_CONFIG_INDEX;
        int_desc.uid_alt_index = USB_CURRENT_ALT_INDEX;
        end_desc.ued_config_index = USB_CURRENT_CONFIG_INDEX;
        end_desc.ued_alt_index = USB_CURRENT_ALT_INDEX;
        for (i = 0; i <= desc.ucd_desc.bNumInterface - 1; i++) {
                printf("\nInterface %d:\n", i);
                int_desc.uid_interface_index = i;
                if (ioctl(fd, USB_GET_INTERFACE_DESC, &int_desc) < 0) {
                        printf("ioctl failed, %d\n", errno);
                        exit(0);
                }
                printf("  Length: %d\n", int_desc.uid_desc.bLength);
                printf("  Descriptor Type: %d\n", 
int_desc.uid_desc.bDescriptorType);
                printf("  Interface No: %d\n", 
int_desc.uid_desc.bInterfaceNumber);
                printf("  Alt Setting: %d\n", 
int_desc.uid_desc.bAlternateSetting);
                printf("  Num Endpoints: %d\n", 
int_desc.uid_desc.bNumEndpoints);
                printf("  Interface Class: %d\n", 
int_desc.uid_desc.bInterfaceClass);
                printf("  Interface SubClass: %d\n", 
int_desc.uid_desc.bInterfaceSubClass);
                printf("  Interface Protocol: %d\n", 
int_desc.uid_desc.bInterfaceProtocol);
                printf("  Interface: %d\n", int_desc.uid_desc.iInterface);

                end_desc.ued_interface_index = i;
                for (j = 0; j < int_desc.uid_desc.bNumEndpoints; j++) {
                        printf("  Endpoint %d:\n", j);
                        end_desc.ued_endpoint_index = j;
                        if (ioctl(fd, USB_GET_ENDPOINT_DESC, &end_desc) < 0) {
                                printf("ioctl failed, %d\n", errno);
                                exit(0);
                        }
                        printf("    Length: %d\n", end_desc.ued_desc.bLength);
                        printf("    Length: %d\n",
                               end_desc.ued_desc.bDescriptorType);
                        printf("    Length: (0x%x) %d ",
                               end_desc.ued_desc.bEndpointAddress,
                               UE_GET_ADDR(end_desc.ued_desc.bEndpointAddress));
                        if (UE_GET_DIR(end_desc.ued_desc.bEndpointAddress)
                            == UE_DIR_OUT)
                                printf("(out)\n");
                        else
                                printf("(in)\n");

                        printf("    Attributes: (0x%x) ",
                               end_desc.ued_desc.bmAttributes);
                        switch 
(UE_GET_XFERTYPE(end_desc.ued_desc.bmAttributes)) {
                        case UE_CONTROL:
                                printf("control ");
                                break;

                        case UE_ISOCHRONOUS:
                                printf("isochronous ");
                                break;

                        case UE_BULK:
                                printf("bulk ");
                                break;

                        case UE_INTERRUPT:
                                printf("interrupt ");
                                break;
                        }

                        switch 
(UE_GET_ISO_TYPE(end_desc.ued_desc.bmAttributes)) {

                        case UE_ISO_ASYNC:
                                printf("async");
                                break;

                        case UE_ISO_ADAPT:
                                printf("adapt");
                                break;

                        case UE_ISO_SYNC:
                                printf("sync");
                                break;
                        }
                        printf("\n");
                        printf("    Max Packet Size: %d\n",
                               end_desc.ued_desc.wMaxPacketSize);
                        printf("    Interval: %d\n",
                               end_desc.ued_desc.bInterval);
                }
        }
}


Home | Main Index | Thread Index | Old Index