Current-Users archive

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

Re: USB networking (cdce) with Linux host (g_ether)



Hi,

From: Martin Husemann <martin%duskware.de@localhost>, Date: Fri, 3 Apr 2015 19:44:09 +0200

> On Fri, Apr 03, 2015 at 05:02:15PM +0200, Christof Meerwald wrote:
>> I have now enabled the umodem driver again, but reverted
>> /src/sys/dev/usb/umodem.c to revision 1.65 and it's still working for
>> me. So looks like the changes done in r1.66 result in the umodem
>> driver kicking in (and interfering with the cdce driver) when it
>> shouldn't. Does that make some sense to anyone?
>> 
>> http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/usb/umodem.c.diff?r1=1.65&r2=1.66&only_with_tag=MAIN&f=h
> 
> Good catch - I guess we will need to make the additional match that
> Onodera-san was after more specific.
> 
> And we also need to add code to print interface details to usbdevs(8).

Hi,

blymn@ provides me the program to print interface detail.
See http://mail-index.netbsd.org/current-users/2014/01/21/msg024127.html
or attached probe_usb.c .

Please remove cdce(4) and umodem(4) entries from your kernel configuration
file (your device should be recognized as ugen(4)) and run
$ gcc -o probe_usb probe_usb.c
# ./probe_usb /dev/ugen0.00

Thank you.

--
Ryo ONODERA // ryo_on%yk.rim.or.jp@localhost
PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3
#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