在 Arduino 中使用 3.1 的 USB 主机模式
有没有关于在 Android 上使用 Arduino(其中 Android 设备是 USB 主机)的好教程? (Android 设备的操作系统版本为 3.1 (Honeycomb) 或更高版本)。开发者网站上唯一的主机程序是导弹发射器,它看起来比与 Arduino 的接口简单得多。
具体说明:我正在尝试使 Asus Transformer 主机成为 Arduino Uno,但由于有关于 Android host 模式如何工作的信息很少,我不知道从哪里开始。我只需要 Android 能够从 Arduino 内存中读取数据值。 Arduino 用于计算信号的频率,然后需要将该值传递给 Android。如果我错过了一些简单的方法,请随时告诉我。
(有很多关于使用 ADK 的信息让 Arduino 作为主机,但对于 Transformer,这不是一个选择 - 请参阅堆栈溢出问题是否可以获取Android ADK 在运行 3.1 的 ASUS Eee Pad Transformer 上工作?
这些信息实际上并不需要特定于 Transformer 或 Uno,我只是似乎找不到人的示例。在平板电脑上使用新的主机模式。
Is there a good tutorial for using an Arduino with an Android where the Android device is the USB host? (The Android device has OS version 3.1 (Honeycomb) or later). The only host program on the developer site is the missile launcher, which seems far simpler than interfacing with an Arduino would be.
Specifics: I'm trying to make an Asus Transformer host an Arduino Uno, but since there is very little information on how the Android host mode works, I'm lost on where to start. I just need the Android to be able to read data values out of the Arduino's memory. The Arduino is being used to count the frequency of a signal, that value then needs to be passed to the Android. If I've missed some simple way of doing this, feel free to let me know.
(There is a lot of information floating around about using the ADK to make the Arduino the host, but with the Transformer, that isn't an option - see Stack Overflow question Is it possible to get the Android ADK working on an ASUS Eee Pad Transformer running 3.1?.
The information doesn't really need to be Transformer or Uno specific, I just can't seem to find examples of people using the new host mode on their tablets.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我们使用以下代码使 FTDI 通信正常工作,无需内核驱动程序:
http://android.serverbox.ch/?p=370
请注意,Samsung Galaxy Tab 10.1 似乎缺乏正确的 USB 代码,甚至无法检测 USB 设备(除了鼠标、键盘、集线器和存储设备,这些设备由操作系统检测到,不会传递给应用程序)。
不过,我们在 Acer A500 上实现了此功能。
We got FTDI communcations working, without a kernel driver, using this code:
http://android.serverbox.ch/?p=370
Note that the Samsung Galaxy Tab 10.1 seems to lack the proper USB code to even detect USB devices (aside from mouse, keyboard, hub, and storage, which are detected by the OS and not passed to applications).
However, we got this working on an Acer A500.
arduino uno 放弃了以前设计中使用的 FTDI 或类似的 usb-rs232 芯片,转而采用基于 LUFA 堆栈。
对于普通的 Linux,您将使用 USB CDC 驱动程序 - 因此问题是蜂窝平板电脑是否附带这些驱动程序。
Honeycomb USB 主机支持 似乎提供了一种编写底层的方法第三方用户空间 Android 应用程序中的 USB 驱动程序,因此大概如果该功能尚未在内核中,则可以将其添加到用户空间中。
另一个想法是更改 arduino 上的 LUFA 安装,将其重新配置为 LUFA 项目支持的许多其他模式之一,使其看起来像未经修改的蜂窝平板电脑已经知道如何与之通信的东西,例如大容量存储驱动器,或键盘,或鼠标等。但是,如果您想对此系统外围设备进行低级(尤其是写入)访问,则可能需要蜂窝平板电脑上的根级访问权限。
The arduino uno drops the FTDI or similar usb-rs232 chip used on previous designs in favor of a re-programmable USB interface based on the LUFA stack.
With a normal linux you would use USB CDC drivers - so a question would be if the honeycomb tablet ships with these.
The Honeycomb USB host support seems to provide a means of writing low-level usb drivers in 3rd party userspace android applications, so presumably if the functionality is not already in the kernel it could be added in userspace.
Another idea would be to change the LUFA installation on the arduino, reconfiguring it to one of the many other modes supported by the LUFA project so that it looks like something an unmodified honeycomb tablet already knows how to talk to, such as a mass storage drive, or a keyboard, or a mouse, etc. You might however need root-level access on the honeycomb tablet if you want to do low-level (especially write) access to this system peripheral.
如果您只想找到一些使用 USB 主机功能的应用程序示例,那么最好的选择是使用 google 的代码搜索工具之类的工具,并搜索一些 USB 主机特定的类/权限/意图,
例如,搜索 < code>android.hardware.usb.action.USB_DEVICE_ATTACHED 会显示以下应用程序:
If you just want to find some examples of applications that use the USB Host functionality, your best bet is to use something like google's codesearch tool, and search for some of the usb host specific classes/permissions/intents
For example, a search for
android.hardware.usb.action.USB_DEVICE_ATTACHED
brings up the following applications:由于Arduino使用USB转RS232转换芯片,主机模式USB端口通常需要内核模块驱动程序来实现串行驱动程序。通常使用FTDI芯片,该模块可能被命名为ftdi_sio。因此,在低级别上,如果启用了 USB 主机模式,系统可能会使用此模块提供 /dev/ttyUSB0 设备。但我认为这是没有用的,因为它对应用程序是隐藏的,除非它在 root 设备上运行。所以我认为高级 ADK 抽象是正确的选择。
As the Arduino is using a USB to RS232 converter chip, the host mode USB port usually needs a kernel module driver for the serial driver implementation. Usually a FTDI chip is used, the module might be named ftdi_sio. So on the low level, if USB host mode is enabled, the system will maybe provide a /dev/ttyUSB0 device using this module. But this is useless i think as it is hidden from the application unless it is running on a rooted device. So the high level ADK abstraction is the way to go i think.