How to Detect UU Cable Connnected Programmatically: Difference between revisions

From wizarPOS
(Created page with "Snippet code: <syntaxhighlight lang="java"> /** * Obtain whether the UU cable is connected to the terminal. * 1,getSystemService(Context.USB_SERVICE); * 2,getDeviceList();...")
 
(Replaced content with "{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/usb-serial-port/detect-uu-cable-connnected}}")
Tag: Replaced
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Snippet code:
{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/usb-serial-port/detect-uu-cable-connnected}}
<syntaxhighlight lang="java">
/**
* Obtain whether the UU cable is connected to the terminal.
* 1,getSystemService(Context.USB_SERVICE);
* 2,getDeviceList();
* 3,finding UU cable features;
*/
/**
*  UU Cable UsbDevice info :
* [mName=/dev/bus/usb/001/002,
* mVendorId=1659,mProductId=8963,  // UU Cable : vid,pid
* mClass=0,mSubclass=0,mProtocol=0,
* mManufacturerName=Prolific Technology Inc. ,
* mProductName=USB-Serial Controller D,  // UU Cable : productName
* mVersion=1.16,mSerialNumber=null,
* mConfigurations=[UsbConfiguration[mId=1,mName=null,mAttributes=128,mMaxPower=50,mInterfaces=[
* UsbInterface[mId=0,mAlternateSetting=0,mName=null,mClass=255,mSubclass=0,mProtocol=0,mEndpoints=[
* UsbEndpoint[mAddress=129,mAttributes=3,mMaxPacketSize=10,mInterval=1]
* UsbEndpoint[mAddress=2,mAttributes=2,mMaxPacketSize=64,mInterval=0]
* UsbEndpoint[mAddress=131,mAttributes=2,mMaxPacketSize=64,mInterval=0]]]]
*/
UsbManager usbManager = (UsbManager) getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> deviceList = usbManager.getDeviceList();
for (UsbDevice device : deviceList.values()) {
    Log.d("getDeviceList", "device.toString:" + device.toString());
    if (device.getVendorId() == 1659
        && device.getProductId() == 8963
        && device.getProductName().startsWith("USB-Serial Controller D")) {
        // UU Cable connected. TODO
    }
}
</syntaxhighlight >

Latest revision as of 08:27, 7 April 2024

Please visit new link of same subject:

https://smartpossdk.gitbook.io/cloudpossdk/faq/usb-serial-port/detect-uu-cable-connnected

We're making a move! Our site's content is migrating to a new URL, to provide you with an enhanced browsing experience. Please update your bookmarks accordingly. Thank you for your continuous support!