Usb device attached

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
fagci
Posts: 80
Joined: 03 Feb 2017 13:06
Location: Novosibirsk, RU
Contact:

Usb device attached

Post by fagci » 03 Jun 2017 19:01

Hello.
I use General broadcast trigger to watch for usb device attaching.

In debug log I see:

Code: Select all

04.06.2017 01:21:12.560 Trigger 'USB_DEVICE_ATTACHED' intent bundle UsbDevice device=UsbDevice[mName=/dev/bus/usb/001/029,mVendorId=3034,mProductId=10296,mClass=0,mSubclass=0,mProtocol=0,mManufacturerName=Realtek,mProductName=RTL2838UHIDIR,mVersion=2.0,mSerialNumber=00000001,mConfigurations=[ UsbConfiguration[mId=1,mName=USB2.0-Bulk&Iso,mAttributes=128,mMaxPower=250,mInterfaces=[ UsbInterface[mId=0,mAlternateSetting=0,mName=Bulk-In, Interface,mClass=255,mSubclass=255,mProtocol=255,mEndpoints=[ UsbEndpoint[mAddress=129,mAttributes=2,mMaxPacketSize=512,mInterval=0]] UsbInterface[mId=1,mAlternateSetting=0,mName=Bulk-In, Interface,mClass=255,mSubclass=255,mProtocol=255,mEndpoints=[]]] 
and use this script to get properties:

Code: Select all

b = getBundle("device");
v = getString(b,"mProductName");
but that throws me exception about variable "b", it is not bundle. Whats wrong?
All systems nominal.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: Usb device attached

Post by Martin » 03 Jun 2017 19:53

Hi,

UsbDevice is indeed not a bundle. See this page for a description of the class:
https://developer.android.com/reference ... evice.html

There's probably no way to access this extra, maybe with getParcelableAsString but that might not be very useful to work with the UsbDevice. I could add a new function to get Parcelables as is then you could use the Java features of action Script to use it.

Regards,
Martin

User avatar
fagci
Posts: 80
Joined: 03 Feb 2017 13:06
Location: Novosibirsk, RU
Contact:

Re: Usb device attached

Post by fagci » 04 Jun 2017 05:34

Thank you, Martin. getParcelableAsString() works pretty well for me.
All systems nominal.

Post Reply