Android Question How to obtain Serial Number from USB device

littlerunningdeer

Member
Licensed User
Am developing interface to MCP2210 USB HID device. The USB library wrapper (v0.98) appears to be missing a way to get the USB device Serial Number. Are there other methods by which to obtain the USB getSerialNumber from android.hardware.usb.UsbDevice? Am just getting started. The USBdetails program (v1.1) was a very useful starting point. Is there a way to modify the Library and recompile it?
 

littlerunningdeer

Member
Licensed User
While the USBDetails program was very useful in getting started, a bug in it caused me to discount the value of the raw descriptors.
So now the applicable code to obtain the serial number is:

Dim ud As UsbDevice
ud = devices(device)
Dim connection As UsbDeviceConnection
connection = Connect(0, 0, interfaces)
Dim Obj1 As Reflector
Obj1.Target = connection
Obj1.Target = Obj1.GetField("connection")

Dim buffer(128) As Byte ' maximum packet size
Dim datalen, idx As Int
rawdescs = Obj1.RunMethod("getRawDescriptors")idx = rawdescs(16)
datalen = connection.ControlTransfer(128, 6, 0x0300 + idx, 0, buffer, buffer.Length, 100)
'buffer(0..datalen) contains string descriptor
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…