Connecting to external USB device

prokli

Active Member
Licensed User
Longtime User
Hello everybody!
I have some problems connecting a USB device to my Asus Transformer tablet (Android 3.1).
I want to read out the data of a Pulsoximeter (medical device measuring the heart rate and blood oxygen) via USB interface. The data is stored to the Pulsoximeter internal Flash memory which I can read by sending simple byte sequences.
I am using the USB library V.093 on Android platform 15. Software is mainly based on Erel's USB example. I also know that my tablet supports USB host mode. Using the code shown next, it seems that the device can be successfully initialized:
For a = 0 To ud.InterfaceCount - 1
Dim inter As UsbInterface
inter = ud.GetInterface(a)
If inter.InterfaceClass = 255 AND inter.InterfaceSubclass = 0 Then
device = ud
interface = inter
'Find correct endpoints
For b = 0 To interface.EndpointCount - 1
Dim endpoint As UsbEndpoint
endpoint = interface.GetEndpoint(b)
If endpoint.Type = manager.USB_ENDPOINT_XFER_BULK Then
If endpoint.Direction = manager.USB_DIR_IN Then
inEndpoint = endpoint
Else If endpoint.Direction = manager.USB_DIR_OUT Then
outEndpoint = endpoint
End If
End If
Next
End If
Next

If the device is ready for reading, it first issues a 5 byte sequence: 0x53, 0x4e, 0x50, 0x31, 0x30
To get the first data set, I have to transmit: 0x55, 0xAA, 0x60, 0x00, 0x00, 0x00, 0x60
Unfortunately I neither receive the first sequence nor I get any response when sending the second sequence. I tried also several hardware scenarios:
Medical device directly connected to tablet PC (no success)
Medical device connected via unpowered USB hub (no success)
Medical device connected via powered USB hub (no success)
Here is the information which I got from my USB Sniffer running on my Windows PC:
Device = Silicon Labs CP21x USB to UART Bridge (COM3)

Connection Information
Port: 3
Speed: Full Speed
Device address: 5
Open pipes: 2
Connection status: Device connected

Device Descriptor
USB version: 1.10
Device class: 0x0 - (Defined at Interface level)
Device subclass: 0x0 - Unknown
Device protocol: 0x0 - Unknown
Control pipe max size: 64 bytes
Vendor ID: 0x10c4 (Cygnal Integrated Products, Inc.)
Product ID: 0xea60 (CP210x Composite Device)
Product version: 1.0
Manufacturer: Not specified
Product: Not specified
Serial Number: Not specified

But if I remove the USB connector from the medical device (while the App is still running on the table) I get some data. How funny is this?!?!
Has anybody a good idea??
Does the USB library support such devices at all??
Thanks
Harald
 
Last edited:

agraham

Expert
Licensed User
Longtime User
It looks like the Pulsoximeter was designed as an RS232 interface device and adapted for USB by using this chip.

CP21xx USB to UART Bridge

You would need to know how to drive this chip by using USB commands but the information on how to do this may not be publicly available as the chip manufacturers often provide the driver software pre-compiled as they regard such details as proprietary information.

Also the Android USB implementation sucks big time. See the travails I suffered trying to do something similar with the PL203 .
 
Upvote 0

prokli

Active Member
Licensed User
Longtime User
Thanks for giving this great example to me. It seems that I can use this code even for my pulsoximeter which uses a similar chip from FDTI (USB-to-UART).
I will give feedback to the b4a community when I succeeded in modify your code.
Regards, Harald
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
FTDI also don't give out the necessary details to directly drive their chip using the USB commands, it is different to the PL203. If you can find those details I would like to see them but I haven''t been able to locate them.

Erel and I have actually tried to talk to an FTDI chip as they do however have an experimental Android driver here, details here FTDI Android and here http://www.ftdichip.com/FTDrivers.htm. I've tried to get this running on my Xoom but hit a brick wall as the driver throws a segment fault when loading so I cannot get any further.
 
Upvote 0

mterveen

Member
Licensed User
Longtime User
ftdi usb

any luck getting the ftdi drivers to work? can you write a b4a library wrapper? i use the ftdi products alot with windows apps so it would be FANTASTIC to get it to work under android OS.
 
Upvote 0

Toley

Active Member
Licensed User
Longtime User
If you can find those details I would like to see them but I haven''t been able to locate them.

Hello agraham, a recent update of USB Serial Monitor can communicate with an FTDI device. I don't know if you can look at the code and find what you are looking for or maybe get in touch with the author, but adding the possibility to talk with an FTDI chip would be a great addon.

https://github.com/ksksue/Android-USB-Serial-Monitor-Lite

I have personnally test this program and it works great.
 
Upvote 0
Top