0

I'm writing a utility for an Android tablet that communicates with custom hardware over USB using a bulk endpoint. My development tablet is a rooted Nexus 10 (v4.4.3). Custom hardware is running Linux 3.2 using gadgetfs that appears to work fine for Linux<->Linux USB communication.

I am able to find the USB Device, verify the VID/PID, get permission, open the connection, get the interface, claim the interface, and get the endpoints. But when I attempt to send data using the following code, the application crashes:

int dataWritten = connection.bulkTransfer(endpoint, dataArray, dataArray.length, USB_TIMEOUT);

where connection is UsbDeviceConnection, endpoint is a UsbEndpoint (out), dataArray is byte[], and USB_TIMEOUT is set to 1000. Commenting out this code removes the crash.

I am unable to find out why the crash occurs since in order to attach my custom hardware to USB to test, I have to disconnect my laptop from USB debugging with the Eclipse Android Development Tools. When I reconnect to the ADT, all logging and stack trace dumps appear to have been lost. At this point I'm at a loss on how to proceed.

So my question is: How can I determine the cause of the crash if I have to disconnect my debugger in order to test it?

Thanks.

Dan Eisenhut
  • 141
  • 1
  • 2
  • 8
  • Run adb from the commandline rather than from eclipse upon reconnect, and you should recover at least a few minutes worth of logs. Or else use normall ADB-over-USB (or any of the various root-based methods) to start up ADB-over-TCP (wifi) and use that during your USB host tests. Or use/create a "root" logcat recording app. – Chris Stratton Jun 11 '14 at 19:38
  • @ChrisStratton Thanks, I'll get ADB-over-TCP working with Wifi. Following instructions here: http://stackoverflow.com/questions/2604727/how-can-i-connect-to-android-with-adb-over-tcp Though it looks like when I recently updated to v4.4.3 I lost my root so I'm now re-rooting. – Dan Eisenhut Jun 12 '14 at 14:57
  • You don't actually need root to get ADB-over-TCP, you merely need it to do so *without* using ADB-over-USB to activate it. – Chris Stratton Jun 12 '14 at 14:58
  • @ChrisStratton I tried before re-rooting and I just couldn't connect from Eclipse. I could switch using "adb tcpip 5555" and "adb connect " and it would show up in Eclipse, but I just couldn't connect. I went ahead and re-rooted my device, entered the setprop command, and restarted the adbd service from a local terminal and then everything worked just fine. I am now debugging my app over Wifi. Now to solve my crash issue... Thanks for your help. – Dan Eisenhut Jun 12 '14 at 16:16
  • My problem has been solved. It was really easy to figure once I had a working debugger, it pointed me right to the problem. The problem was an idiot developer (me) was using an object that wasn't initialized in the USB receive thread (NullPointerException). Apparently the transfer was working and it was crashing on the reception of the reply. Go figure. :) – Dan Eisenhut Jun 12 '14 at 22:42

0 Answers0