本文整理匯總了Java中android.hardware.usb.UsbInterface.getEndpointCount方法的典型用法代碼示例。如果您正苦於以下問題:Java UsbInterface.getEndpointCount方法的具體用法?Java UsbInterface.getEndpointCount怎麽用?Java UsbInterface.getEndpointCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.hardware.usb.UsbInterface
的用法示例。
在下文中一共展示了UsbInterface.getEndpointCount方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: AdbDevice
import android.hardware.usb.UsbInterface; //導入方法依賴的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;
}
示例2: dumpInterfaces
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
public static void dumpInterfaces(UsbDevice dev) {
for (int i = 0; i < dev.getInterfaceCount(); i++) {
System.out.printf("%d - Iface %d (%02x/%02x/%02x)\n",
i, dev.getInterface(i).getId(),
dev.getInterface(i).getInterfaceClass(),
dev.getInterface(i).getInterfaceSubclass(),
dev.getInterface(i).getInterfaceProtocol());
UsbInterface iface = dev.getInterface(i);
for (int j = 0; j < iface.getEndpointCount(); j++) {
System.out.printf("\t%d - Endpoint %d (%x/%x)\n",
j, iface.getEndpoint(j).getEndpointNumber(),
iface.getEndpoint(j).getAddress(),
iface.getEndpoint(j).getAttributes());
}
}
}
示例3: ConnectedUsbDevice
import android.hardware.usb.UsbInterface; //導入方法依賴的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);
}
}
示例4: UsbMidiDeviceAndroid
import android.hardware.usb.UsbInterface; //導入方法依賴的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);
}
}
}
}
示例5: SmartCardChannel
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
/** Constructor. Inicia los EndPoints del Interfaz del dispositivo
* @param usbDevCon
* @param usbInterface */
protected SmartCardChannel(final UsbDeviceConnection usbDevCon, final UsbInterface usbInterface) {
this.usbDeviceConnection = usbDevCon;
for (int i = 0; i < usbInterface.getEndpointCount(); i++) {
final UsbEndpoint usbEndPoint = usbInterface.getEndpoint(i);
if (usbEndPoint.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
if (usbEndPoint.getDirection() == UsbConstants.USB_DIR_IN) {
this.endPointIn = usbEndPoint;
}
else if (usbEndPoint.getDirection() == UsbConstants.USB_DIR_OUT) {
this.endPointOut = usbEndPoint;
}
}
}
}
示例6: FcUsbDevice
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
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);
}
示例7: open
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
@Override
public void open() throws IOException {
boolean opened = false;
try {
for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
UsbInterface usbIface = mDevice.getInterface(i);
if (mConnection.claimInterface(usbIface, true)) {
Log.d(TAG, "claimInterface " + i + " SUCCESS");
} else {
Log.d(TAG, "claimInterface " + i + " FAIL");
}
}
UsbInterface dataIface = mDevice.getInterface(mDevice.getInterfaceCount() - 1);
for (int i = 0; i < dataIface.getEndpointCount(); i++) {
UsbEndpoint ep = dataIface.getEndpoint(i);
if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
if (ep.getDirection() == UsbConstants.USB_DIR_IN) {
mReadEndpoint = ep;
} else {
mWriteEndpoint = ep;
}
}
}
setConfigSingle(SILABSER_IFC_ENABLE_REQUEST_CODE, UART_ENABLE);
setConfigSingle(SILABSER_SET_MHS_REQUEST_CODE, MCR_ALL | CONTROL_WRITE_DTR | CONTROL_WRITE_RTS);
setConfigSingle(SILABSER_SET_BAUDDIV_REQUEST_CODE, BAUD_RATE_GEN_FREQ / DEFAULT_BAUD_RATE);
// setParameters(DEFAULT_BAUD_RATE, DEFAULT_DATA_BITS, DEFAULT_STOP_BITS, DEFAULT_PARITY);
opened = true;
} finally {
if (!opened) {
close();
}
}
}
示例8: getEndpoint
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
private UsbEndpoint getEndpoint(int devNum, int intfNum, int usbDir) {
UsbInterface intf = mUsbAccess.intface(devNum, intfNum);
if (intf == null) {
return null;
}
for (int i = 0; i < intf.getEndpointCount(); i++) {
UsbEndpoint ep = mUsbAccess.endpoint(devNum, intfNum, i);
if (ep == null) return null;
if (ep.getDirection() == usbDir) {
return ep;
}
}
return null;
}
示例9: setupDevice
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
private UsbDeviceConnection setupDevice(UsbManager manager,
UsbDevice device) throws UsbDeviceException {
if(device.getInterfaceCount() != 1) {
throw new UsbDeviceException("USB device didn't have an " +
"interface for us to open");
}
UsbInterface iface = null;
for(int i = 0; i < device.getInterfaceCount(); i++) {
iface = device.getInterface(i);
if(iface.getEndpointCount() == ENDPOINT_COUNT) {
break;
}
}
if(iface == null) {
Log.w(TAG, "Unable to find a USB device interface with the " +
"expected number of endpoints (" + ENDPOINT_COUNT + ")");
return null;
}
for(int i = 0; i < iface.getEndpointCount(); i++) {
UsbEndpoint endpoint = iface.getEndpoint(i);
if(endpoint.getType() ==
UsbConstants.USB_ENDPOINT_XFER_BULK) {
if(endpoint.getDirection() == UsbConstants.USB_DIR_IN) {
Log.d(TAG, "Found IN endpoint " + endpoint);
mInEndpoint = endpoint;
} else {
Log.d(TAG, "Found OUT endpoint " + endpoint);
mOutEndpoint = endpoint;
}
}
if(mInEndpoint != null && mOutEndpoint != null) {
break;
}
}
return openInterface(manager, device, iface);
}
示例10: UsbMidiDeviceAndroid
import android.hardware.usb.UsbInterface; //導入方法依賴的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 SparseArray<UsbEndpoint>();
mRequestMap = new HashMap<UsbEndpoint, UsbRequest>();
mHandler = new Handler();
mUsbDevice = device;
mIsClosed = false;
mHasInputThread = false;
mNativePointer = 0;
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);
}
}
}
// Start listening for input endpoints.
// This function will create and run a thread if there is USB-MIDI endpoints in the
// device. Note that because UsbMidiDevice is shared among all tabs and the thread
// will be terminated when the device is disconnected, at most one thread can be created
// for each connected USB-MIDI device.
startListen(device);
}
示例11: getEndpoint
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
private UsbEndpoint getEndpoint(int devNum, int intfNum, int usbDir) {
UsbInterface intf = mUsbAccess.intface(devNum, intfNum);
if(intf == null) {return null;}
for(int i=0; i<intf.getEndpointCount(); i++) {
UsbEndpoint ep = mUsbAccess.endpoint(devNum, intfNum, i);
if(ep==null) return null;
if(ep.getDirection() == usbDir) {
return ep;
}
}
return null;
}
示例12: getDeviceInfo
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
public String getDeviceInfo(UsbDevice device) {
if (device == null)
return "No device found.";
StringBuilder sb = new StringBuilder();
sb.append("Model: " + device.getDeviceName() + "\n");
sb.append("ID: " + device.getDeviceId() + " (0x" + Integer.toHexString(device.getDeviceId()) + ")" + "\n");
sb.append("Class: " + device.getDeviceClass() + "\n");
sb.append("Subclass: " + device.getDeviceSubclass() + "\n");
sb.append("Protocol: " + device.getDeviceProtocol() + "\n");
sb.append("Vendor ID " + device.getVendorId() + " (0x" + Integer.toHexString(device.getVendorId()) + ")" + "\n");
sb.append("Product ID: " + device.getProductId() + " (0x" + Integer.toHexString(device.getProductId()) + ")" + "\n");
sb.append("Device Ver: 0x" + Integer.toHexString(mDeviceVersion) + "\n");
sb.append("Interface count: " + device.getInterfaceCount() + "\n");
for (int i = 0; i < device.getInterfaceCount(); i++) {
UsbInterface usbInterface = device.getInterface(i);
sb.append("Interface: " + usbInterface.toString() + "\n");
sb.append("Endpoint Count: " + usbInterface.getEndpointCount() + "\n");
for (int j = 0; j < usbInterface.getEndpointCount(); j++) {
UsbEndpoint ep = usbInterface.getEndpoint(j);
sb.append("Endpoint: " + ep.toString() + "\n");
}
}
return sb.toString();
}
示例13: open
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
public static BTChipTransport open(UsbManager manager, UsbDevice device) {
// Must only be called once permission is granted (see http://developer.android.com/reference/android/hardware/usb/UsbManager.html)
// Important if enumerating, rather than being awaken by the intent notification
UsbInterface dongleInterface = device.getInterface(0);
UsbEndpoint in = null;
UsbEndpoint out = null;
boolean ledger;
for (int i=0; i<dongleInterface.getEndpointCount(); i++) {
UsbEndpoint tmpEndpoint = dongleInterface.getEndpoint(i);
if (tmpEndpoint.getDirection() == UsbConstants.USB_DIR_IN) {
in = tmpEndpoint;
}
else {
out = tmpEndpoint;
}
}
UsbDeviceConnection connection = manager.openDevice(device);
connection.claimInterface(dongleInterface, true);
ledger = ((device.getProductId() == PID_HID_LEDGER) || (device.getProductId() == PID_HID_LEDGER_PROTON)
|| (device.getProductId() == PID_NANOS) || (device.getProductId() == PID_BLUE));
if (device.getProductId() == PID_WINUSB) {
return new BTChipTransportAndroidWinUSB(connection, dongleInterface, in, out, TIMEOUT);
}
else {
return new BTChipTransportAndroidHID(connection, dongleInterface, in, out, TIMEOUT, ledger);
}
}
示例14: open
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
@Override
public void open() throws IOException {
boolean opened = false;
try {
for (int i = 0; i < mDevice.getInterfaceCount(); i++) {
UsbInterface usbIface = mDevice.getInterface(i);
if (mConnection.claimInterface(usbIface, true)) {
Log.d(TAG, "claimInterface " + i + " SUCCESS");
} else {
Log.d(TAG, "claimInterface " + i + " FAIL");
}
}
UsbInterface dataIface = mDevice.getInterface(mDevice.getInterfaceCount() - 1);
for (int i = 0; i < dataIface.getEndpointCount(); i++) {
UsbEndpoint ep = dataIface.getEndpoint(i);
if (ep.getType() == UsbConstants.USB_ENDPOINT_XFER_BULK) {
if (ep.getDirection() == UsbConstants.USB_DIR_IN) {
mReadEndpoint = ep;
} else {
mWriteEndpoint = ep;
}
}
}
setConfigSingle(SILABSER_IFC_ENABLE_REQUEST_CODE, UART_ENABLE);
setConfigSingle(SILABSER_SET_MHS_REQUEST_CODE, MCR_ALL | CONTROL_WRITE_DTR | CONTROL_WRITE_RTS);
setConfigSingle(SILABSER_SET_BAUDDIV_REQUEST_CODE, BAUD_RATE_GEN_FREQ / DEFAULT_BAUD_RATE);
// setParameters(DEFAULT_BAUD_RATE, DEFAULT_DATA_BITS, DEFAULT_STOP_BITS, DEFAULT_PARITY);
opened = true;
} finally {
if (!opened) {
close();
}
}
}
示例15: getUsbDevice
import android.hardware.usb.UsbInterface; //導入方法依賴的package包/類
public void getUsbDevice() {
//Log.d("findingDevices", " - wubbahed");
HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
while (deviceIterator.hasNext()) {
mDevice = deviceIterator.next();
// your code
Log.d("deviceName", mDevice.getDeviceName() + " - wubbahed");
Log.d("deviceId", mDevice.getDeviceId() + " - wubbahed");
Log.d("deviceInterfaceCount", mDevice.getInterfaceCount()
+ " - wubbahed");
Log.d("deviceClass", mDevice.getDeviceClass() + " - wubbahed");
Log
.d("deviceProductId", mDevice.getProductId()
+ " - wubbahed");
Log.d("deviceVendorId", mDevice.getVendorId() + " - wubbahed");
UsbInterface iFace = mDevice.getInterface(0);
Log.d("interfaceToString", iFace.toString() + " - wubbahed");
int endpointCount = iFace.getEndpointCount();
for (int i = 0; i < endpointCount; i++) {
mEndpoint = iFace.getEndpoint(i);
Log.d("endpoint", mEndpoint.toString() + " - wubbahed");
Log.d("endpointDirection", mEndpoint.getDirection()
+ " - wubbahed");
Log.d("endpointType", mEndpoint.getType() + " - wubbahed");
}
mConnection = mUsbManager.openDevice(mDevice);
mConnection.claimInterface(iFace, true);
}
}