当前位置: 首页>>代码示例>>Java>>正文


Java UsbConstants.USB_ENDPOINT_XFER_CONTROL属性代码示例

本文整理汇总了Java中android.hardware.usb.UsbConstants.USB_ENDPOINT_XFER_CONTROL属性的典型用法代码示例。如果您正苦于以下问题:Java UsbConstants.USB_ENDPOINT_XFER_CONTROL属性的具体用法?Java UsbConstants.USB_ENDPOINT_XFER_CONTROL怎么用?Java UsbConstants.USB_ENDPOINT_XFER_CONTROL使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.hardware.usb.UsbConstants的用法示例。


在下文中一共展示了UsbConstants.USB_ENDPOINT_XFER_CONTROL属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ConnectedUsbDevice

public ConnectedUsbDevice(UsbDeviceConnection connection, UsbInterface usbInterface) {
	this.connection = connection;
	this.usbInterface = usbInterface;
	initConnection(connection);
	int endPoints = usbInterface.getEndpointCount();
	int interfaceProtocol = usbInterface.getInterfaceProtocol();
	System.out.println("EndPoints: " + endPoints + " | interfaces: " + interfaceProtocol);
	out = usbInterface.getEndpoint(1);
	in = usbInterface.getEndpoint(2);
	for (int x = 0; x < endPoints; x++) {
		UsbEndpoint endpoint = usbInterface.getEndpoint(x);
		boolean bulk = endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK;
		boolean crtl = endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_CONTROL;
		boolean inDir = endpoint.getDirection() == UsbConstants.USB_DIR_IN;
		boolean outDir = endpoint.getDirection() == UsbConstants.USB_DIR_OUT;
		System.out.println("ID: " + x + " Bulk: " + bulk + " Ctrl: " + crtl + " Out: " + outDir + " In: " + inDir);
	}
}
 
开发者ID:grundid,项目名称:android-weather-station,代码行数:18,代码来源:ConnectedUsbDevice.java

示例2: nameForEndpointType

public static String nameForEndpointType(int type) {
    switch (type) {
        case UsbConstants.USB_ENDPOINT_XFER_BULK:
            return "Bulk";
        case UsbConstants.USB_ENDPOINT_XFER_CONTROL:
            return "Control";
        case UsbConstants.USB_ENDPOINT_XFER_INT:
            return "Interrupt";
        case UsbConstants.USB_ENDPOINT_XFER_ISOC:
            return "Isochronous";
        default:
            return "Unknown Type";
    }
}
 
开发者ID:androidthings,项目名称:sample-usbenum,代码行数:14,代码来源:UsbHelper.java

示例3: endpointTypeName

static String endpointTypeName(int type) {
    switch (type) {
        case UsbConstants.USB_ENDPOINT_XFER_BULK: return "bulk";
        case UsbConstants.USB_ENDPOINT_XFER_CONTROL: return "control";
        case UsbConstants.USB_ENDPOINT_XFER_INT: return "interrupt";
        case UsbConstants.USB_ENDPOINT_XFER_ISOC: return "isochronous";
        default: return "ERR:" + type;
    }
}
 
开发者ID:MobileChromeApps,项目名称:cordova-plugin-chrome-apps-usb,代码行数:9,代码来源:ChromeUsb.java

示例4: detectSpeed

private int detectSpeed(UsbDevice dev, UsbDeviceDescriptor devDesc) {
	int possibleSpeeds = FLAG_POSSIBLE_SPEED_LOW |
			FLAG_POSSIBLE_SPEED_FULL |
			FLAG_POSSIBLE_SPEED_HIGH;
	
	for (int i = 0; i < dev.getInterfaceCount(); i++) {
		UsbInterface iface = dev.getInterface(i);
		for (int j = 0; j < iface.getEndpointCount(); j++) {
			UsbEndpoint endpoint = iface.getEndpoint(j);
			if ((endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) ||
				(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_ISOC)) {
				// Low speed devices can't implement bulk or iso endpoints
				possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_LOW;
			}
			
			if (endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_CONTROL) {
				if (endpoint.getMaxPacketSize() > 8) {
					// Low speed devices can't use control transfer sizes larger than 8 bytes
					possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_LOW;
				}
				if (endpoint.getMaxPacketSize() < 64) {
					// High speed devices can't use control transfer sizes smaller than 64 bytes
					possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_HIGH;
				}
			}
			else if (endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_INT) {
				if (endpoint.getMaxPacketSize() > 8) {
					// Low speed devices can't use interrupt transfer sizes larger than 8 bytes
					possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_LOW;
				}
				if (endpoint.getMaxPacketSize() > 64) {
					// Full speed devices can't use interrupt transfer sizes larger than 64 bytes
					possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_FULL;
				}
			}
			else if (endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
				// A bulk endpoint alone can accurately distiniguish between
				// full and high speed devices
				if (endpoint.getMaxPacketSize() == 512) {
					// High speed devices can only use 512 byte bulk transfers
					possibleSpeeds = FLAG_POSSIBLE_SPEED_HIGH;
				}
				else {
					// Otherwise it must be full speed
					possibleSpeeds = FLAG_POSSIBLE_SPEED_FULL;
				}
			}
			else if (endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_ISOC) {
				// If the transfer size is 1024, it must be high speed
				if (endpoint.getMaxPacketSize() == 1024) {
					possibleSpeeds = FLAG_POSSIBLE_SPEED_HIGH;
				}
			}
		}
	}
	
	if (devDesc != null) {
		if (devDesc.bcdUSB < 0x200) {
			// High speed only supported on USB 2.0 or higher
			possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_HIGH;
		}
	}
	
	// Return the lowest speed that we're compatible with
	System.out.printf("Speed heuristics for device %d left us with 0x%x\n",
			dev.getDeviceId(), possibleSpeeds);

	if ((possibleSpeeds & FLAG_POSSIBLE_SPEED_LOW) != 0) {
		return UsbIpDevice.USB_SPEED_LOW;
	}
	else if ((possibleSpeeds & FLAG_POSSIBLE_SPEED_FULL) != 0) {
		return UsbIpDevice.USB_SPEED_FULL;
	}
	else if ((possibleSpeeds & FLAG_POSSIBLE_SPEED_HIGH) != 0) {
		return UsbIpDevice.USB_SPEED_HIGH;
	}
	else {
		// Something went very wrong in speed detection
		return UsbIpDevice.USB_SPEED_UNKNOWN;
	}
}
 
开发者ID:cgutman,项目名称:USBIPServerForAndroid,代码行数:81,代码来源:UsbIpService.java


注:本文中的android.hardware.usb.UsbConstants.USB_ENDPOINT_XFER_CONTROL属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。