本文整理汇总了Java中android.hardware.usb.UsbRequest.initialize方法的典型用法代码示例。如果您正苦于以下问题:Java UsbRequest.initialize方法的具体用法?Java UsbRequest.initialize怎么用?Java UsbRequest.initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.hardware.usb.UsbRequest
的用法示例。
在下文中一共展示了UsbRequest.initialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: 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;
}
}
示例3: 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;
}
}
示例4: 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;
}
}
示例5: 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();
}
}
}
示例6: 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();
}
}
}
示例7: 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;
}
}
示例8: 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;
}
}
示例9: 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;
}
}
示例10: open
import android.hardware.usb.UsbRequest; //导入方法依赖的package包/类
@Override
public boolean open()
{
initSerialBuffer();
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;
}
}
示例11: open
import android.hardware.usb.UsbRequest; //导入方法依赖的package包/类
@Override
public boolean open()
{
initSerialBuffer();
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;
}
}
示例12: open
import android.hardware.usb.UsbRequest; //导入方法依赖的package包/类
@Override
public boolean open()
{
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;
}
}
示例13: open
import android.hardware.usb.UsbRequest; //导入方法依赖的package包/类
@Override
public boolean open()
{
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;
}
}
示例14: controlTransfer
import android.hardware.usb.UsbRequest; //导入方法依赖的package包/类
int controlTransfer(int requestType, int request, int value, int index,
byte[] transferBuffer, byte[] receiveBuffer, int timeout) {
UsbEndpoint ep = mDevice.getInterface(0).getEndpoint(0);
int result = -1;
if(ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT &&
ep.getDirection() == UsbConstants.USB_DIR_IN) {
ByteBuffer bb = ByteBuffer.wrap(receiveBuffer);
UsbRequest ur = new UsbRequest();
ur.initialize(mConnection, ep);
ur.queue(bb, receiveBuffer.length);
result = mConnection.controlTransfer(requestType, request, value, index,
transferBuffer, transferBuffer.length, timeout);
if(result >= 0) {
if (mConnection.requestWait() != ur) {
Log.e(TAG, "[controlTransfer] requestWait failed");
return -1;
}
} else {
Log.e(TAG, "[controlTransfer] Transfer failed");
}
} else {
result = mConnection.controlTransfer(requestType, request, value, index,
transferBuffer, transferBuffer.length, timeout);
receiveBuffer = transferBuffer.clone();
}
return result;
}
示例15: messageWrite
import android.hardware.usb.UsbRequest; //导入方法依赖的package包/类
private void messageWrite(Message msg) {
int msg_size = msg.getSerializedSize();
String msg_name = msg.getClass().getSimpleName();
int msg_id = MessageType.valueOf("MessageType_" + msg_name).getNumber();
Timber.i(TAG, String.format("messageWrite: Got message: %s (%d bytes)", msg_name, msg_size));
ByteBuffer data = ByteBuffer.allocate(msg_size + 1024); // 32768);
data.put((byte) '#');
data.put((byte) '#');
data.put((byte) ((msg_id >> 8) & 0xFF));
data.put((byte) (msg_id & 0xFF));
data.put((byte) ((msg_size >> 24) & 0xFF));
data.put((byte) ((msg_size >> 16) & 0xFF));
data.put((byte) ((msg_size >> 8) & 0xFF));
data.put((byte) (msg_size & 0xFF));
data.put(msg.toByteArray());
while (data.position() % 63 > 0) {
data.put((byte) 0);
}
UsbRequest request = new UsbRequest();
request.initialize(usbConnection, writeEndpoint);
int chunks = data.position() / 63;
Timber.i(TAG, String.format("messageWrite: Writing %d chunks", chunks));
data.rewind();
for (int i = 0; i < chunks; i++) {
byte[] buffer = new byte[64];
buffer[0] = (byte) '?';
data.get(buffer, 1, 63);
request.queue(ByteBuffer.wrap(buffer), 64);
usbConnection.requestWait();
}
}