本文整理汇总了Java中android.hardware.usb.UsbRequest类的典型用法代码示例。如果您正苦于以下问题:Java UsbRequest类的具体用法?Java UsbRequest怎么用?Java UsbRequest使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UsbRequest类属于android.hardware.usb包,在下文中一共展示了UsbRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
public boolean write(AdbDevice device) {
synchronized (device) {
UsbRequest request = device.getOutRequest();
request.setClientData(this);
if (request.queue(mMessageBuffer, 24)) {
int length = getDataLength();
if (length > 0) {
request = device.getOutRequest();
request.setClientData(this);
if (request.queue(mDataBuffer, length)) {
return true;
} else {
device.releaseOutRequest(request);
return false;
}
}
return true;
} else {
device.releaseOutRequest(request);
return false;
}
}
}
示例2: open
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
@Override
public boolean open()
{
boolean ret = openPL2303();
if(ret)
{
// Initialize UsbRequest
requestIN = new UsbRequest();
requestIN.initialize(connection, inEndpoint);
// Restart the working thread if it has been killed before and get and claim interface
restartWorkingThread();
restartWriteThread();
// Pass references to the threads
setThreadsParams(requestIN, outEndpoint);
asyncMode = true;
return true;
}else
{
return false;
}
}
示例3: open
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
@Override
public boolean open()
{
boolean ret = openCDC();
if(ret)
{
// Initialize UsbRequest
requestIN = new UsbRequest();
requestIN.initialize(connection, inEndpoint);
// Restart the working thread if it has been killed before and get and claim interface
restartWorkingThread();
restartWriteThread();
// Pass references to the threads
setThreadsParams(requestIN, outEndpoint);
asyncMode = true;
return true;
}else
{
return false;
}
}
示例4: open
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
@Override
public boolean open()
{
boolean ret = openFTDI();
if(ret)
{
// Initialize UsbRequest
requestIN = new UsbRequest();
requestIN.initialize(connection, inEndpoint);
// Restart the working thread if it has been killed before and get and claim interface
restartWorkingThread();
restartWriteThread();
// Pass references to the threads
setThreadsParams(requestIN, outEndpoint);
asyncMode = true;
return true;
}else
{
return false;
}
}
示例5: open
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
@Override
public boolean open()
{
boolean ret = openCH34X();
if(ret)
{
setBaudRate(DEFAULT_BAUDRATE);
// Initialize UsbRequest
requestIN = new UsbRequest();
requestIN.initialize(connection, inEndpoint);
// Restart the working thread if it has been killed before and get and claim interface
restartWorkingThread();
restartWriteThread();
// Pass references to the threads
setThreadsParams(requestIN, outEndpoint);
asyncMode = true;
return true;
}else
{
return false;
}
}
示例6: bulkOutTransfer
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
@Override
public synchronized int bulkOutTransfer(ByteBuffer src) throws IOException {
int length = src.remaining();
int oldPosition = src.position();
// workaround: UsbRequest.queue always reads at position 0 :/
workaroundBuffer.clear();
workaroundBuffer.put(src);
if (!outRequest.queue(workaroundBuffer, length)) {
throw new IOException("Error queueing request.");
}
UsbRequest request = deviceConnection.requestWait();
if (request == outRequest) {
src.position(oldPosition + workaroundBuffer.position());
return workaroundBuffer.position();
}
throw new IOException("requestWait failed! Request: " + request);
}
示例7: bulkInTransfer
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
@Override
public synchronized int bulkInTransfer(ByteBuffer dest) throws IOException {
int length = dest.remaining();
// workaround: UsbRequest.queue always writes at position 0 :/
workaroundBuffer.clear();
workaroundBuffer.limit(length);
if (!inRequest.queue(workaroundBuffer, length)) {
throw new IOException("Error queueing request.");
}
UsbRequest request = deviceConnection.requestWait();
if (request == inRequest) {
workaroundBuffer.flip();
dest.put(workaroundBuffer);
return workaroundBuffer.limit();
}
throw new IOException("requestWait failed! Request: " + request);
}
示例8: UsbMidiDeviceAndroid
import android.hardware.usb.UsbRequest; //导入依赖的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);
}
}
}
}
示例9: getOutRequest
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
public UsbRequest getOutRequest() {
synchronized(mOutRequestPool) {
if (mOutRequestPool.isEmpty()) {
UsbRequest request = new UsbRequest();
request.initialize(mDeviceConnection, mEndpointOut);
return request;
} else {
return mOutRequestPool.removeFirst();
}
}
}
示例10: getInRequest
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
public UsbRequest getInRequest() {
synchronized(mInRequestPool) {
if (mInRequestPool.isEmpty()) {
UsbRequest request = new UsbRequest();
request.initialize(mDeviceConnection, mEndpointIn);
return request;
} else {
return mInRequestPool.removeFirst();
}
}
}
示例11: open
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
@Override
public boolean open()
{
initSerialBuffer();
boolean ret = openCH34X();
if(ret)
{
// Initialize UsbRequest
requestIN = new UsbRequest();
requestIN.initialize(connection, inEndpoint);
// Restart the working thread if it has been killed before and get and claim interface
restartWorkingThread();
restartWriteThread();
// Create Flow control thread but it will only be started if necessary
createFlowControlThread();
// Pass references to the threads
setThreadsParams(requestIN, outEndpoint);
asyncMode = true;
return true;
}else
{
return false;
}
}
示例12: run
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
@Override
public void run()
{
while(working.get())
{
UsbRequest request = connection.requestWait();
if(request != null && request.getEndpoint().getType() == UsbConstants.USB_ENDPOINT_XFER_BULK
&& request.getEndpoint().getDirection() == UsbConstants.USB_DIR_IN)
{
byte[] data = serialBuffer.getDataReceived();
// FTDI devices reserves two first bytes of an IN endpoint with info about
// modem and Line.
if(isFTDIDevice())
{
((FTDISerialDevice) usbSerialDevice).ftdiUtilities.checkModemStatus(data); //Check the Modem status
serialBuffer.clearReadBuffer();
if(data.length > 2)
{
data = ((FTDISerialDevice) usbSerialDevice).ftdiUtilities.adaptArray(data);
onReceivedData(data);
}
}else
{
// Clear buffer, execute the callback
serialBuffer.clearReadBuffer();
onReceivedData(data);
}
// Queue a new request
requestIN.queue(serialBuffer.getReadBuffer(), serialBuffer.getReadBufferSize());
}
}
}
示例13: setThreadsParams
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
protected void setThreadsParams(UsbRequest request, UsbEndpoint endpoint)
{
if(mr1Version)
{
workerThread.setUsbRequest(request);
writeThread.setUsbEndpoint(endpoint);
}else
{
readThread.setUsbEndpoint(request.getEndpoint());
writeThread.setUsbEndpoint(endpoint);
}
}
示例14: open
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
@Override
public boolean open()
{
initSerialBuffer();
boolean ret = openCP2102();
if(ret)
{
// Initialize UsbRequest
requestIN = new UsbRequest();
requestIN.initialize(connection, inEndpoint);
// Restart the working thread if it has been killed before and get and claim interface
restartWorkingThread();
restartWriteThread();
// Create Flow control thread but it will only be started if necessary
createFlowControlThread();
// Pass references to the threads
setThreadsParams(requestIN, outEndpoint);
asyncMode = true;
return true;
}else
{
return false;
}
}
示例15: open
import android.hardware.usb.UsbRequest; //导入依赖的package包/类
@Override
public boolean open()
{
initSerialBuffer();
boolean ret = openPL2303();
if(ret)
{
// Initialize UsbRequest
requestIN = new UsbRequest();
requestIN.initialize(connection, inEndpoint);
// Restart the working thread if it has been killed before and get and claim interface
restartWorkingThread();
restartWriteThread();
// Pass references to the threads
setThreadsParams(requestIN, outEndpoint);
asyncMode = true;
return true;
}else
{
return false;
}
}