从 Android 与 Arduino 通信 [英] Communicating with Arduino from Android

查看:30
本文介绍了从 Android 与 Arduino 通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Android USB Host API 与带有 USB 主机支持的 ​​Android 3.1 设备的 Arduino 板 (Duemilanove) 通信.

i'm trying to communicate with Arduino board (Duemilanove) from Android 3.1 device with USB-host support using Android USB Host API.

目标是以与通过串行相同的方式与电路板通信.

The goal is to communicate with the board in the same way as via Serial.

我遵循本手册 (http://android.serverbox.ch/?p=427) 但几乎没有问题(fe 未能声明接口)和粗略的开发指南(http://developer.android.com/reference/android/hardware/usb/package-summary.html) 但没有运气.

I follow this manual (http://android.serverbox.ch/?p=427) but have few problems (f.e. failed to claim interface) and of coarse dev guide (http://developer.android.com/reference/android/hardware/usb/package-summary.html) but no luck.

问题是:

  1. 如何准备 arduino 板(修改固件)- 中断或 smth?
  2. 如何检查arduino板是否正常(例如枚举USB接口并验证它是否支持所需.可以使用哪些工具?
  3. 如何找到需要的接口(什么是接口类/协议/子类)
  4. 无法声明接口的原因是什么?(面对那个)

推荐答案

  1. arduino Duemilanove 板仅内置 FTDI FT232RL USB 串行转换器.所以你不必处理USB设备端.从 AVR 控制器的角度来看,它只是一个异步串行端口.找出它连接到哪个 UART 并使用它.也许您想实现一个简单的回声(再次发送所有接收到的字符)作为第一次测试.

  1. The arduino Duemilanove board has only a build in FTDI FT232RL USB serial converter. So you don't have to deal with the USB device side. From the AVR controller point of view it is simply an asynchronous serial port. Find out to which UART it is connected to and use it. Maybe you want to implement a simple echo (transmit all received characters again) as a first test.

在linux下使用lsusb命令查看usb设备描述符.

Use lsusb command under linux to check out the usb device descriptor.

了解 USB USB 简介在官方规范中 了解它是如何工作的(尤其是第 9 章).不这样做,你就不能继续.你什么都不会明白.然后继续阅读 CDC 类设备在 USB 类部分.

Read about USB in USB in a nutshell or in the official specification to find out how it works (especially chapter 9). Without doing so you can't go on. You would not understand anything. Then go on and read about CDC class devices in the usb class section.

它可能不存在(如果您在不检查设备描述符的情况下依赖接口索引)或者 android 内核已声明该接口,因为该接口有本机驱动程序.在这种情况下,您可以使用 true 作为第二个参数调用 UsbDeviceConnection.claimInterface 以首先断开内核驱动程序.

It might not exist (if you rely on the interface index without checking the device descriptor) or the android kernel has claimed the interface because there is a native driver for that interface. In this case you can call UsbDeviceConnection.claimInterface with true as second argument to disconnect the kernel driver first.

这篇关于从 Android 与 Arduino 通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆