Pass data from Tablet application to PC using USB - android

I have to communicate from tablet to PC using USB. I have studied about using TCP and abd but i have to do with the Serial port. I am even not sure is that possible or not. So please guide me through what is the way to achieve this. Any help is appreciated.

You can use a USB to UART bridge device to do this, but the caveat is that your tablet device will need a driver to do so. Your tag shows you are using Android, which is based on the Linux kernel. Linux already supports plenty of USB to UART bridge devices natively, so once you choose one you can go through the steps of building in the driver to your Android image and probably perform a make menuconfig and add in support for your driver that way.
Communication to the PC on the other side of the bridge can be through a standard RS232 serial port (if available), or you can use USB to UART bridge on the other side as well.

Related

Using a Panel PC DB9 Serial Port

I have a Panel PC which was Android OS. In this Panel PC, There are two DB9 Port which can use RS232, RS232/422/485.
It was possible to communicate serial data using USB port [for example FTDI chip or PL2303].
But I want to use the DB9 Port without FTDI or PL2303.
I know that linux is possible to communicate using device driver directly.
Are there any method to access to device driver directly in Android OS like Linux?
Please Help me.

Android to PC USB Read/Write

I have a program on PC taking in string input from USB ( old program) I have a Android (4.X) tablet which needs to provide string input on USB to the program running on PC.
When I used the sample code on Android, following code gives empty hashmap. The PC( tried on 32 bit XP and 64 bit Windows 7) has Android driver.
mManager = (UsbManager)getSystemService(Context.USB_SERVICE);
HashMap<String, UsbDevice> devices = mManager.getDeviceList();
Any real working code example talking to PC over USB will help, pl. also point out if any driver etc. needed on Android to talk to PC.
I have tried both the Accessory mode and the host mode( just in case)
I'm not sure I exactly follow what you're doing here, but if I understand you correctly - it just won't work this way. The UsbManager.getDeviceList() is meant to be used with Android devices with USB host port, to which some USB devices are connected. But, as far as I understand, you connect Android tablet acting as a device to your PC acting as a host (I guess so, cause you wrote about driver installation).
If you want to communicate between Android USB device and some USB host (e.g. because your Android device has no USB host capabilities), you need to use accessory mode (I suggest you start with this Android Developers Blog post). But this mode requires special support on the USB host side (it must talk to the device with Android Open Accessory Protocol). Note, that getDeviceList() makes no sense in Accessory mode - first of all, connected accessory is a USB host, not a USB device, and there can be only one USB host on a USB bus.
If you want to communicate with PC using Accessory mode, you may want to try this AOAP implementation for PC. If all you need is to talk to Android device for some debugging needs, you may want to use ADB port forwarding and TCP connection instead.

Programming Usb Connection with Android

I've started a project on Andorid, but I don't know NDK very much. I want to send custom data as per receiving message on usb port. I saw some applications that can send/recieve custom data on usb port if the phone is in recovery. I've programmed usb connection in windows before. But I haven't any clue where should I start in android. Is there any documentation for usb programming for android? If NDK isn't suitable to implement this, which options do I have? It is not important if the application is device specific.
The issues are more of system architecture and permission, an area where the NDK offers little in excess of the SDK.
Android does not really support (direct) custom use of the USB port, at least when the device is connected to a computer (there are some recent options when the device is hosting a USB peripheral). What is possible in recovery mode is essentially irrelevant, unless you want to make substantial modifications to the installation of Android running on your device.
Generally, the only practical way to do application-level communication between the device and a hosting PC is to use the IP networking paradigm over the USB cable. You do this either by enabling USB debugging on the device and installing much of the android SDK on the PC, or by enabling some forms of tethering which may create a general network as a side effect.
For the SDK method, read up on adb port forwards, including the limitation that the PC side must initiate the connection.
It may also be possible to create custom drivers which get a PC to pretend to be an android accessory kit (ADK) circuit and use the apis related to that.
Unfortunately, pretty much all of these ideas are more suitable for developers/power users, than for general consumer application. For consumer apps, most developers ignore the USB cable and do IP networking over WIFI, requiring the user to put the device and the PC on the same network, or proxy through an Internet server visible to both the PC and the device's mobile network.

USB Communication with Android/Arduino

I am working on this Android application that needs to communicate over USB. I have an Archos 101 Tablet (specifications here: http://www.archos.com/products/ta/archos_101it/specs.html?country=us&lang=en). It has a full USB host port. I can put a flash USB drive in the USB port and copy files to and from the flash drive onto internal storage.
I have this Arduino Fio board, with an XBee attached to it. I have an XBee Explorer Dongle with another XBee that I plan to hook into the Archos 101 tablet into the USB port.
As of right now, I can put the XBee Explorer Dongle into my computer and send/receive data to and from the Arduino Fio, no problems.
Is there a way for Android to talk over USB? I know there has to be drivers somewhere in the tablet allowing USB communication, but I cannot find a way to access them or use them.
I can see Android recognizing the XBee Explorer Dongle. I downloaded a terminal emulator, and I can type "dmesg" and see that it sees the dongle hooked up. But I cannot do anything with it.
I seem to need a FTDI driver for Android.
I would greatly appreciate any help in getting my tablet to communicate with the XBee Explorer Dongle.
If you have root and can hack your kernel, FTDI offers its D2XX driver for Android OS. Check its website, please.
If your Android device is 3.1+, you should be able to use Android USB host to talk with Arduino. However, I met some issues on this.
If you have ADK/UHS at hand, your Arduino can act as USB host and talk to Android USB device. Even in same hardware, if your Android OS is quite old like 1.5/1.6, you have to use ADB interface rather than ADK (Accessory Developer Kit) protocol.
If you have Bluetooth, you can write your own Bluetooth SPP in your app.
If you can handle WiFi, you can write app to communication with socket, or via latest WiFi direct mode in Android.
Communication is various. However, it depends your hardware.
There is a solution by Inopiaaardbei using Arduino and a USB host shield with an Android Debug Bridge running on Arduino.
Using this solution you can use serial communication between the Android phone and the Arduino board.
See my post and the link inside for more info.
You can use an android adk or the android ioio connected to an xbee module as I did in this article. I have published the code on my github and another guy is going to implement the gui currently.
USB is not easy to programm, and it would be much easier with ethernet or rs232. However, if you insist, then take a look at V-USB (SW USB), LUFA (HW USB) and Lufaduino (HW USB). If Android has USB CDC drivers already embedded then it could be the easiest path for you if you implement it in AVR too. Slow, cheap and software only AVR USB CDC implementation is here.

Data collection with Android via USB

What would be the best way to access the USB as a serial port on an Android device (HTC Magic)?
I am thinking about an OBD-II interface. Can I do this on a standard phone or more likely will I need a modified firmware?
According to this post, Matt Porter presented a review of Android at the Embedded Linux Conference Europe. I mention this mostly because of the example used to describe the current state of Android.
"Just one more practical example: You cannot even plug a USB drive to an android system, since /dev/sd* is not an expected device name in their hardcoded hotplug management.
Executive summary: Android is a screwed, hard-coded, non-portable abomination."
I'm sure someone's working on it, but I'm afraid for now you're out of luck unless you're willing to go low-level and edit the OS.
PSFreedom (project to jailbrack Playstation 3) has list of controllers which support usb host mode which then translate to supported Android devices.
My own expirience is that usb host works on HTC Dream/G1 without problems.
For OBD-II I would suggest bluetooth ODB-II dongle which side-stepps problem with usb host adapter.
Depending on the USB chip in your particular phone, it may be possible to rebuild the kernel to support USB Host mode or USB On-The-Go (Host + Gadget modes) instead of the normal USB Gadget mode. I've found some people speculating that it could be possible on the HTC Dream. Assuming you could reconfigure the USB port in Host mode a USB to serial, ODB-II, or CAN should be doable.
From what I can tell Android is Linux of some sort, to have USB device which would apear as serial port, you should write a driver for that device. I don't know much about OBD-II interface but i am guesing they use some sort of USB driver for windows, same is for android, not mentioning the application to handle the driver.
I don't think the current Android devices can act as a USB host only as a USB device when attached to a host. So using the USB port as a serial port is not likely.
Get a hostmode kernel for your device and you can use python for android and the pyserial library to talk to the serial over USB. I did this with Huawei Ideos U8150 (here is the post) for a loopback test.

Categories

Resources