Android UsbInterface - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android UsbInterface class.

This code example shows how to use the following methods:getEndpoint, getEndpointCount
            Log.e(TAG, "could not find interface");
            return; 
        } 
        UsbInterface intf = device.getInterface(0);
        // device should have one endpoint 
        if (intf.getEndpointCount() != 1) {
            Log.e(TAG, "could not find endpoint");
            return; 
        } 
        // endpoint should be of type interrupt 
        UsbEndpoint ep = intf.getEndpoint(0);
        if (ep.getType() != UsbConstants.USB_ENDPOINT_XFER_INT) {
            Log.e(TAG, "endpoint is not interrupt type");
            return; 
        } 
        mDevice = device;
        mEndpointIntr = ep;
        if (device != null) {
            UsbDeviceConnection connection = mUsbManager.openDevice(device);
            if (connection != null && connection.claimInterface(intf, true)) {
7
CodeRank
This code example shows how to use the following methods:getEndpoint, getEndpointCount
			toast.show();
			return; 
		} 
		UsbInterface intf = device.getInterface(0);
		// device should have two endpoints 
		if (intf.getEndpointCount() != 2) {
			Toast toast = Toast.makeText(context, "could not find endpoint", duration);
			toast.show();
			return; 
		} 
 
		// endpoint should be of type bulk 
		UsbEndpoint ep = intf.getEndpoint(0);
		UsbEndpoint epOut = null;
		UsbEndpoint epIn = null;
		if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
			if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
				epOut = ep;
				//Toast toast = Toast.makeText(context, "endpoint 0 is out", duration); 
				//toast.show(); 

5
CodeRank
This code example shows how to use the following methods:getInterfaceClass
        final int id = iface.getId();
        return "" + id;
    } 
 
    public static String getClassString(UsbInterface iface) {
        final int clazz = iface.getInterfaceClass();
        return "" + clazz;
    } 
 
    public static String getSubclassString(UsbInterface iface) {
        final int subclass = iface.getInterfaceSubclass();
        return "" + subclass;
    } 
 
    public static String getProtocolString(UsbInterface iface) {
        final int protocol = iface.getInterfaceProtocol();
        return "" + protocol;
    } 
 
    public static String getAddressString(UsbEndpoint ep) {
4
CodeRank
This code example shows how to use the following methods:getEndpoint
        // class should be USB_CLASS_CDC_DATA 
 
        if (!mConnection.claimInterface(mDataInterface, true)) {
            throw new IOException("Could not claim data interface.");
        } 
        mReadEndpoint = mDataInterface.getEndpoint(1);
        Log.d(TAG, "Read endpoint direction: " + mReadEndpoint.getDirection());
        mWriteEndpoint = mDataInterface.getEndpoint(0);
        Log.d(TAG, "Write endpoint direction: " + mWriteEndpoint.getDirection());
 
        Log.d(TAG, "Setting line coding");
        setBaudRate(115200); 
 
    } 
 
    private static final int USB_RECIP_INTERFACE = 0x01;
    private static final int USB_RT_ACM = UsbConstants.USB_TYPE_CLASS | USB_RECIP_INTERFACE;
 
    private static final int SET_LINE_CODING = 0x20;  // USB CDC 1.1 section 6.2
 
4
CodeRank
This code example shows how to use the following methods:getEndpoint, getEndpointCount
			appendLogText("could not find interface"); 
			return; 
		} 
		UsbInterface intf = device.getInterface(0);
		// device should have one endpoint 
		if (intf.getEndpointCount() != 1) {
			appendLogText("could not find endpoint"); 
			return; 
		} 
		// endpoint should be of type interrupt 
		UsbEndpoint ep = intf.getEndpoint(0);
		if (ep.getType() != UsbConstants.USB_ENDPOINT_XFER_INT) {
 
			appendLogText("endpoint is not interrupt type"); 
			return; 
		} 
 
		mDevice = device;
		mEndpointIntr = ep;
		if (device != null) {
4
CodeRank
This code example shows how to use the following methods:getId
    private static final Comparator<Map<String, ?>> INTERFACE_COMPARATOR = new Comparator<Map<String, ?>>() {
        @Override 
        public int compare(Map<String, ?> object1, Map<String, ?> object2) { 
            final UsbInterface iface1 = (UsbInterface) object1.get(InterfaceMapKeys.INTERFACE); 
            final UsbInterface iface2 = (UsbInterface) object2.get(InterfaceMapKeys.INTERFACE); 
            return Integer.valueOf(iface1.getId()).compareTo(Integer.valueOf(iface2.getId())); 
        } 
    }; 
 
    private SimpleExpandableListAdapter createAdapter(final Map<String, UsbDevice> devices) {
        final List<Map<String, ?>> deviceEntries = Lists.newArrayList();
        final List<List<Map<String, ?>>> ifaceEntriesList = Lists.newArrayList();
 
        for (Entry<String, UsbDevice> entry : devices.entrySet()) {
            final UsbDevice dev = entry.getValue();
 
            final Map<String, String> deviceEntry = Maps.newHashMap();
            deviceEntries.add(deviceEntry);
            deviceEntry.put(DeviceMapKeys.NAME, dev.getDeviceName());
            deviceEntry.put(DeviceMapKeys.ID, "Id: " + getIdString(dev));
4
CodeRank
This code example shows how to use the following methods:getEndpoint

Related Android UsbInterface Questions & Answers:

See Code Examples for Android UsbInterface Methods: