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


Java UsbInterface.getEndpoint方法代码示例

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


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

示例1: AdbDevice

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
public AdbDevice(AdbTestActivity activity, UsbDeviceConnection connection,
        UsbInterface intf) {
    mActivity = activity;
    mDeviceConnection = connection;
    mSerial = connection.getSerial();

    UsbEndpoint epOut = null;
    UsbEndpoint epIn = null;
    // look for our bulk endpoints
    for (int i = 0; i < intf.getEndpointCount(); i++) {
        UsbEndpoint ep = intf.getEndpoint(i);
        if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
            if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
                epOut = ep;
            } else {
                epIn = ep;
            }
        }
    }
    if (epOut == null || epIn == null) {
        throw new IllegalArgumentException("not all endpoints found");
    }
    mEndpointOut = epOut;
    mEndpointIn = epIn;
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:26,代码来源:AdbDevice.java

示例2: onConnect

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
@Override
public void onConnect() {
    // Serial mode only
    // TODO: find the interface and endpoint indexes no matter what mode it is
    int ifIdx = 1;
    int epInIdx = 1;
    int epOutIdx = 0;

    UsbInterface iface = usbDevice.getInterface(ifIdx);

    if (usbConnection.claimInterface(iface, true)) {
        logger.log("Interface claimed successfully\n");
    } else {
        logger.log("ERROR - can't claim interface\n");
        return;
    }

    endpointIn = iface.getEndpoint(epInIdx);
    endpointOut = iface.getEndpoint(epOutIdx);

    super.onConnect();
}
 
开发者ID:google,项目名称:walt,代码行数:23,代码来源:WaltUsbConnection.java

示例3: ConnectedUsbDevice

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
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,代码行数:19,代码来源:ConnectedUsbDevice.java

示例4: UsbMidiDeviceAndroid

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
/**
 * Constructs a UsbMidiDeviceAndroid.
 * @param manager
 * @param device The USB device which this object is assocated with.
 */
UsbMidiDeviceAndroid(UsbManager manager, UsbDevice device) {
    mConnection = manager.openDevice(device);
    mEndpointMap = new HashMap<Integer, UsbEndpoint>();
    mRequestMap = new HashMap<UsbEndpoint, UsbRequest>();

    for (int i = 0; i < device.getInterfaceCount(); ++i) {
        UsbInterface iface = device.getInterface(i);
        if (iface.getInterfaceClass() != UsbConstants.USB_CLASS_AUDIO ||
            iface.getInterfaceSubclass() != MIDI_SUBCLASS) {
            continue;
        }
        mConnection.claimInterface(iface, true);
        for (int j = 0; j < iface.getEndpointCount(); ++j) {
            UsbEndpoint endpoint = iface.getEndpoint(j);
            if (endpoint.getDirection() == UsbConstants.USB_DIR_OUT) {
                mEndpointMap.put(endpoint.getEndpointNumber(), endpoint);
            }
        }
    }
}
 
开发者ID:mogoweb,项目名称:chromium_webview,代码行数:26,代码来源:UsbMidiDeviceAndroid.java

示例5: SmartCardChannel

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
/** Constructor. Inicia los EndPoints del Interfaz del dispositivo
 * @param usbDevCon
 * @param usbInterface */
protected SmartCardChannel(final UsbDeviceConnection usbDevCon, final UsbInterface usbInterface) {
	this.usbDeviceConnection = usbDevCon;
	for (int i = 0; i < usbInterface.getEndpointCount(); i++) {
		final UsbEndpoint usbEndPoint = usbInterface.getEndpoint(i);
		if (usbEndPoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
			if (usbEndPoint.getDirection() == UsbConstants.USB_DIR_IN) {
				this.endPointIn = usbEndPoint;
			}
			else if (usbEndPoint.getDirection() == UsbConstants.USB_DIR_OUT) {
				this.endPointOut = usbEndPoint;
			}
		}
	}
}
 
开发者ID:MiFirma,项目名称:mi-firma-android,代码行数:18,代码来源:SmartCardChannel.java

示例6: FcUsbDevice

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
public FcUsbDevice(MainActivity activity, UsbDeviceConnection connection,
                   UsbInterface intf, Map<String, UAVTalkXMLObject> xmlObjects) {
    super(activity);

    //mActivity = activity;
    mDeviceConnection = connection;
    mObjectTree = new UAVTalkObjectTree();
    mObjectTree.setXmlObjects(xmlObjects);
    mActivity.setPollThreadObjectTree(mObjectTree);

    UsbEndpoint epOut = null;
    UsbEndpoint epIn = null;
    // look for our bulk endpoints
    for (int i = 0; i < intf.getEndpointCount(); i++) {
        UsbEndpoint ep = intf.getEndpoint(i);
        if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT) {
            if (ep.getDirection() == UsbConstants.USB_DIR_OUT) {
                epOut = ep;
            } else {
                epIn = ep;
            }
        }
    }
    if (epOut == null || epIn == null) {
        throw new IllegalArgumentException("not all endpoints found");
    }
    mEndpointOut = epOut;
    mEndpointIn = epIn;

    mWaiterThread = new FcUsbWaiterThread(this, mDeviceConnection, mEndpointIn);
}
 
开发者ID:MarcProe,项目名称:lp2go,代码行数:32,代码来源:FcUsbDevice.java

示例7: open

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
@Override
    public void open() throws IOException {        
        boolean opened = false;
        try {
            for (int i = 0; i < mDevice.getInterfaceCount(); i++) {                
                UsbInterface usbIface = mDevice.getInterface(i);
                if (mConnection.claimInterface(usbIface, true)) {
                    Log.d(TAG, "claimInterface " + i + " SUCCESS");                    
                } else {
                    Log.d(TAG, "claimInterface " + i + " FAIL");
                }
            }                       
            
            UsbInterface dataIface = mDevice.getInterface(mDevice.getInterfaceCount() - 1);
            for (int i = 0; i < dataIface.getEndpointCount(); i++) {
                UsbEndpoint ep = dataIface.getEndpoint(i);
                if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
                    if (ep.getDirection() == UsbConstants.USB_DIR_IN) {
                        mReadEndpoint = ep;
                    } else {
                        mWriteEndpoint = ep;
                    }
                }
            }
            
            setConfigSingle(SILABSER_IFC_ENABLE_REQUEST_CODE, UART_ENABLE);
            setConfigSingle(SILABSER_SET_MHS_REQUEST_CODE, MCR_ALL | CONTROL_WRITE_DTR | CONTROL_WRITE_RTS);
            setConfigSingle(SILABSER_SET_BAUDDIV_REQUEST_CODE, BAUD_RATE_GEN_FREQ / DEFAULT_BAUD_RATE);            
//            setParameters(DEFAULT_BAUD_RATE, DEFAULT_DATA_BITS, DEFAULT_STOP_BITS, DEFAULT_PARITY);
            opened = true;
        } finally {
            if (!opened) {
                close();
            }
        }        
    }
 
开发者ID:jiaminghan,项目名称:droidplanner-master,代码行数:37,代码来源:Cp2102SerialDriver.java

示例8: initEnpoints

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
private void initEnpoints(UsbInterface usbInterface) {
    usbInterface.getInterfaceSubclass();
    UsbEndpoint endpoint = usbInterface.getEndpoint(0);
    UsbEndpoint endpoint2 = usbInterface.getEndpoint(1);
    if (endpoint.getDirection() == UsbConstants.USB_DIR_IN) {
        UsbEndpoint usbEndpoint = endpoint2;
        endpoint2 = endpoint;
        endpoint = usbEndpoint;
    }
    inputEndpoint = endpoint2;
    outputEndpoint = endpoint;
}
 
开发者ID:rostskadat,项目名称:OTGDiskBackup,代码行数:13,代码来源:OtgDeviceFacade.java

示例9: setupDevice

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
private UsbDeviceConnection setupDevice(UsbManager manager,
        UsbDevice device) throws UsbDeviceException {
    if(device.getInterfaceCount() != 1) {
        throw new UsbDeviceException("USB device didn't have an " +
                "interface for us to open");
    }
    UsbInterface iface = null;
    for(int i = 0; i < device.getInterfaceCount(); i++) {
        iface = device.getInterface(i);
        if(iface.getEndpointCount() == ENDPOINT_COUNT) {
            break;
        }
    }

    if(iface == null) {
        Log.w(TAG, "Unable to find a USB device interface with the " +
                "expected number of endpoints (" + ENDPOINT_COUNT + ")");
        return null;
    }

    for(int i = 0; i < iface.getEndpointCount(); i++) {
        UsbEndpoint endpoint = iface.getEndpoint(i);
        if(endpoint.getType() ==
                UsbConstants.USB_ENDPOINT_XFER_BULK) {
            if(endpoint.getDirection() == UsbConstants.USB_DIR_IN) {
                Log.d(TAG, "Found IN endpoint " + endpoint);
                mInEndpoint = endpoint;
            } else {
                Log.d(TAG, "Found OUT endpoint " + endpoint);
                mOutEndpoint = endpoint;
            }
        }

        if(mInEndpoint != null && mOutEndpoint != null) {
            break;
        }
    }
    return openInterface(manager, device, iface);
}
 
开发者ID:bibhrajit,项目名称:openxc-androidStudio,代码行数:40,代码来源:UsbVehicleInterface.java

示例10: connectUSB

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
public void connectUSB(UsbManager mgr, UsbDevice device) {
    UsbInterface device_interface = device.getInterface(0);
    _connection = mgr.openDevice(device);

    if (_connection != null) {
        _connection.claimInterface(device_interface, true);
        _endpoint_in = device_interface.getEndpoint(1);
        _endpoint_out = device_interface.getEndpoint(2);
        _max_packet_size = _endpoint_in.getMaxPacketSize();
        _packet_buffer = ByteBuffer.allocate(_max_packet_size);
        _packet_buffer.order(ByteOrder.LITTLE_ENDIAN);
        _result_buffer = ByteBuffer.allocate(4096);
    }
}
 
开发者ID:GeoSpark,项目名称:scoperoid,代码行数:15,代码来源:Scope.java

示例11: UsbMidiDeviceAndroid

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
/**
 * Constructs a UsbMidiDeviceAndroid.
 * @param manager
 * @param device The USB device which this object is assocated with.
 */
UsbMidiDeviceAndroid(UsbManager manager, UsbDevice device) {
    mConnection = manager.openDevice(device);
    mEndpointMap = new SparseArray<UsbEndpoint>();
    mRequestMap = new HashMap<UsbEndpoint, UsbRequest>();
    mHandler = new Handler();
    mUsbDevice = device;
    mIsClosed = false;
    mHasInputThread = false;
    mNativePointer = 0;

    for (int i = 0; i < device.getInterfaceCount(); ++i) {
        UsbInterface iface = device.getInterface(i);
        if (iface.getInterfaceClass() != UsbConstants.USB_CLASS_AUDIO
                || iface.getInterfaceSubclass() != MIDI_SUBCLASS) {
            continue;
        }
        mConnection.claimInterface(iface, true);
        for (int j = 0; j < iface.getEndpointCount(); ++j) {
            UsbEndpoint endpoint = iface.getEndpoint(j);
            if (endpoint.getDirection() == UsbConstants.USB_DIR_OUT) {
                mEndpointMap.put(endpoint.getEndpointNumber(), endpoint);
            }
        }
    }
    // Start listening for input endpoints.
    // This function will create and run a thread if there is USB-MIDI endpoints in the
    // device. Note that because UsbMidiDevice is shared among all tabs and the thread
    // will be terminated when the device is disconnected, at most one thread can be created
    // for each connected USB-MIDI device.
    startListen(device);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:37,代码来源:UsbMidiDeviceAndroid.java

示例12: getDeviceInfo

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
public String getDeviceInfo(UsbDevice device) {
    if (device == null)
        return "No device found.";

    StringBuilder sb = new StringBuilder();
    sb.append("Model: " + device.getDeviceName() + "\n");
    sb.append("ID: " + device.getDeviceId() + " (0x" + Integer.toHexString(device.getDeviceId()) + ")" + "\n");
    sb.append("Class: " + device.getDeviceClass() + "\n");
    sb.append("Subclass: " + device.getDeviceSubclass() + "\n");
    sb.append("Protocol: " + device.getDeviceProtocol() + "\n");
    sb.append("Vendor ID " + device.getVendorId() + " (0x" + Integer.toHexString(device.getVendorId()) + ")" + "\n");
    sb.append("Product ID: " + device.getProductId() + " (0x" + Integer.toHexString(device.getProductId()) + ")" + "\n");
    sb.append("Device Ver: 0x" + Integer.toHexString(mDeviceVersion) + "\n");
    sb.append("Interface count: " + device.getInterfaceCount() + "\n");

    for (int i = 0; i < device.getInterfaceCount(); i++) {

        UsbInterface usbInterface = device.getInterface(i);

        sb.append("Interface: " + usbInterface.toString() + "\n");
        sb.append("Endpoint Count: " + usbInterface.getEndpointCount() + "\n");

        for (int j = 0; j < usbInterface.getEndpointCount(); j++) {

            UsbEndpoint ep = usbInterface.getEndpoint(j);

            sb.append("Endpoint: " + ep.toString() + "\n");
        }
    }

    return sb.toString();
}
 
开发者ID:UmbrelaSmart,项目名称:android-stm32-dfu-programmer,代码行数:33,代码来源:Usb.java

示例13: open

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
public static BTChipTransport open(UsbManager manager, UsbDevice device) {
	// Must only be called once permission is granted (see http://developer.android.com/reference/android/hardware/usb/UsbManager.html)
	// Important if enumerating, rather than being awaken by the intent notification
	UsbInterface dongleInterface = device.getInterface(0);
       UsbEndpoint in = null;
       UsbEndpoint out = null;
       boolean ledger; 
       for (int i=0; i<dongleInterface.getEndpointCount(); i++) {
           UsbEndpoint tmpEndpoint = dongleInterface.getEndpoint(i);
           if (tmpEndpoint.getDirection() == UsbConstants.USB_DIR_IN) {
               in = tmpEndpoint;
           }
           else {
               out = tmpEndpoint;
           }
       }
       UsbDeviceConnection connection = manager.openDevice(device);
       connection.claimInterface(dongleInterface, true);
       ledger = ((device.getProductId() == PID_HID_LEDGER) || (device.getProductId() == PID_HID_LEDGER_PROTON)
	|| (device.getProductId() == PID_NANOS) || (device.getProductId() == PID_BLUE));
       if (device.getProductId() == PID_WINUSB) {
       	return new BTChipTransportAndroidWinUSB(connection, dongleInterface, in, out, TIMEOUT);
       }
       else {
       	return new BTChipTransportAndroidHID(connection, dongleInterface, in, out, TIMEOUT, ledger);
       }
}
 
开发者ID:greenaddress,项目名称:WalletCordova,代码行数:28,代码来源:BTChipTransportAndroid.java

示例14: open

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
@Override
    public void open() throws IOException {
        boolean opened = false;
        try {
            for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
                UsbInterface usbIface = mDevice.getInterface(i);
                if (mConnection.claimInterface(usbIface, true)) {
                    Log.d(TAG, "claimInterface " + i + " SUCCESS");
                } else {
                    Log.d(TAG, "claimInterface " + i + " FAIL");
                }
            }

            UsbInterface dataIface = mDevice.getInterface(mDevice.getInterfaceCount() - 1);
            for (int i = 0; i < dataIface.getEndpointCount(); i++) {
                UsbEndpoint ep = dataIface.getEndpoint(i);
                if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
                    if (ep.getDirection() == UsbConstants.USB_DIR_IN) {
                        mReadEndpoint = ep;
                    } else {
                        mWriteEndpoint = ep;
                    }
                }
            }

            setConfigSingle(SILABSER_IFC_ENABLE_REQUEST_CODE, UART_ENABLE);
            setConfigSingle(SILABSER_SET_MHS_REQUEST_CODE, MCR_ALL | CONTROL_WRITE_DTR | CONTROL_WRITE_RTS);
            setConfigSingle(SILABSER_SET_BAUDDIV_REQUEST_CODE, BAUD_RATE_GEN_FREQ / DEFAULT_BAUD_RATE);
//            setParameters(DEFAULT_BAUD_RATE, DEFAULT_DATA_BITS, DEFAULT_STOP_BITS, DEFAULT_PARITY);
            opened = true;
        } finally {
            if (!opened) {
                close();
            }
        }
    }
 
开发者ID:brentn,项目名称:StenoIME,代码行数:37,代码来源:Cp2102SerialDriver.java

示例15: getUsbDevice

import android.hardware.usb.UsbInterface; //导入方法依赖的package包/类
public void getUsbDevice() {
	
	//Log.d("findingDevices", " - wubbahed");
	HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
	Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
	while (deviceIterator.hasNext()) {

			mDevice = deviceIterator.next();
			// your code
			
			Log.d("deviceName", mDevice.getDeviceName() + " - wubbahed");
			Log.d("deviceId", mDevice.getDeviceId() + " - wubbahed");
			Log.d("deviceInterfaceCount", mDevice.getInterfaceCount()
					+ " - wubbahed");
			Log.d("deviceClass", mDevice.getDeviceClass() + " - wubbahed");
			Log
					.d("deviceProductId", mDevice.getProductId()
							+ " - wubbahed");
			Log.d("deviceVendorId", mDevice.getVendorId() + " - wubbahed");

			UsbInterface iFace = mDevice.getInterface(0);
			Log.d("interfaceToString", iFace.toString() + " - wubbahed");

			int endpointCount = iFace.getEndpointCount();
			for (int i = 0; i < endpointCount; i++) {
				mEndpoint = iFace.getEndpoint(i);
				Log.d("endpoint", mEndpoint.toString() + " - wubbahed");
				Log.d("endpointDirection", mEndpoint.getDirection()
						+ " - wubbahed");
				Log.d("endpointType", mEndpoint.getType() + " - wubbahed");
			}

			mConnection = mUsbManager.openDevice(mDevice);
			mConnection.claimInterface(iFace, true);			

	}       

}
 
开发者ID:wubbahed,项目名称:carv-hackmeat,代码行数:39,代码来源:MainActivity.java


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