Android USB host-to-serial connection?

2019-01-21 20:45发布

Apparently with Android 2.3.4 and 3.1 one can now access USB accessories.

I have a Ardupilot Mega (based on Arduino) board with a USB cable connected to my laptop, and I can connect to it using a simple serial communications program over COM7 and 115,200 baud. This allows me into the command-line interface, and I can issue commands and get logs.

Is it possible to write an Android app that will communicate over USB to my Ardupilot Mega board?

I've seen many similar threads, but most of them were pre-USB host.

4条回答
乱世女痞
2楼-- · 2019-01-21 20:57

Maybe. Check out the Android Open Accessories announcement on the Android Developers Blog. The Arduino Mega ADK is compatible. Not sure about the Ardupilot Mega.

From their page:

The Android 3.1 platform (also backported to Android 2.3.4) introduces Android Open Accessory support, which allows external USB hardware (an Android USB accessory) to interact with an Android-powered device in a special "accessory" mode. When an Android-powered powered device is in accessory mode, the connected accessory acts as the USB host (powers the bus and enumerates devices) and the Android-powered device acts as the USB device. Android USB accessories are specifically designed to attach to Android-powered devices and adhere to a simple protocol (Android accessory protocol) that allows them to detect Android-powered devices that support accessory mode. Accessories must also provide 500mA at 5V for charging power. Many previously released Android-powered devices are only capable of acting as a USB device and cannot initiate connections with external USB devices. Android Open Accessory support overcomes this limitation and allows you to build accessories that can interact with an assortment of Android-powered devices by allowing the accessory to initiate the connection.

Note: Accessory mode is ultimately dependent on the device's hardware and not all devices will support accessory mode. Devices that support accessory mode can be filtered using a "uses-feature" element in your corresponding application's Android manifest. For more information, see the USB Accessory Developer Guide.

The following list of distributers are currently producing Android Open Accessory compatible development boards:

The Arduino Store provides the Arduino Mega ADK (in EU nations or non-EU nations) that is based on the ATmega2560 and supports the ADK firmware. DIY Drones provides an Arduino-compatible board geared towards RC (radio controlled) and UAV (unmanned aerial vehicle) enthusiasts. Microchip provides a PIC based USB microcontroller board. Modern Device provides an Arduino-compatible board that supports the ADK firmware. RT Corp provides an Arduino-compatible board based on the Android ADK board design. Seeed Studio provides an Arduino-compatible board that supports the ADK firmware. SparkFun's IOIO board now has beta support for the ADK firmware.

查看更多
Bombasti
3楼-- · 2019-01-21 20:58

You can check out the library described in Slick USB 2 Serial Library.

It enables common USB-to-serial adapters to work with Android devices that have USB host mode without needing to root.

查看更多
Luminary・发光体
4楼-- · 2019-01-21 21:13

http://slickdevlabs.com/

I am currently using the library in my own app, however I think you can get away with just the app that slick has on the market. There are two free apps and one is the "pro" version of one of the free ones; search slick usb in Google Play.

It does use HOST mode and you can change the baud rate to whatever you need.

查看更多
仙女界的扛把子
5楼-- · 2019-01-21 21:17

usb-serial-for-android is my open source library written for exactly this need. It supports FTDI and CDC-ACM usb serial devices using Android's USB host support; no root or ADK necessary. It can talk most Arduinos.

The project is still in its early days, but the basic support has worked well enough for several projects. There is also a discussion list where you can get help.

查看更多
登录 后发表回答