USB code for Android 2.3.4 - android

I want to use usb in my application to retrieve data from my computer (present in text files) to android mobile and read it... what are the neccessities in terms of hardware and helpful links for the usb code...
Recently google launched USB accessory for android 2.3 ... it have classes UsbManager, UsbAccessory etc... i want to use that ... how can it be used.??

Usually the opposite of this is observed, where the android mobile projects itself as a usb device (client) , The USB host controller driver on the computer recognizes the device and handles future USB requests from your client. This is just the hardware layer, mind you. Since the USB protocol has become so ubiquitous, the computer actually stores multiple families of drivers both at the kernel layer and user space to be able to handle the variety of requests and their user space interpretations.
Since android mobiles are primarily linux-based devices, to achieve your end you will need to integrate these USB host-based driver families to your device's kernel / ROM. You will need to create a custom ROM (someone else asked this question here). This link provides you a list of drivers corresponding to specific hardware families.
Additionally, you will need to set up necessary programs on your computer that allows it to project itself as a USB client.
If you use linux on the computer too, this article might help you to start.

Related

Connect external hardware to android tablet

Im developing an application for a manufacturing plant. They want to connect a scale, printer and meter counter to an android tablet.
They use rs232 ports.
Im planning on using the galaxy view tablets that have a Micro Usb port, then hook that up to usb hub and then use a rs232 converter.
My question is will this be able to communicate to the tablet? At least show the raw values and will it know its 3 separate pieces of hardware?
I have a similar problem but only part of your problem here:
Connecting external hardware to Android Phone
You need to ask those hardware manufacturer to send you the Android driver to include in your Android app. It will run on some phone but may not work on all phone. Most software developer will refuse to provide support for Android as there are so many manufacturers and possibly compliance issue. Your best bet will be to ask the hardware manufacturer which phone/tablet they have tested the device on. In any case you still need a hardware driver like the one for windows.

Android USB host mode "soft-mode" drivers for standard class-compliant USB devices

Now that the Android APIs support working directly with USB devices (since 3.1), I am curious if there has been any work to create "soft-mode" drivers for some of the more popular class-compliant devices (such as audio or HID).
In other words, are there any open source projects that wrap up more useful communication with specific classes of devices into a Java class that can be added to an Android project?
For my purposes, I am specifically interested in USB audio, but it seems that a community-built set of classes derived from Linux kernel module sources could be beneficial to many projects. My hope is that others have thought of the same thing and have already began work. Any pointers in this direction would be most appreciated.
A few more resources that I have stumbled on:
User mode USB isochronous transfer from device-to-host
Audio Evolution seems to have built their own userland driver somehow
I have started work on an IRDA driver stack over USB in user space.
I am working out the basic plumbing but as far as I can see if I can create the equivalent user space driver to the linux kernel drivers such as the STIR4200 driver then I "ought" to then be able to port over existing IRDA protocol stacks such as JIR.
We shall see...

Bluetooth Drivers on Android Device

I'm currently looking into communicating with a bluetooth enabled device from an android app that I'm developing. In order for a PC to communicate with this device, one must install drivers on the computer. My question is, if I am required to install bluetooth drivers on the PC, will I not be able to communicate with the device using an android app? Essentially I'm trying to find out how the drivers come into play with the communication of the dev
Android only supports certain Bluetooth device "profiles". What is the device you are trying to communicate with? Fortunately many Bluetooth peripherals use Serial Port Profile (SPP), so there's a decent chance you can easily talk to your device via a BluetoothSocket.
See this topic for more info on writing apps for Bluetooth
EDIT: Sorry, to more directly answer your specific question, your users will not/cannot install OS "drivers" on their Android devices for your Bluetooth peripheral. Assuming you can use BluetoothSocket to talk to your peripheral, everything else will be up to you and your app.
The idea of a driver is that it is software to enable a hardware component. Hardware drivers generally sit between the Hardware Abstraction Layer and device. In addition, hardware that works without having a formal driver installation step still has a driver which was bundled into the operating system. I am confused how your research could bring your understanding this direction: will I not be able to communicate with the device using an android app. If you mean, "will your end users require a driver", the short answer is yes and "will my development computer require a driver to write the computer side of my application", again yes.

How to communicate with a USB device from Android tablet?

From a year ago, Is there a way to communicate with USB devices on Android? this didn't look like a common requirement, but tablets have evolved, and hopefully, the OS has, as well.
I need to operate a simple USB relay card from my Curtis LT8025 tablet, currently running 2.1 patched.
I'm also a newcomer to both Android and java, so relatively clueless!
No need for bi-directional communication, just a simple serial command out to the device.
Any suggestions?
Thanks!
Dave
Sadly, there is currently no standard API to achieve wired communication with Android devices. I was facing a similar issue a while back (see Android: Communicating with a USB device which acts as host ).
I was able to successfully implement the solution provided by CommonsWare. Leave a comment if you need more help regarding this and I can provide details.
Edit (more details) -
Basically, I narrowed down to two possible solutions for this problem:
Modify the Android source itself to include custom drivers for whatever purpose you need and install this in your tablet. Since its mostly based on Linux, if you develop the drivers for Linux, the same can be used in Android with a little modification. This solution is simpler to develop, but not practical commercially if you are not providing the tablet/phone yourself.
Make your USB device act as an host and implement the ADB driver/command-set in your device. When connected, you can issue "adb forward" to forward tcp ports so you can interact with your Android apps and have two way communication between the device and the app.
I used the second method and it works flawlessly. But its only practical if you are making USB host devices. for USB slaves, first method is the only way I recon.
If you are using a serial device and have the ability to talk to it over native serial, you might want to consider IOIO (see http://ytai-mer.blogspot.com/2011/04/meet-ioio-io-for-android.html for more details).
I'm building an Android custom system. I did connect several devices on the USB. I looked to connect a device on the OTG port, the one that usually gets out of a tablet on which you use ADB. I gave up. This is a nightmare. I don't think you can use ADB on the OTG USB that is currently a device and expect to be able to use another device like a USB to serial converter. That means that you loose the whole ADB toolchain for debugging when you want to use the port as a host. On top of that, the USB OTG drivers you have for your tablet was probably not very well tested in host mode since it's not really used that way. So lots of headakes.
The simple way that I found was to use the second USB port on the CPU. This one is a plain HOST port (unfortunately limited to 12 Mbit/s). Unfortunately, I don't know if there are any tablet out there with 2 USB port available from outside (One OTG and one host).
If you get a set-up with two USB port (one HOST) then it's possible to compile as a module (drivername.ko), a usb to serial converter. There are several chipset supported in the kernel source tree and I already used a few of them and it works.
hope this bit of info is helpful.

android: api to external usb devices for robotic applications

Android devices become incredible cheap (especially those with android v1.6). I'm considering to use one as a brain of autonomous robot. Unfortunately I didn't find any info on that.
I would like to connect two external USB-webcams and some DIY-selfmade USB ADC & output-ports converter to steer the wheels and read analog distance sensors. If I choose some cheap netbook than they usually already have 3 usb ports. But if I will be forced to use a tablet, then it requires also an usb hub.
Do android devices support usb-hubs?
Is there any API to grab still frames from external usb webcams (e.g. "vfa://0" & "vfa://1")
Is there any API to read from USB custom device? Let assume that it will simulate serial port for simplicity.
Do I get all of this in android 1.6 or any newer version?
As an update for your information: Based on answers I assume that android device will be too expensive in comparison to effort. I will go for cheap atom netbook with standard linux & arduinio USB device for controls & sensors. At cost of half kg (one pound) heavier device I will save months on learning & development.
You need an android device that either supports usb host mode out of the box (a few of the cheap tablets apparently do) or a phone that can do so with custom usb power wiring and perhaps a new kernel driver (as many phones can).
You will likely need root.
The api would be the normal linux USB stack, including just about any C-coded source-available device driver available for a desktop linux (excepting those that use bits of x86 binary windows drivers run in a compatibility wrapper).
You could interact with that either from the ndk using normal methods (device files, read/write/ioctl) or with careful driver design so things really look like files you can probably get at some of it from java or at the very least java with some thin ndk wrappers around device file operations.
Essentially, this isn't an "android" question, it's a question about the capabilities of a particular android device's hardware, how to get root on that device, and then it becomes a standard embedded linux question.
As far as I know you won't get any of this with the default Java API. Lots of this stuff can however be achieved if you build a custom kernel and add needed modules to it. Basically it all comes down to kernel hacking and won't be really Android related.
I'm very interested in stuff like that myself so keep me updated please.

Categories

Resources