2

I am connecting a USB device I built (dsPIC33E powered) to a generic 7" A13-MID android.

I am using ADB over TCPIP with LogCat running.

When I plug in my device I get this in LogCat:

I/USB3G (90): event { 'add', '/devices/platform/sw_hcd_host0/usb1/1-1', 'usb', '', 189, 7 }
I/USB3G (90): path : '/sys/devices/platform/sw_hcd_host0/usb1/1-1'
I/USB3G (90): VID :size 5,vid_path '/sys/devices/platform/sw_hcd_host0/usb1/1-   1/idVendor',VID  '04d8'.
I/USB3G (90): PID :size 5,Pid_path '/sys/devices/platform/sw_hcd_host0/usb1/1-1/idProduct',PID  '003f'.
I/USB3G (90): cmd=/system/etc/usb_modeswitch.sh /system/etc/usb_modeswitch.d/04d8_003f &,
I/USB3G (90): excute ret : 0,err:No such file or directory

I have MissileLauncher Demo running in debug mode ADT.

I can set a breakpoint in Fire and when I press Fire button, the code breaks there (so debugging IS working).

I have set Product-ID and Vendor-ID to the correct values in device_filter.xml.

I then set a breakpoint here:

UsbDevice device = (UsbDevice)intent.getParcelableExtra(UsbManager.EXTRA_DEVICE);
if (UsbManager.ACTION_USB_DEVICE_ATTACHED.equals(action)) {
    setDevice(device);
} else if (UsbManager.ACTION_USB_DEVICE_DETACHED.equals(action)) {
    if (mDevice != null && mDevice.equals(device)) {
        setDevice(null);
    }
}

When I step through the code after the break, the intent. line is executed but the following if statement is not entered and setDevice(device) is never called (neither is setDevice(null)).

I did expect setDevice(device) to be called. After all, I have the device plugged in, the android saw that I plugged it in (see LogCat above) and I have the device_filter.xml set correctly.

What am I missing?

Other info, an app I installed 'USB Device' sees the device but lists it under the Linux tab. I hope that is not bad news for me!

Thanks, Dale

I tried to enumerate the devices individually but no 'Yeah' (in fact there were no devices returned in HashMap):

HashMap<String, UsbDevice> deviceList = mUsbManager.getDeviceList();
Iterator<UsbDevice> deviceIterator = deviceList.values().iterator();
while(deviceIterator.hasNext()){
    UsbDevice device1 = deviceIterator.next();
    //your code
    if (device1.getVendorId()==1240) {
        savetofile("Yeah!");
    }
} 

Not sure if this is relevant or not but the android is rooted and it came that way.

KiloOne
  • 312
  • 1
  • 6
  • 20
  • what's in action ? did you check it ? – njzk2 Jan 16 '13 at 16:02
  • @njzk2 action "android.intent.action.MAIN" (id=830013334544) count 26 hashCode -1173447682 offset 0 value (id=830013334576) – KiloOne Jan 16 '13 at 16:18
  • that's why. you don't receive ACTION_USB_DEVICE_* – njzk2 Jan 16 '13 at 17:10
  • @njzk2 Sorry, I'm a newbie, what does that mean? Is there a way to resolve that? – KiloOne Jan 16 '13 at 17:43
  • how do you get to this code ? you are starting a service or something ? – njzk2 Jan 16 '13 at 18:24
  • @njzk2 Code is unmodified (except for PID and VID changes and I added savetofile()) Android sample app from 17. From the USB samples diectory call MissileLauncher. Don't understand the service question. – KiloOne Jan 16 '13 at 18:34
  • see my answer here :http://stackoverflow.com/questions/11242730/usb-device-attached-only-startsactivity-of-galaxy-s3-ics/29073989#29073989 Rooting is not needed. – Abhishek Chandel Mar 16 '15 at 10:36

1 Answers1

0

Turned out that I needed to use root privileges and make the changes I found in this answered question:

Android USB host and hidden devices

I was on the right track and now I am :) again. I am sure that someone else will find my quest to find this answer helpful.

BUT, only the HashMap enumeration method works, the intent filter method still returns action as android.intent.action.MAIN.

Thanks for input!

Dale

Community
  • 1
  • 1
KiloOne
  • 312
  • 1
  • 6
  • 20
  • yes, this worked like a charm (micromax A120 phone, kitkat 4.4.2). see the comment http://stackoverflow.com/a/11992683/979369. – mahesh Mar 25 '15 at 01:09