5. USB Host APIとADKの使い分け1
給電方式による使い分け
ADK :
○ Android端末の電源を持続させる
☓ 別電源が必要(ACアダプタorバッテリー)
使用用途:長時間据え置き、ロガー
USB Host API :
○ Android端末の電源を使える
☓ 長時間の使用には向いていない
使用用途:短時間だけ使用するツール、デモ
対象デバイスによる使い分け
ADK : USB Host機能がついたAVR(Arduino)/PIC系のADK
対応デバイス
USB Host API : 大抵のデバイスOK(アイソクロナス転送
以外)
6. USB Host APIとADKの使い分け2
プログラミング難易度による使い分け
ADK:アプリプログラミングがラク
USB Host API : アプリプログラミング
+USB基礎知識+USBプログラミング+USBデバッグ
技術的な障壁が高い・・・
→プロトコル部分をライブラリ化することでADK並
にラクに開発できる環境になる
…ということで
USBシリアル通信ライブラリ「FTDriver」を
githubで公開
7. USB Host API クラス
Class Description
UsbManager Allows you to enumerate and communicate with
connected USB devices.
UsbDevice Represents a connected USB device and contains
methods to access its identifying information, interfaces,
and endpoints.
UsbInterface Represents an interface of a USB device, which defines a
set of functionality for the device. A device can have one
or more interfaces on which to communicate on.
UsbEndpoint Represents an interface endpoint, which is a
6つ以上のクラス,
communication channel for this interface. An interface
数十メソッド
can have one or more endpoints, and usually has input
and output endpoints for two-way communication with
(めんどくさい!)
the device.
UsbDeviceConnection Represents a connection to the device, which transfers
data on endpoints. This class allows you to send data
back and forth sychronously or asynchronously.
UsbRequest Represents an asynchronous request to communicate
with a device through aUsbDeviceConnection.
UsbConstants Defines USB constants that correspond to definitions in
linux/usb/ch9.h of the Linux kernel.
12. 対応状況(2012/10/6現在)
FTDI
機種 OK/NG/?
・FT232RL
・FT232H Arduino UNO OK
・FT2232C/D/HL Arduino MEGA OK
・FT4232HL Arduino ADK OK
・FT230X Arduino Leonard NG
mbed NXP
ラトックシステム ?
LPC11U24
・REX-USB60F/MI
mbed NXP
OK
LPC1768
NXP LPC1769 OK
GR-SAKURA OK
PSoC ?
Arduino
OK
Duemilanove
秋月FT232RL Harpy nano OK
USBシリアルモジュール
19. 自分のAndroidは
USB Host API対応?2/4
AndroidのUSBホスト機能はLinux USBホスト機能と
USB Host APIの2種類存在
Linux USB ホスト USB Host API
目的・用途 エンドユーザがUSBキー 開発者がUSBホスト機能を
ボード/マウス/USBメモ 使ってアプリケーション開
リを使える。 発できる。
Androidバージョン Android3.1以前でも動作 Android3.1以降
対応内容 USB2.0の USB 2.0
USB Mass Strage アイソクロナス転送を除く
Class(USBメモリ)、USB 3種類の転送方式に対応。
HID Class(USBキーボー プロトコルがわかれば開発
ド、USBマウスなど) 者の手でUSBデバイスに対
応可
※「Linux USB ホスト」という名称はUSB Host APIと区別しやすくするため
勝手につけた名称です