How to Detect UU Cable Connnected Programmatically: Difference between revisions

From wizarPOS
No edit summary
(Replaced content with "{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/usb-serial-port/detect-uu-cable-connnected}}")
Tag: Replaced
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
== Overview: ==
{{Migrating|https://smartpossdk.gitbook.io/cloudpossdk/faq/usb-serial-port/detect-uu-cable-connnected}}
This guide provides instructions and a code snippet for developers on how to programmatically detect the connection of a UU cable. This functionality is essential for applications that need to respond to hardware changes dynamically.
== Implementation Steps: ==
# '''Understand the Context:'''
#* The detection of a UU cable connection is typically handled within the application's code, allowing the app to perform specific actions when the cable is connected or disconnected.
# '''Code Snippet:'''
#* Below is an example snippet that demonstrates how to detect a UU cable connection within your application.
<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, 9123, 9155,  // 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.getProductId() == 9123||device.getProductId() == 9155)
        && device.getProductName().toLowerCase().contains("serial")) {
        // UU Cable connected. TODO
    }
}
</syntaxhighlight >
This code snippet serves as a starting point. The exact implementation will depend on the specific requirements and the environment in which the application is running.

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!