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


Java UsbRequest类代码示例

本文整理汇总了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;
        }
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:24,代码来源:AdbMessage.java

示例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;
    }
}
 
开发者ID:GIGATeam,项目名称:UsbExtension,代码行数:27,代码来源:PL2303SerialDevice.java

示例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;
    }
}
 
开发者ID:GIGATeam,项目名称:UsbExtension,代码行数:27,代码来源:CDCSerialDevice.java

示例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;
    }
}
 
开发者ID:GIGATeam,项目名称:UsbExtension,代码行数:27,代码来源:FTDISerialDevice.java

示例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;
    }
}
 
开发者ID:once2go,项目名称:mvp.recar.io,代码行数:27,代码来源:CH34xSerialDevice.java

示例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);
}
 
开发者ID:mrolcsi,项目名称:FileBrowser-Android,代码行数:22,代码来源:UsbRequestCommunication.java

示例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);
}
 
开发者ID:mrolcsi,项目名称:FileBrowser-Android,代码行数:22,代码来源:UsbRequestCommunication.java

示例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);
            }
        }
    }
}
 
开发者ID:mogoweb,项目名称:chromium_webview,代码行数:26,代码来源:UsbMidiDeviceAndroid.java

示例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();
        }
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:12,代码来源:AdbDevice.java

示例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();
        }
    }
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:12,代码来源:AdbDevice.java

示例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;
    }
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:31,代码来源:CH34xSerialDevice.java

示例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());
        }
    }
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:35,代码来源:UsbSerialDevice.java

示例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);
    }
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:13,代码来源:UsbSerialDevice.java

示例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;
    }
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:32,代码来源:CP2102SerialDevice.java

示例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;
    }
}
 
开发者ID:BITPlan,项目名称:can4eve,代码行数:29,代码来源:PL2303SerialDevice.java


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