Patrick
Patrick

Reputation: 1

Android reading data via USB & UART

I am student and currently working on a project for my university. I am trying to write an app which is capable of reading date by using the TUSB3410(http://www.ti.com/product/tusb3410) and its USB to connect it with the C2500(http://www.ti.com/product/cc2500) connected via UART. Something like USB to serial.

I can get information off the TUSB3140 like its vendor id or its endpoint so I can use the normal USB API. But it is rather tricky to receive the information of the cc2500. I don't know which methods I should use or which parameter are correct. So maybe you have an idea how the methods like controlTransfer() etc. should look like.

I hope you can help me with this problem!

Upvotes: 0

Views: 8996

Answers (2)

James
James

Reputation: 1

I think apart from the FT311D which is using the AOA protocol, you may also consider to use FT231X, via FT231X, you can use the APK of android hyperterminal which you can easily find in google search/ google play. This is using by OTG method. You may also have a look.

Upvotes: 0

devunwired
devunwired

Reputation: 63293

I'm afraid the answer isn't quite as simple as all that.

According to the linked datasheet and associated documentation, the TUSB3410 is not a fixed function device. It's basically a USB device on one side, a UART on the other side, and an MCU applications processor in the middle. In order for that chip to do anything useful, it has to have a firmware application loaded into it to govern how the data moves from one side to the other. So you get to define in the firmware how the data moves through the USB (interrupt transfers, bulk transfers, etc.) and that will govern how an Android application interacts with it.

Also, the chip does not seem to support having its firmware burned in, it always loads the firmware externally from I2C EEPROM or from the USB Host. If your device setup does not already have the EEPROM on it, you will likely have a difficult time because the Android USB APIs don't really give your application access to the device during the enumeration process, which is when the firmware would need to be sent if downloaded from the Host. It also would require you to detect your device twice (once with the standard bootcode VID/PID, and once again after the firmware file takes over and the device reconnects to the bus).

If you are just looking for a simple embedded implementation to get UART, SPI, etc. data into an Android application, you are probably better off with something like the FTDI FT311, which implements the Open Accessory protocol and comes with library code to get you started on both sides of the equation: http://www.ftdichip.com/Products/ICs/FT311D.html

EDIT: From your comment

So if your device conforms to the CDC USB Device Class, then there are basically three points of interest:

  • Every device has an "endpoint 0" for configuration, and this is accessed in the Android APIs using the controlTransfer() method. CDC devices use this endpoint for changing items like baud rate, stop bits, etc.
  • CDC Devices like a VCP have two interfaces, one for communications and one for data. The data interface (usually enumerated second) has two bulk endpoints (one in and one out) where the serial data is usually transferred. You can transfer the data back and forth on those endpoints with the bulkTransfer() method, or using an asynchronous UsbRequest.

As a starting point, perhaps take a look at the source of this open source project, which implements CDC basics using the host APIs. You should be able to get a good idea of how to roll your own driver from there (specifically the CdcAcmSerialDriver):

http://code.google.com/p/usb-serial-for-android/

Upvotes: 4

Related Questions