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


Java UsbEndpoint类代码示例

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


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

示例1: AdbDevice

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

示例3: MidiInputDevice

import android.hardware.usb.UsbEndpoint; //导入依赖的package包/类
/**
 * constructor
 *
 * @param usbDevice
 * @param usbDeviceConnection
 * @param usbInterface
 * @param midiEventListener
 * @throws IllegalArgumentException endpoint not found.
 */
public MidiInputDevice(UsbDevice usbDevice, UsbDeviceConnection usbDeviceConnection, UsbInterface usbInterface, UsbEndpoint usbEndpoint, OnMidiInputEventListener midiEventListener) throws IllegalArgumentException {
    //this.usbDevice = usbDevice;
    this.usbDeviceConnection = usbDeviceConnection;
    this.usbInterface = usbInterface;

    this.midiEventListener = midiEventListener;

    waiterThread = new WaiterThread();

    inputEndpoint = usbEndpoint;


    usbDeviceConnection.claimInterface(usbInterface, true);
    waiterThread.setPriority(8);
    waiterThread.setName("MidiInputDevice[" + usbDevice.getDeviceName() + "].WaiterThread");
    waiterThread.start();
    FragMentManager.getInstance().updateUSBConnection(true);
}
 
开发者ID:Ag47,项目名称:TrueTone,代码行数:28,代码来源:MidiInputDevice.java

示例4: startConnecting

import android.hardware.usb.UsbEndpoint; //导入依赖的package包/类
private void startConnecting() {
	handleConnecting();
	try {
		UsbManager usbManager = (UsbManager) context.getSystemService(Context.USB_SERVICE);
		deviceConnection = usbManager.openDevice(device);

		driver = UsbSerialDriverFactory.createDriver(device, deviceConnection);
		UsbEndpoint[] endpoints = driver.open();
		readEndpoint = endpoints[0];
		writeEndpoint = endpoints[1];

		driver.setParameters(115200, 8, UsbSerialDriver.STOPBITS_1, UsbSerialDriver.PARITY_NONE);
	} catch (Exception e) {
		Log.e(LOG_TAG, "Failed to connect to USB device(" + device.getDeviceName() + "). cause=" + e.getMessage());
		cleanUp();
		handleFailedToConnect(e);
		return;
	}

	// Start a thread for reading
	readThread = new UsbReadThread();
	readThread.start();

	Log.i(LOG_TAG, "USB device is connected! connection=" + getDescription());
	handleConnected();
}
 
开发者ID:Neofect,项目名称:Communicator,代码行数:27,代码来源:UsbConnection.java

示例5: 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

示例6: testStartReadThread

import android.hardware.usb.UsbEndpoint; //导入依赖的package包/类
/**
 * Test method for {@link com.digi.xbee.api.connection.android.AndroidUSBInputStream#startReadThread()}
 */
@Test
public void testStartReadThread() throws Exception {
	// Prepare the resources for the test.
	Whitebox.setInternalState(is, VARIABLE_READ_BUFFER, circularBuffer);

	// Call the method under test.
	is.startReadThread();

	Thread.sleep(10);

	boolean working = (Boolean) Whitebox.getInternalState(is, VARIABLE_WORKING);

	// Perform the verifications.
	assertThat(working, is(equalTo(true)));
	Mockito.verify(usbConnection, Mockito.atLeast(1)).bulkTransfer(Mockito.any(UsbEndpoint.class),
			Mockito.any(byte[].class), Mockito.anyInt(), Mockito.anyInt());

	is.stopReadThread();
}
 
开发者ID:digidotcom,项目名称:XBeeJavaLibrary,代码行数:23,代码来源:AndroidUSBInputStreamTest.java

示例7: createUsbCommunication

import android.hardware.usb.UsbEndpoint; //导入依赖的package包/类
public static UsbCommunication createUsbCommunication(UsbDeviceConnection deviceConnection,
    UsbEndpoint outEndpoint, UsbEndpoint inEndpoint) {
  UsbCommunication communication;

  if (underlyingUsbCommunication == UnderlyingUsbCommunication.DEVICE_CONNECTION_SYNC) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
      communication = new JellyBeanMr2Communication(deviceConnection, outEndpoint, inEndpoint);
    } else {
      Log.i(TAG, "using workaround usb communication");
      communication = new HoneyCombMr1Communication(deviceConnection, outEndpoint, inEndpoint);
    }
  } else {
    communication = new UsbRequestCommunication(deviceConnection, outEndpoint, inEndpoint);
  }

  return communication;
}
 
开发者ID:mrolcsi,项目名称:FileBrowser-Android,代码行数:18,代码来源:UsbCommunicationFactory.java

示例8: write

import android.hardware.usb.UsbEndpoint; //导入依赖的package包/类
public int write(final byte[] data, final int timeout) throws IOException {
    //TODO: score the real interface and endpoint
    final UsbEndpoint endpoint = mDevice.getInterface(0).getEndpoint(1);
    int offset = 0;
    while (offset < data.length) {
        final int write_length;
        final int result;
        synchronized (mWriteBufferLock) {
            final byte[] writeBuffer;
            write_length = Math.min(data.length-offset, mWriteBuffer.length);
            if (offset == 0) {
                writeBuffer = data;
            } else {
                System.arraycopy(data, offset, mWriteBuffer, 0, write_length);
                writeBuffer = mWriteBuffer;
            }
            result = mConnection.bulkTransfer(endpoint, writeBuffer, write_length, timeout);
        }
        if (result <=0) {
            throw new IOException("Error writing " + write_length + " bytes at offset " + offset + " length="+data.length);
        }
        Log.d(TAG, "Wrote " + result + " bytes.  Attempted=" + write_length);
        offset += result;
    }
    return offset;
}
 
开发者ID:brentn,项目名称:StenoIME,代码行数:27,代码来源:SerialDevice.java

示例9: 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

示例10: 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

示例11: setFTDIEndpoints

import android.hardware.usb.UsbEndpoint; //导入依赖的package包/类
private boolean setFTDIEndpoints(UsbInterface[] intf, int portNum) {
    UsbEndpoint epIn;
    UsbEndpoint epOut;

    if (intf[0] == null) {
        return false;
    }

    for (int i = 0; i < portNum; ++i) {
        epIn = intf[i].getEndpoint(0);
        epOut = intf[i].getEndpoint(1);

        if (epIn != null && epOut != null) {
            mFTDIEndpointIN[i] = epIn;
            mFTDIEndpointOUT[i] = epOut;
        } else {
            return false;
        }
    }
    return true;

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

示例12: 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

示例13: write

import android.hardware.usb.UsbEndpoint; //导入依赖的package包/类
@Override
public int write(byte[] src, int timeoutMillis) throws IOException {
    final UsbEndpoint endpoint = mDevice.getInterface(0).getEndpoint(1);
    int offset = 0;

    while (offset < src.length) {
        final int writeLength;
        final int amtWritten;

        synchronized (mWriteBufferLock) {
            final byte[] writeBuffer;

            writeLength = Math.min(src.length - offset, mWriteBuffer.length);
            if (offset == 0) {
                writeBuffer = src;
            } else {
                // bulkTransfer does not support offsets, make a copy.
                System.arraycopy(src, offset, mWriteBuffer, 0, writeLength);
                writeBuffer = mWriteBuffer;
            }

            amtWritten = mConnection.bulkTransfer(endpoint, writeBuffer, writeLength,
                    timeoutMillis);
        }

        if (amtWritten <= 0) {
            throw new IOException("Error writing " + writeLength
                    + " bytes at offset " + offset + " length=" + src.length);
        }

        Log.d(TAG, "Wrote amtWritten=" + amtWritten + " attempted=" + writeLength);
        offset += amtWritten;
    }
    return offset;
}
 
开发者ID:OpilkiInside,项目名称:bimdroid,代码行数:36,代码来源:FtdiSerialDriver.java

示例14: UsbHiSpeedBulk

import android.hardware.usb.UsbEndpoint; //导入依赖的package包/类
public UsbHiSpeedBulk(UsbDeviceConnection usbDeviceConnection, UsbEndpoint usbEndpoint, int nrequests, int packetsPerRequests) {
    this.usbDeviceConnection = usbDeviceConnection;
    this.fileDescriptor = usbDeviceConnection.getFileDescriptor();
    this.nrequests = nrequests;
    this.requests = new ArrayList<>(nrequests);
    this.packetSize = usbEndpoint.getMaxPacketSize();
    this.usbEndpoint = usbEndpoint;
    this.packetsPerRequests = packetsPerRequests;
    this.buffer = new Buffer(packetsPerRequests * packetSize);
}
 
开发者ID:martinmarinov,项目名称:AndroidDvbDriver,代码行数:11,代码来源:UsbHiSpeedBulk.java

示例15: UsbBulkSource

import android.hardware.usb.UsbEndpoint; //导入依赖的package包/类
public UsbBulkSource(UsbDeviceConnection usbDeviceConnection, UsbEndpoint usbEndpoint, AlternateUsbInterface usbInterface, int numRequests, int numPacketsPerReq) {
    this.usbDeviceConnection = usbDeviceConnection;
    this.usbEndpoint = usbEndpoint;
    this.usbInterface = usbInterface;
    this.numRequests = numRequests;
    this.numPacketsPerReq = numPacketsPerReq;
}
 
开发者ID:martinmarinov,项目名称:AndroidDvbDriver,代码行数:8,代码来源:UsbBulkSource.java


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