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


Java UsbEndpoint.getDirection方法代码示例

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


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

示例1: UsbHidDevice

import android.hardware.usb.UsbEndpoint; //导入方法依赖的package包/类
private UsbHidDevice(UsbDevice usbDevice, UsbInterface usbInterface, UsbManager usbManager) {
    mUsbDevice = usbDevice;
    mUsbInterface = usbInterface;
    mUsbManager= usbManager;

    for (int i = 0; i < mUsbInterface.getEndpointCount(); i++) {
        UsbEndpoint endpoint = mUsbInterface.getEndpoint(i);
        int dir = endpoint.getDirection();
        int type = endpoint.getType();
        if (mInUsbEndpoint == null && dir == UsbConstants.USB_DIR_IN && type == UsbConstants.USB_ENDPOINT_XFER_INT) {
            mInUsbEndpoint = endpoint;
        }
        if (mOutUsbEndpoint == null && dir == UsbConstants.USB_DIR_OUT && type == UsbConstants.USB_ENDPOINT_XFER_INT) {
            mOutUsbEndpoint = endpoint;
        }
    }
}
 
开发者ID:benlypan,项目名称:UsbHid,代码行数:18,代码来源:UsbHidDevice.java

示例2: open

import android.hardware.usb.UsbEndpoint; //导入方法依赖的package包/类
@Override
public boolean open() {
    iface = device.getInterface(0);
    Log.d(TAG, "Endpoint Count: " + iface.getEndpointCount());
    UsbEndpoint ep0 = iface.getEndpoint(0);
    UsbEndpoint ep1 = iface.getEndpoint(1);

    if (ep0.getDirection() == UsbConstants.USB_DIR_IN) {
        in = ep0;
        out = ep1;
    } else {
        in = ep1;
        out = ep0;
    }

    con = manager.openDevice(device);

    return con != null;
}
 
开发者ID:uvwxy,项目名称:android-ambit,代码行数:20,代码来源:AndroidAmbitDevice.java

示例3: ConnectedUsbDevice

import android.hardware.usb.UsbEndpoint; //导入方法依赖的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: getCdcEndpoint

import android.hardware.usb.UsbEndpoint; //导入方法依赖的package包/类
private boolean getCdcEndpoint() {
    UsbEndpoint ep;

    if (mInterface[0] == null) {
        return false;
    }
    for (int i = 0; i < 2; ++i) {
        ep = mInterface[0].getEndpoint(i);
        if (ep.getDirection() == UsbConstants.USB_DIR_IN) {
            mFTDIEndpointIN[0] = ep;
        } else {
            mFTDIEndpointOUT[0] = ep;
        }
    }
    if (mFTDIEndpointIN == null || mFTDIEndpointOUT == null) {
        return false;
    }
    return true;

}
 
开发者ID:r00li,项目名称:RHome,代码行数:21,代码来源:FTDriver.java

示例5: UsbMidiDeviceAndroid

import android.hardware.usb.UsbEndpoint; //导入方法依赖的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

示例6: SmartCardChannel

import android.hardware.usb.UsbEndpoint; //导入方法依赖的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

示例7: SonyInitiator

import android.hardware.usb.UsbEndpoint; //导入方法依赖的package包/类
/**
 * Constructs a class driver object, if the device supports
 * operations according to Annex D of the PTP specification.
 *
 * @param dev        the first PTP interface will be used
 * @param connection
 * @throws IllegalArgumentException if the device has no
 *                                  Digital Still Imaging Class or PTP interfaces
 */
public SonyInitiator(UsbDevice dev, UsbDeviceConnection connection) throws PTPException {

    super();

    this.mConnection = connection;
    if (dev == null) {
        throw new PTPException ("dev = null");//IllegalArgumentException();
    }
    session = new Session();
    this.device = dev;
    intf = findUsbInterface (dev);

    if (intf == null) {
        //if (usbInterface == null) {
        throw new PTPException("No PTP interfaces associated to the device");
    }

    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 (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT){
            epEv = ep;
        }
    }
    endpointSanityCheck();
    inMaxPS = epOut.getMaxPacketSize();
    intrMaxPS = epIn.getMaxPacketSize();

    // clear epOut any previous state
    reset();
}
 
开发者ID:iyundong,项目名称:InstantUpload,代码行数:47,代码来源:SonyInitiator.java

示例8: openCH34X

import android.hardware.usb.UsbEndpoint; //导入方法依赖的package包/类
private boolean openCH34X()
{
    if(connection.claimInterface(mInterface, true))
    {
        Log.i(CLASS_ID, "Interface succesfully claimed");
    }else
    {
        Log.i(CLASS_ID, "Interface could not be claimed");
        return false;
    }

    // Assign endpoints
    int numberEndpoints = mInterface.getEndpointCount();
    for(int i=0;i<=numberEndpoints-1;i++)
    {
        UsbEndpoint endpoint = mInterface.getEndpoint(i);
        if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
                && endpoint.getDirection() == UsbConstants.USB_DIR_IN)
        {
            inEndpoint = endpoint;
        }else if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
                && endpoint.getDirection() == UsbConstants.USB_DIR_OUT)
        {
            outEndpoint = endpoint;
        }
    }

    return init() == 0;
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:30,代码来源:CH34xSerialDevice.java

示例9: openCDC

import android.hardware.usb.UsbEndpoint; //导入方法依赖的package包/类
private boolean openCDC()
{
    if(connection.claimInterface(mInterface, true))
    {
        Log.i(CLASS_ID, "Interface succesfully claimed");
    }else
    {
        Log.i(CLASS_ID, "Interface could not be claimed");
        return false;
    }

    // Assign endpoints
    int numberEndpoints = mInterface.getEndpointCount();
    for(int i=0;i<=numberEndpoints-1;i++)
    {
        UsbEndpoint endpoint = mInterface.getEndpoint(i);
        if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
                && endpoint.getDirection() == UsbConstants.USB_DIR_IN)
        {
            inEndpoint = endpoint;
        }else if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
                && endpoint.getDirection() == UsbConstants.USB_DIR_OUT)
        {
            outEndpoint = endpoint;
        }
    }

    if(outEndpoint == null || inEndpoint == null)
    {
        Log.i(CLASS_ID, "Interface does not have an IN or OUT interface");
        return false;
    }

    // Default Setup
    setControlCommand(CDC_SET_LINE_CODING, 0, getInitialLineCoding());
    setControlCommand(CDC_SET_CONTROL_LINE_STATE, CDC_CONTROL_LINE_ON, null);

    return true;
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:40,代码来源:CDCSerialDevice.java

示例10: openCP2102

import android.hardware.usb.UsbEndpoint; //导入方法依赖的package包/类
private boolean openCP2102()
{
    if(connection.claimInterface(mInterface, true))
    {
        Log.i(CLASS_ID, "Interface succesfully claimed");
    }else
    {
        Log.i(CLASS_ID, "Interface could not be claimed");
        return false;
    }

    // Assign endpoints
    int numberEndpoints = mInterface.getEndpointCount();
    for(int i=0;i<=numberEndpoints-1;i++)
    {
        UsbEndpoint endpoint = mInterface.getEndpoint(i);
        if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
                && endpoint.getDirection() == UsbConstants.USB_DIR_IN)
        {
            inEndpoint = endpoint;
        }else
        {
            outEndpoint = endpoint;
        }
    }


    // Default Setup
    if(setControlCommand(CP210x_IFC_ENABLE, CP210x_UART_ENABLE, null) < 0)
        return false;
    setBaudRate(DEFAULT_BAUDRATE);
    if(setControlCommand(CP210x_SET_LINE_CTL, CP210x_LINE_CTL_DEFAULT,null) < 0)
        return false;
    setFlowControl(UsbSerialInterface.FLOW_CONTROL_OFF);
    if(setControlCommand(CP210x_SET_MHS, CP210x_MHS_DEFAULT, null) < 0)
        return false;

    return true;
}
 
开发者ID:GIGATeam,项目名称:UsbExtension,代码行数:40,代码来源:CP2102SerialDevice.java

示例11: open

import android.hardware.usb.UsbEndpoint; //导入方法依赖的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

示例12: openCDC

import android.hardware.usb.UsbEndpoint; //导入方法依赖的package包/类
private boolean openCDC()
{
    if(connection.claimInterface(mInterface, true))
    {
        Log.i(CLASS_ID, "Interface succesfully claimed");
    }else
    {
        Log.i(CLASS_ID, "Interface could not be claimed");
        return false;
    }

    // Assign endpoints
    int numberEndpoints = mInterface.getEndpointCount();
    for(int i=0;i<=numberEndpoints-1;i++)
    {
        UsbEndpoint endpoint = mInterface.getEndpoint(i);
        if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
                && endpoint.getDirection() == UsbConstants.USB_DIR_IN)
        {
            inEndpoint = endpoint;
        }else if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
                && endpoint.getDirection() == UsbConstants.USB_DIR_OUT)
        {
            outEndpoint = endpoint;
        }
    }

    if(outEndpoint == null || inEndpoint == null)
    {
        Log.i(CLASS_ID, "Interface does not have an IN or OUT interface");
        return false;
    }

    // Default Setup
    setControlCommand(CDC_SET_LINE_CODING, 0, CDC_DEFAULT_LINE_CODING);
    setControlCommand(CDC_SET_CONTROL_LINE_STATE, CDC_CONTROL_LINE_ON, null);

    return true;
}
 
开发者ID:simondlevy,项目名称:Hackflight,代码行数:40,代码来源:CDCSerialDevice.java

示例13: FcUsbDevice

import android.hardware.usb.UsbEndpoint; //导入方法依赖的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

示例14: openCP2130

import android.hardware.usb.UsbEndpoint; //导入方法依赖的package包/类
private boolean openCP2130()
{
    if(connection.claimInterface(mInterface, true))
    {
        Log.i(CLASS_ID, "Interface succesfully claimed");
    }else
    {
        Log.i(CLASS_ID, "Interface could not be claimed");
        return false;
    }

    // Assign endpoints
    int numberEndpoints = mInterface.getEndpointCount();
    for(int i=0;i<=numberEndpoints-1;i++)
    {
        UsbEndpoint endpoint = mInterface.getEndpoint(i);
        if(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
                && endpoint.getDirection() == UsbConstants.USB_DIR_IN)
        {
            inEndpoint = endpoint;
        }else
        {
            outEndpoint = endpoint;
        }
    }

    return true;
}
 
开发者ID:simondlevy,项目名称:Hackflight,代码行数:29,代码来源:CP2130SpiDevice.java

示例15: getEndpoint

import android.hardware.usb.UsbEndpoint; //导入方法依赖的package包/类
private UsbEndpoint getEndpoint(int devNum, int intfNum, int usbDir) {
    UsbInterface intf = mUsbAccess.intface(devNum, intfNum);
    if (intf == null) {
        return null;
    }

    for (int i = 0; i < intf.getEndpointCount(); i++) {
        UsbEndpoint ep = mUsbAccess.endpoint(devNum, intfNum, i);
        if (ep == null) return null;
        if (ep.getDirection() == usbDir) {
            return ep;
        }
    }
    return null;
}
 
开发者ID:cattaka,项目名称:PhysicaloidVc,代码行数:16,代码来源:UsbCdcConnection.java


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