I am trying to write an Android app using the USB host mode on a Motorola Xoom with Android version 3.1 (build HMJ37) using the new Android host USB APIs to communicate over USB with a device that uses a Silicon Labs CP2102 Virtual COM Port Interface (USB to serial bridge). I have been using the AdbTest application example from the Android developer's site as a guideline.
I have been having trouble reading characters sent in on the UART side of the CP2102. Single byte bulk transfers work fine, but not if I ask for more than 1 byte of data. I know the data is there because I can send a GET_COMM_STATUS command using USBDeviceConnection.controlTransfer() and see that there are characters in the InQueue buffer on the CP2102. However, when I request more than one byte from the In Endpoint either by using USBRequest.queue() (asynchronous) or the SBDeviceConnection.bulkTransfer() (synchronous) functions, the buffer that is returned contains invalid characters.
Here's what does work:
- intent fires upon insertion and deletion of USB device
- application starts, finds USB device, connections, interfaces, endpoints, and claims interface
- can configure the CP2102 by sending USBDeviceConnection.controlTransfer() commands
- Characters are successfully transmitted out the UART side of the CP2102 by sending data to the Out Endpoint using USBRequest.queue().
- Single characters (separated by time delays) coming in the UART side of the CP2102 are successfully read from the bulk transfer In Endpoint using either the synchronous or asynchronous commands.
Problems arise when I try to send characters in a streak. However, I am only sending data at 9600 baud on the UART side and am not sending so many characters that I fill up the buffer on the CP2102.
I am using the Xoom as the power source for the device. I get the same behavior on two different XOOMs. I'm using the Motorola Camera Connection Kit for MOTOROLA XOOM as my USB host cable.
Can anyone give me guidelines on how to make this work? Or is the Honeycomb 3.1 USB host API on the XOOM not yet really stable?