Is there a way to communicate with USB devices on Android?
Asked Answered
P

3

8

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.

Pelkey answered 12/5, 2010 at 1:7 Comment(0)
A
2

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.

Aqueduct answered 12/5, 2010 at 1:11 Comment(10)
So, OS does not provide such functionality at all? Any ideas how to make that work?Pelkey
Could a special "crossover cable" of sorts handle this? Or is it more complex than that?Sentry
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 driversStull
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.Stull
@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.Aqueduct
@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.Aqueduct
@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.Stull
@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."Aqueduct
@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.Stull
Right. You need (1) an OTG controller chip (2) the host support circuitry and (3) the host driver.Aqueduct
W
1

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

Whitewood answered 5/9, 2010 at 2:8 Comment(0)
J
0

Yes, it will work, and you do not need to write drivers for the Android side. However, the device must support the open accessory protocol and must be able to supply power to the Android device. A development kit is available.

However: "Accessory mode is ultimately dependent on the device's hardware and not all devices support accessory mode."

Juliannejuliano answered 15/12, 2013 at 23:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.