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


Java UsbConstants.USB_ENDPOINT_XFER_INT属性代码示例

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


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

示例1: UsbHidDevice

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,代码行数:17,代码来源:UsbHidDevice.java

示例2: SonyInitiator

/**
 * 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,代码行数:46,代码来源:SonyInitiator.java

示例3: nameForEndpointType

public static String nameForEndpointType(int type) {
    switch (type) {
        case UsbConstants.USB_ENDPOINT_XFER_BULK:
            return "Bulk";
        case UsbConstants.USB_ENDPOINT_XFER_CONTROL:
            return "Control";
        case UsbConstants.USB_ENDPOINT_XFER_INT:
            return "Interrupt";
        case UsbConstants.USB_ENDPOINT_XFER_ISOC:
            return "Isochronous";
        default:
            return "Unknown Type";
    }
}
 
开发者ID:androidthings,项目名称:sample-usbenum,代码行数:14,代码来源:UsbHelper.java

示例4: FcUsbDevice

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,代码行数:31,代码来源:FcUsbDevice.java

示例5: controlTransfer

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;
}
 
开发者ID:MobileChromeApps,项目名称:cordova-plugin-chrome-apps-usb,代码行数:35,代码来源:ChromeUsb.java

示例6: endpointTypeName

static String endpointTypeName(int type) {
    switch (type) {
        case UsbConstants.USB_ENDPOINT_XFER_BULK: return "bulk";
        case UsbConstants.USB_ENDPOINT_XFER_CONTROL: return "control";
        case UsbConstants.USB_ENDPOINT_XFER_INT: return "interrupt";
        case UsbConstants.USB_ENDPOINT_XFER_ISOC: return "isochronous";
        default: return "ERR:" + type;
    }
}
 
开发者ID:MobileChromeApps,项目名称:cordova-plugin-chrome-apps-usb,代码行数:9,代码来源:ChromeUsb.java

示例7: BaselineInitiator

/**
     * 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
     * @exception IllegalArgumentException if the device has no
     *	Digital Still Imaging Class or PTP interfaces
     */
    public BaselineInitiator(UsbDevice dev, UsbDeviceConnection connection) throws PTPException {
        if (connection == null) {
            throw new PTPException ("Connection = null");//IllegalArgumentException();
        }
    	this.mConnection = connection;
//        try {
            if (dev == null) {
                throw new PTPException ("dev = null");//IllegalArgumentException();
            }
            session = new Session();
            this.device = dev;
            intf = findUsbInterface (dev);

//            UsbInterface usbInterface = intf.getUsbInterface();

            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();

            //UsbDevice usbDevice = dev.getUsbDevice();
//            UsbConfigDescriptor[] descriptors = usbDevice.getConfig();
//
//            if ((descriptors == null) || (descriptors.length < 1)) {
//                throw new PTPException("UsbDevice with no descriptors!");
//            }

            // we want exclusive access to this interface.
            //TODO implement: UsbDeviceConnection.claimInterface (intf, true);
//            dev.open(
//                descriptors[0].getConfigurationValue(),
//                intf.getInterface(),
//                intf.getAlternateSetting()
//            );

            // clear epOut any previous state
            reset();
            if (getClearStatus() != Response.OK
                    && getDeviceStatus(null) != Response.OK) {
                throw new PTPException("can't init");
            }

            Log.d(TAG, "trying getDeviceInfoUncached");
            // get info to sanity check later requests
            info = getDeviceInfoUncached(); 

            // set up to use vendor extensions, if any
            if (info.vendorExtensionId != 0) {
                info.factory = updateFactory(info.vendorExtensionId);
            }
            session.setFactory((NameFactory) this);

    }
 
开发者ID:iyundong,项目名称:InstantUpload,代码行数:78,代码来源:BaselineInitiator.java

示例8: openSingleInterface

private void openSingleInterface() throws IOException {
    // the following code is inspired by the cdc-acm driver
    // in the linux kernel

    mControlInterface = mDevice.getInterface(0);
    Log.d(TAG, "Control iface=" + mControlInterface);

    mDataInterface = mDevice.getInterface(0);
    Log.d(TAG, "data iface=" + mDataInterface);

    if (!mConnection.claimInterface(mControlInterface, true)) {
        throw new IOException("Could not claim shared control/data interface.");
    }

    int endCount = mControlInterface.getEndpointCount();

    if (endCount < 3) {
        Log.d(TAG, "not enough endpoints - need 3. count=" + mControlInterface.getEndpointCount());
        throw new IOException("Insufficient number of endpoints(" + mControlInterface.getEndpointCount() + ")");
    }

    // Analyse endpoints for their properties
    mControlEndpoint = null;
    mReadEndpoint = null;
    mWriteEndpoint = null;
    for (int i = 0; i < endCount; ++i) {
        UsbEndpoint ep = mControlInterface.getEndpoint(i);
        if ((ep.getDirection() == UsbConstants.USB_DIR_IN) &&
                (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT)) {
            Log.d(TAG, "Found controlling endpoint");
            mControlEndpoint = ep;
        } else if ((ep.getDirection() == UsbConstants.USB_DIR_IN) &&
                (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK)) {
            Log.d(TAG, "Found reading endpoint");
            mReadEndpoint = ep;
        } else if ((ep.getDirection() == UsbConstants.USB_DIR_OUT) &&
                (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK)) {
            Log.d(TAG, "Found writing endpoint");
            mWriteEndpoint = ep;
        }


        if ((mControlEndpoint != null) &&
                (mReadEndpoint != null) &&
                (mWriteEndpoint != null)) {
            Log.d(TAG, "Found all required endpoints");
            break;
        }
    }

    if ((mControlEndpoint == null) ||
            (mReadEndpoint == null) ||
            (mWriteEndpoint == null)) {
        Log.d(TAG, "Could not establish all endpoints");
        throw new IOException("Could not establish all endpoints");
    }
}
 
开发者ID:msillano,项目名称:USBphpTunnel,代码行数:57,代码来源:CdcAcmSerialDriver.java

示例9: openSingleInterface

private void openSingleInterface() throws IOException {
    // the following code is inspired by the cdc-acm driver
    // in the linux kernel

    mControlInterface = mDevice.getInterface(0);
    Log.d(TAG, "Control iface=" + mControlInterface);

    mDataInterface = mDevice.getInterface(0);
    Log.d(TAG, "data iface=" + mDataInterface);

    if (!mConnection.claimInterface(mControlInterface, true)) {
        throw new IOException("Could not claim shared control/data interface.");
    }

    int endCount = mControlInterface.getEndpointCount();

    if (endCount < 3) {
        Log.d(TAG,"not enough endpoints - need 3. count=" + mControlInterface.getEndpointCount());
        throw new IOException("Insufficient number of endpoints(" + mControlInterface.getEndpointCount() + ")");
    }

    // Analyse endpoints for their properties
    mControlEndpoint = null;
    mReadEndpoint = null;
    mWriteEndpoint = null;
    for (int i = 0; i < endCount; ++i) {
        UsbEndpoint ep = mControlInterface.getEndpoint(i);
        if ((ep.getDirection() == UsbConstants.USB_DIR_IN) &&
            (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT)) {
            Log.d(TAG,"Found controlling endpoint");
            mControlEndpoint = ep;
        } else if ((ep.getDirection() == UsbConstants.USB_DIR_IN) &&
                   (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK)) {
            Log.d(TAG,"Found reading endpoint");
            mReadEndpoint = ep;
        } else if ((ep.getDirection() == UsbConstants.USB_DIR_OUT) &&
                (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK)) {
            Log.d(TAG,"Found writing endpoint");
            mWriteEndpoint = ep;
        }


        if ((mControlEndpoint != null) &&
            (mReadEndpoint != null) &&
            (mWriteEndpoint != null)) {
            Log.d(TAG,"Found all required endpoints");
            break;
        }
    }

    if ((mControlEndpoint == null) ||
            (mReadEndpoint == null) ||
            (mWriteEndpoint == null)) {
        Log.d(TAG,"Could not establish all endpoints");
        throw new IOException("Could not establish all endpoints");
    }
}
 
开发者ID:meedeepak,项目名称:Arduino-android-serial-communication,代码行数:57,代码来源:CdcAcmSerialDriver.java

示例10: openSingleInterface

private void openSingleInterface() throws IOException {
    // the following code is inspired by the cdc-acm driver
    // in the linux kernel

    mControlInterface = mDevice.getInterface(0);
    Log.d(TAG, "Control iface=" + mControlInterface);

    mDataInterface = mDevice.getInterface(0);
    Log.d(TAG, "data iface=" + mDataInterface);

    if (!mConnection.claimInterface(mControlInterface, true)) {
        throw new IOException("Could not claim shared control/data interface.");
    }

    int endCount = mControlInterface.getEndpointCount();

    if (endCount < 3) {
        Log.d(TAG, "not enough endpoints - need 3. count=" + mControlInterface.getEndpointCount());
        throw new IOException("Insufficient number of endpoints(" + mControlInterface.getEndpointCount() + ")");
    }

    // Analyse endpoints for their properties
    mControlEndpoint = null;
    mReadEndpoint = null;
    mWriteEndpoint = null;
    for (int i = 0; i < endCount; ++i) {
        UsbEndpoint ep = mControlInterface.getEndpoint(i);
        if ((ep.getDirection() == UsbConstants.USB_DIR_IN) && (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT)) {
            Log.d(TAG, "Found controlling endpoint");
            mControlEndpoint = ep;
        } else if ((ep.getDirection() == UsbConstants.USB_DIR_IN) && (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK)) {
            Log.d(TAG, "Found reading endpoint");
            mReadEndpoint = ep;
        } else if ((ep.getDirection() == UsbConstants.USB_DIR_OUT) && (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK)) {
            Log.d(TAG, "Found writing endpoint");
            mWriteEndpoint = ep;
        }


        if ((mControlEndpoint != null) && (mReadEndpoint != null) && (mWriteEndpoint != null)) {
            Log.d(TAG, "Found all required endpoints");
            break;
        }
    }

    if ((mControlEndpoint == null) || (mReadEndpoint == null) || (mWriteEndpoint == null)) {
        Log.d(TAG, "Could not establish all endpoints");
        throw new IOException("Could not establish all endpoints");
    }
}
 
开发者ID:HelloHuDi,项目名称:usb-with-serial-port,代码行数:50,代码来源:CdcAcmSerialDriver.java

示例11: setDevice

private void setDevice(UsbDevice device) {
        if (device == null) {
            mConnection = null;
            mRunning = false;
            return;
        }
        Log.d(TAG, "setDevice " + device.getDeviceName());

        if (device.getInterfaceCount() != 1) {
            Toast.makeText(activity, "no usb interface", Toast.LENGTH_LONG).show();
            Log.e(TAG, "no usb interface");
            return;
        }
        UsbInterface intf = device.getInterface(0);
        if (intf.getEndpointCount() != 1) {
            Toast.makeText(activity, "no usb interface endpoint", Toast.LENGTH_LONG).show();
            Log.e(TAG, "no usb interface endpoint");
            return;
        }
        UsbEndpoint ep = intf.getEndpoint(0);
        if (ep.getType() != UsbConstants.USB_ENDPOINT_XFER_INT
                || ep.getDirection() != UsbConstants.USB_DIR_IN) {
            Toast.makeText(activity, "endpoint is not Interrupt IN", Toast.LENGTH_LONG).show();
            Log.e(TAG, "endpoint is not Interrupt IN");
            return;
        }
        mDevice = device;
        mEndpointIntr = ep;

        UsbDeviceConnection connection = mUsbManager.openDevice(device);
        if (connection != null && connection.claimInterface(intf, true)) {
            mConnection = connection;
//            updateAttributesData(mConnection);
//            updateLimitData(mConnection);

            mRunning = true;
            Thread thread = new Thread(null, this, "ScaleMonitor");
            thread.start();
        } else {
            mConnection = null;
            mRunning = false;
        }
    }
 
开发者ID:Kornkammer,项目名称:foodcoapp,代码行数:43,代码来源:Scale.java

示例12: tryGetDevice

private TrezorDevice tryGetDevice() {
    if (device == null) {
        Timber.i(TAG, "tryGetDevice: trying to find and open connection to TREZOR");
        HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList();

        deviceWithoutPermission = null;

        for (UsbDevice usbDevice : deviceList.values()) {
            // check if the device is TREZOR
            if (!deviceIsTrezor(usbDevice))
                continue;

            Timber.i(TAG, "tryGetDevice: TREZOR device found");

            if (!usbManager.hasPermission(usbDevice)) {
                if (deviceWithoutPermission == null)
                    deviceWithoutPermission = usbDevice;
                continue;
            }

            // use first interface
            UsbInterface usbInterface = usbDevice.getInterface(0);
            // try to find read/write endpoints
            UsbEndpoint readEndpoint = null, writeEndpoint = null;
            for (int i = 0; i < usbInterface.getEndpointCount(); i++) {
                UsbEndpoint ep = usbInterface.getEndpoint(i);
                if (readEndpoint == null && ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT && ep.getAddress() == 0x81) { // number = 1 ; dir = USB_DIR_IN
                    readEndpoint = ep;
                    continue;
                }
                if (writeEndpoint == null && ep.getType() == UsbConstants.USB_ENDPOINT_XFER_INT && (ep.getAddress() == 0x01 || ep.getAddress() == 0x02)) { // number = 1 ; dir = USB_DIR_OUT
                    writeEndpoint = ep;
                }
            }
            if (readEndpoint == null) {
                Timber.e(TAG, "tryGetDevice: Could not find read endpoint");
                continue;
            }
            if (writeEndpoint == null) {
                Timber.e(TAG, "tryGetDevice: Could not find write endpoint");
                continue;
            }
            if (readEndpoint.getMaxPacketSize() != 64) {
                Timber.e(TAG, "tryGetDevice: Wrong packet size for read endpoint");
                continue;
            }
            if (writeEndpoint.getMaxPacketSize() != 64) {
                Timber.e(TAG, "tryGetDevice: Wrong packet size for write endpoint");
                continue;
            }

            UsbDeviceConnection conn = usbManager.openDevice(usbDevice);
            if (conn == null) {
                Timber.e(TAG, "tryGetDevice: could not open connection");
            } else {
                if (!conn.claimInterface(usbInterface, true)) {
                    Timber.e(TAG, "tryGetDevice: could not claim interface");
                } else {
                    deviceWithoutPermission = null;
                    device = new TrezorDevice(usbDevice.getDeviceName(), conn.getSerial(), conn, usbInterface, readEndpoint, writeEndpoint);
                    break;
                }
            }
        }
        Timber.i(TAG, "tryGetDevice: " + (this.device == null ? "TREZOR device not found or failed to connect" : "TREZOR device successfully connected"));
    } else
        Timber.i(TAG, "tryGetDevice: using already connected device");
    return device;
}
 
开发者ID:trezor,项目名称:trezor-android,代码行数:69,代码来源:TrezorManager.java

示例13: open

public synchronized void open() throws IOException {
    if (usbDevice == null) throw new IllegalArgumentException("Device can't be null");

    if (usbInterface == null) {
        for (int i = 0; i < usbDevice.getInterfaceCount(); i++) {
            UsbInterface usbIf = usbDevice.getInterface(i);
            if (usbIf.getInterfaceClass() == UsbConstants.USB_CLASS_CSCID) {
                usbInterface = usbIf;
            }
        }
        if (usbInterface == null)
            throw new IllegalStateException("The device hasn't a smart card reader");
    }

    usbConnection = usbManager.openDevice(usbDevice);
    usbConnection.claimInterface(usbInterface, true);
    sequence = 0;

    //Get the interfaces
    for (int i = 0; i < usbInterface.getEndpointCount(); i++) {
        UsbEndpoint usbEp = usbInterface.getEndpoint(i);
        if (usbEp.getDirection() == UsbConstants.USB_DIR_IN && usbEp.getType() == UsbConstants.USB_ENDPOINT_XFER_INT) {
            usbInterrupt = usbEp;
        }
        if (usbEp.getDirection() == UsbConstants.USB_DIR_OUT && usbEp.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
            usbOut = usbEp;
        }
        if (usbEp.getDirection() == UsbConstants.USB_DIR_IN && usbEp.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
            usbIn = usbEp;
        }
    }

    //check for pinPad
    CCIDDescriptor desc = CCIDDescriptor.Parse(usbConnection.getRawDescriptors()).get(usbInterface.getId());
    pinPad = desc.getPinSupports().contains(CCIDDescriptor.PINSupport.Verification);
    supportApdu = desc.getFeatures().contains(CCIDDescriptor.Feature.ShortAPDU) || desc.getFeatures().contains(CCIDDescriptor.Feature.ShortAndExtendedAPDU);
    autoInit = desc.getFeatures().contains(CCIDDescriptor.Feature.AutoParamConfigViaATR);

    //Listen for state changes
    setupStateListener();
}
 
开发者ID:egelke,项目名称:eIDSuite,代码行数:41,代码来源:CCID.java

示例14: detectSpeed

private int detectSpeed(UsbDevice dev, UsbDeviceDescriptor devDesc) {
	int possibleSpeeds = FLAG_POSSIBLE_SPEED_LOW |
			FLAG_POSSIBLE_SPEED_FULL |
			FLAG_POSSIBLE_SPEED_HIGH;
	
	for (int i = 0; i < dev.getInterfaceCount(); i++) {
		UsbInterface iface = dev.getInterface(i);
		for (int j = 0; j < iface.getEndpointCount(); j++) {
			UsbEndpoint endpoint = iface.getEndpoint(j);
			if ((endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) ||
				(endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_ISOC)) {
				// Low speed devices can't implement bulk or iso endpoints
				possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_LOW;
			}
			
			if (endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_CONTROL) {
				if (endpoint.getMaxPacketSize() > 8) {
					// Low speed devices can't use control transfer sizes larger than 8 bytes
					possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_LOW;
				}
				if (endpoint.getMaxPacketSize() < 64) {
					// High speed devices can't use control transfer sizes smaller than 64 bytes
					possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_HIGH;
				}
			}
			else if (endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_INT) {
				if (endpoint.getMaxPacketSize() > 8) {
					// Low speed devices can't use interrupt transfer sizes larger than 8 bytes
					possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_LOW;
				}
				if (endpoint.getMaxPacketSize() > 64) {
					// Full speed devices can't use interrupt transfer sizes larger than 64 bytes
					possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_FULL;
				}
			}
			else if (endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
				// A bulk endpoint alone can accurately distiniguish between
				// full and high speed devices
				if (endpoint.getMaxPacketSize() == 512) {
					// High speed devices can only use 512 byte bulk transfers
					possibleSpeeds = FLAG_POSSIBLE_SPEED_HIGH;
				}
				else {
					// Otherwise it must be full speed
					possibleSpeeds = FLAG_POSSIBLE_SPEED_FULL;
				}
			}
			else if (endpoint.getType() == UsbConstants.USB_ENDPOINT_XFER_ISOC) {
				// If the transfer size is 1024, it must be high speed
				if (endpoint.getMaxPacketSize() == 1024) {
					possibleSpeeds = FLAG_POSSIBLE_SPEED_HIGH;
				}
			}
		}
	}
	
	if (devDesc != null) {
		if (devDesc.bcdUSB < 0x200) {
			// High speed only supported on USB 2.0 or higher
			possibleSpeeds &= ~FLAG_POSSIBLE_SPEED_HIGH;
		}
	}
	
	// Return the lowest speed that we're compatible with
	System.out.printf("Speed heuristics for device %d left us with 0x%x\n",
			dev.getDeviceId(), possibleSpeeds);

	if ((possibleSpeeds & FLAG_POSSIBLE_SPEED_LOW) != 0) {
		return UsbIpDevice.USB_SPEED_LOW;
	}
	else if ((possibleSpeeds & FLAG_POSSIBLE_SPEED_FULL) != 0) {
		return UsbIpDevice.USB_SPEED_FULL;
	}
	else if ((possibleSpeeds & FLAG_POSSIBLE_SPEED_HIGH) != 0) {
		return UsbIpDevice.USB_SPEED_HIGH;
	}
	else {
		// Something went very wrong in speed detection
		return UsbIpDevice.USB_SPEED_UNKNOWN;
	}
}
 
开发者ID:cgutman,项目名称:USBIPServerForAndroid,代码行数:81,代码来源:UsbIpService.java

示例15: UsbPl2303Controller

public UsbPl2303Controller(UsbManager usbManager, UsbDevice usbDevice)
		throws UsbControllerException {
	super(usbManager, usbDevice);

	int endpointCount;

	if (!UsbPl2303Controller.probe(usbDevice)) {
		throw new UsbControllerException("probe() failed");
	}

	if (usbDevice.getInterfaceCount() != 1) {
		throw new UsbControllerException("getInterfaceCount() != 1");
	}

	mUsbInterfaces = new android.hardware.usb.UsbInterface[1];
	mUsbInterfaces[0] = usbDevice.getInterface(0);
	endpointCount = mUsbInterfaces[0].getEndpointCount();
	if (endpointCount != 3) {
		throw new UsbControllerException("getEndpointCount() != 3 (" + endpointCount + ")");
	}

	for (int i=0; i < endpointCount; i++) {
		UsbEndpoint e = mUsbInterfaces[0].getEndpoint(i);
		switch (e.getType()) {
		case UsbConstants.USB_ENDPOINT_XFER_INT:
			mInterruptEndpoint = e;
			break;
		case UsbConstants.USB_ENDPOINT_XFER_BULK:
			if (e.getDirection() == UsbConstants.USB_DIR_IN)
				mBulkInEndpoint = e;
			else
				mBulkOutEndpoint = e;
			break;
		default:
			throw new UsbControllerException("Unexpected endpoint " + i + "type = " + e.getType());
		}
	}

	if (mInterruptEndpoint == null) {
		throw new UsbControllerException("Interrupt input endpoint not found");
	}else if (mBulkInEndpoint == null) {
		throw new UsbControllerException("Bulk data input endpoint not found");
	}else if (mBulkOutEndpoint == null) {
		throw new UsbControllerException("Bulk data output endpoint not found");
	}

	isPl2303Hx = (usbDevice.getDeviceClass() != 0x02)
			&& (mBulkOutEndpoint.getMaxPacketSize() == 0x40);

	mSerialLineConfiguration = new SerialLineConfiguration();
}
 
开发者ID:illarionov,项目名称:RtkGps,代码行数:51,代码来源:UsbPl2303Controller.java


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