本文整理汇总了Java中android.hardware.usb.UsbConstants.USB_CLASS_CDC_DATA属性的典型用法代码示例。如果您正苦于以下问题:Java UsbConstants.USB_CLASS_CDC_DATA属性的具体用法?Java UsbConstants.USB_CLASS_CDC_DATA怎么用?Java UsbConstants.USB_CLASS_CDC_DATA使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.hardware.usb.UsbConstants
的用法示例。
在下文中一共展示了UsbConstants.USB_CLASS_CDC_DATA属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isCdcDevice
public static boolean isCdcDevice(UsbDevice device)
{
int iIndex = device.getInterfaceCount();
for(int i=0;i<=iIndex-1;i++)
{
UsbInterface iface = device.getInterface(i);
if(iface.getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA)
return true;
}
return false;
}
示例2: nameForClass
private static String nameForClass(UsbDevice usbDevice) {
int classType = usbDevice.getDeviceClass();
switch (classType) {
case UsbConstants.USB_CLASS_AUDIO:
return "Audio";
case UsbConstants.USB_CLASS_CDC_DATA:
return "CDC Control";
case UsbConstants.USB_CLASS_COMM:
return "Communications";
case UsbConstants.USB_CLASS_CONTENT_SEC:
return "Content Security";
case UsbConstants.USB_CLASS_CSCID:
return "Content Smart Card";
case UsbConstants.USB_CLASS_HID:
return "Human Interface Device";
case UsbConstants.USB_CLASS_HUB:
return "Hub";
case UsbConstants.USB_CLASS_MASS_STORAGE:
return "Mass Storage";
case UsbConstants.USB_CLASS_MISC:
return "Wireless Miscellaneous";
case UsbConstants.USB_CLASS_PHYSICA:
return "Physical";
case UsbConstants.USB_CLASS_PRINTER:
return "Printer";
case UsbConstants.USB_CLASS_STILL_IMAGE:
return "Still Image";
case UsbConstants.USB_CLASS_VENDOR_SPEC:
return String.format("Vendor Specific 0x%02x", classType);
case UsbConstants.USB_CLASS_VIDEO:
return "Video";
case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER:
return "Wireless Controller";
default:
return "";
}
}
示例3: nameForClass
public static String nameForClass(int classType) {
switch (classType) {
case UsbConstants.USB_CLASS_APP_SPEC:
return String.format("Application Specific 0x%02x", classType);
case UsbConstants.USB_CLASS_AUDIO:
return "Audio";
case UsbConstants.USB_CLASS_CDC_DATA:
return "CDC Control";
case UsbConstants.USB_CLASS_COMM:
return "Communications";
case UsbConstants.USB_CLASS_CONTENT_SEC:
return "Content Security";
case UsbConstants.USB_CLASS_CSCID:
return "Content Smart Card";
case UsbConstants.USB_CLASS_HID:
return "Human Interface Device";
case UsbConstants.USB_CLASS_HUB:
return "Hub";
case UsbConstants.USB_CLASS_MASS_STORAGE:
return "Mass Storage";
case UsbConstants.USB_CLASS_MISC:
return "Wireless Miscellaneous";
case UsbConstants.USB_CLASS_PER_INTERFACE:
return "(Defined Per Interface)";
case UsbConstants.USB_CLASS_PHYSICA:
return "Physical";
case UsbConstants.USB_CLASS_PRINTER:
return "Printer";
case UsbConstants.USB_CLASS_STILL_IMAGE:
return "Still Image";
case UsbConstants.USB_CLASS_VENDOR_SPEC:
return String.format("Vendor Specific 0x%02x", classType);
case UsbConstants.USB_CLASS_VIDEO:
return "Video";
case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER:
return "Wireless Controller";
default:
return String.format("0x%02x", classType);
}
}
示例4: findFirstCDC
private static int findFirstCDC(UsbDevice device)
{
int interfaceCount = device.getInterfaceCount();
for (int iIndex = 0; iIndex < interfaceCount; ++iIndex)
{
if (device.getInterface(iIndex).getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA)
{
return iIndex;
}
}
Log.i(CLASS_ID, "There is no CDC class interface");
return -1;
}
示例5: open
/**
* Open channel-th device with VID and PID
*
* @param ids vid and pid
* @param ch channel
* @return true : open successful, false : open fail
*/
public boolean open(UsbVidPid ids, boolean isCdcAcm, int ch) {
if (ids == null) return false;
int devNum = 0;
int chNum = 0;
for (UsbDevice usbdev : mUsbAccess.manager().getDeviceList().values()) {
if (usbdev.getVendorId() == ids.getVid()) {
if (ids.getPid() == 0 || ids.getPid() == usbdev.getProductId()) {
for (int intfNum = 0; intfNum < usbdev.getInterfaceCount(); intfNum++) {
if ((isCdcAcm && (usbdev.getInterface(intfNum).getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA))
|| !isCdcAcm) {
if (ch == chNum) {
if (!mUsbAccess.deviceIsConnected(devNum)) {
if (mUsbAccess.openDevice(devNum, intfNum, ch)) {
if (DEBUG_SHOW) {
Log.d(TAG, "Find VID:" + Integer.toHexString(usbdev.getVendorId()) + ", PID:" + Integer.toHexString(usbdev.getProductId()) + ", DevNum:" + devNum + ", IntfNum:" + intfNum);
}
mUsbConnectionEp.put(ch, new UsbCdcConnectionEp(mUsbAccess.connection(ch), getEndpoint(devNum, intfNum, UsbConstants.USB_DIR_IN), getEndpoint(devNum, intfNum, UsbConstants.USB_DIR_OUT)));
mCdcAcmInterfaceNum = intfNum - 1;
if (mCdcAcmInterfaceNum < 0)
mCdcAcmInterfaceNum = 0;
return true;
}
}
chNum++;
} // end of if
}// end of if
} // end of for
} // end of if
} // end of if
devNum++;
} //end of for
if (DEBUG_SHOW) {
Log.d(TAG, "Cannot find VID:" + ids.getVid() + ", PID:" + ids.getPid());
}
return false;
}
示例6: open
/**
* Open channel-th device with VID and PID
* @param ids vid and pid
* @param ch channel
* @return true : open successful, false : open fail
*/
public boolean open(UsbVidPid ids, boolean isCdcAcm, int ch) {
Log.e("Physical", "Opening CDC connection - isCdc: " + isCdcAcm);
if(ids == null) return false;
int devNum = 0;
int chNum = 0;
for(UsbDevice usbdev : mUsbAccess.manager().getDeviceList().values()) {
if(usbdev.getVendorId() == ids.getVid()) {
if(ids.getPid() == 0 || ids.getPid() == usbdev.getProductId()) {
for(int intfNum=0; intfNum < usbdev.getInterfaceCount(); intfNum++) {
if( (isCdcAcm && (usbdev.getInterface(intfNum).getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA))
|| !isCdcAcm) {
if(ch == chNum) {
if(!mUsbAccess.deviceIsConnected(devNum)) {
if(mUsbAccess.openDevice(devNum,intfNum,ch)) {
if(DEBUG_SHOW){ Log.d(TAG, "Find VID:"+Integer.toHexString(usbdev.getVendorId())+", PID:"+Integer.toHexString(usbdev.getProductId())+", DevNum:"+devNum+", IntfNum:"+intfNum); }
mUsbConnectionEp.put(ch,new UsbCdcConnectionEp(mUsbAccess.connection(ch), getEndpoint(devNum, intfNum, UsbConstants.USB_DIR_IN), getEndpoint(devNum, intfNum, UsbConstants.USB_DIR_OUT)));
mCdcAcmInterfaceNum = intfNum;
return true;
}
}
chNum++;
} // end of if
}// end of if
} // end of for
} // end of if
} // end of if
devNum++;
} //end of for
if(DEBUG_SHOW){ Log.d(TAG, "Cannot find VID:"+ids.getVid()+", PID:"+ids.getPid()); }
return false;
}
示例7: getClassName
private String getClassName(int deviceClass) {
switch (deviceClass) {
case UsbConstants.USB_CLASS_AUDIO:
return this.getString(R.string.class_audio);
case UsbConstants.USB_CLASS_CDC_DATA:
return this.getString(R.string.class_cdc_data);
case UsbConstants.USB_CLASS_COMM:
return this.getString(R.string.class_comm);
case UsbConstants.USB_CLASS_CONTENT_SEC:
return this.getString(R.string.class_content_sec);
case UsbConstants.USB_CLASS_HID:
return this.getString(R.string.class_hid);
case UsbConstants.USB_CLASS_HUB:
return this.getString(R.string.class_hub);
case UsbConstants.USB_CLASS_MASS_STORAGE:
return this.getString(R.string.class_mass_storage);
case UsbConstants.USB_CLASS_MISC:
return this.getString(R.string.class_misc);
case UsbConstants.USB_CLASS_PHYSICA:
return this.getString(R.string.class_physica);
case UsbConstants.USB_CLASS_PRINTER:
return this.getString(R.string.class_printer);
case UsbConstants.USB_CLASS_STILL_IMAGE:
return this.getString(R.string.class_still_image);
case UsbConstants.USB_CLASS_VIDEO:
return this.getString(R.string.class_video);
case UsbConstants.USB_CLASS_WIRELESS_CONTROLLER:
return this.getString(R.string.class_wireless_controller);
default:
return this.getString(R.string.class_unknown);
}
}
示例8: open
/**
* Open channel-th device with VID and PID
* @param ids vid and pid
* @param ch channel
* @return true : open successful, false : open fail
*/
public boolean open(UsbVidPid ids, boolean isCdcAcm, int ch) {
if(ids == null) return false;
int devNum = 0;
int chNum = 0;
for(UsbDevice usbdev : mUsbAccess.manager().getDeviceList().values()) {
if(usbdev.getVendorId() == ids.getVid()) {
if(ids.getPid() == 0 || ids.getPid() == usbdev.getProductId()) {
for(int intfNum=0; intfNum < usbdev.getInterfaceCount(); intfNum++) {
if( (isCdcAcm && (usbdev.getInterface(intfNum).getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA))
|| !isCdcAcm) {
if(ch == chNum) {
if(!mUsbAccess.deviceIsConnected(devNum)) {
if(mUsbAccess.openDevice(devNum,intfNum,ch)) {
if(DEBUG_SHOW){ Log.d(TAG, "Find VID:"+Integer.toHexString(usbdev.getVendorId())+", PID:"+Integer.toHexString(usbdev.getProductId())+", DevNum:"+devNum+", IntfNum:"+intfNum); }
mUsbConnectionEp.put(ch,new UsbCdcConnectionEp(mUsbAccess.connection(ch), getEndpoint(devNum, intfNum, UsbConstants.USB_DIR_IN), getEndpoint(devNum, intfNum, UsbConstants.USB_DIR_OUT)));
mCdcAcmInterfaceNum = intfNum;
return true;
}
}
chNum++;
} // end of if
}// end of if
} // end of for
} // end of if
} // end of if
devNum++;
} //end of for
if(DEBUG_SHOW){ Log.d(TAG, "Cannot find VID:"+ids.getVid()+", PID:"+ids.getPid()); }
return false;
}
示例9: getUsbInterfaces
private boolean getUsbInterfaces(UsbDevice device) {
UsbInterface[] intf = new UsbInterface[FTDI_MAX_INTERFACE_NUM];
for (UsbId usbids : IDS) {
// TODO: Refactor it for CDC
if (usbids.mVid == 0 && usbids.mPid == 0
&& device.getDeviceClass() == UsbConstants.USB_CLASS_COMM) {
for (int i = 0; i < device.getInterfaceCount(); ++i) {
if (device.getInterface(i).getInterfaceClass() == UsbConstants.USB_CLASS_CDC_DATA) {
intf[0] = device.getInterface(i);
}
}
if (intf[0] == null) {
return false;
}
} else {
intf = findUSBInterfaceByVIDPID(device, usbids.mVid,
usbids.mPid);
}
if (intf[0] != null) {
for (int i = 0; i < usbids.mNumOfChannels; ++i) {
Log.d(TAG, "Found USB interface " + intf[i]);
setUSBInterface(device, intf[i], i);
mSelectedDeviceInfo = usbids;
}
return true;
}
}
return false;
}