views:

456

answers:

2

Hello folks,

I have a really short question: Is it possible to communicate/use USB devices on Android OS? I assume it might be tablet device.

Lest say i want to connect some sort of USB card scanner to android tablet. Will it work? Do i need to write drivers by myself?

Thanks.

+1  A: 

First, you need a USB host port on your tablet. Except for On-the-Go (which is a special design that can be either host or device), it is not possible to connect two USB devices together. The incompatibility is electrical, no amount of software changes can make it work.

Ben Voigt
So, OS does not provide such functionality at all? Any ideas how to make that work?
Dan Sosedoff
Could a special "crossover cable" of sorts handle this? Or is it more complex than that?
Jaxidian
The electrical difference is really only where the pull up/pull down resistors on the data bus are located. If the host is to provide power to the device there is also additional circuitry required as there is a negotiation that occurs where the device requests a curtain amount of power. It is possible to design a normal USB circuit that can run as both host/device but there is special circuitry required as well as the ability to switch out the driver. In short the tablet would specifically have to have a host port and i don't think there is a mechanism in android for providing USB drivers
Mark
If you gained root access to the tablet and it has a host port, you could either write your own driver or there may be a linux driver for the device you want to use. android runs on a fairly stock linux kernel so most drivers should work with little or no modification.
Mark
@Jaxidian: It's more than just pinout. Your "crossover cable" would have to have two USB hosts, or a USB host and two-port hub, a processor to act as a proxy (which btw requires device-specific, or at least class-specific, firmware logic), and its own power supply. By this time your cross-over cable is approaching the size and complexity of a smartphone. Much better to pick a tablet that comes with a host-capable port on it.
Ben Voigt
@Mark: There's no *if* the host is to provide power to the device. Even self-powered devices check for the presence of `VBUS` and disconnect unless >4V is detected.
Ben Voigt
@Ben Voigt There is a large difference between "power" and "voltage" checking for +5V on a line and drawing power from that line are entirely different things. The USB spec requires that a device can freely draw up to 100mA per port and, after a negotiation protocol, request up to 500mA. This spec is not always followed, especially in embedded devices (and even some laptops), its not uncommon for a host to not be able to supply 100mA to the device but this doesn't mean that +5V isn't present on VBUS.
Mark
@Mark: All of which is totally irrelevant to the "could a device be used as a host" question. Your original comment suggested that supplying `VBUS` was only necessary if the other device is bus-powered, but in actuality every host MUST supply `VBUS` (with some current limitations, true) and devices NEVER do. If you connected two self-powered devices you still have a problem that `VBUS` is not supplied so neither device connects to the data lines. Devices simply do not have the circuitry to supply VBUS even absent concerns about load current. Hence "The incompatibility is electrical."
Ben Voigt
@Ben Voigt If you try to connect 2 device only products there would also be no pull downs on the data lines. All i said was "It is possible to design a normal USB circuit that can run as both host/device but there is special circuitry required as well as the ability to switch out the driver." which is accurate, and in fact, this is all USB OTG is from a hardware perspective which some android devices support, in spite of being advertised as device only, the Motorola Droid and HTC Hero are examples.
Mark
Right. You need (1) an OTG controller chip (2) the host support circuitry and (3) the host driver.
Ben Voigt
A: 

Yes, some phones can work as hosts, like the DROID. Do a Google search for connecting a USB keyboard to an android phone, such as here: http://www.tombom.co.uk/blog/?p=124

ben