通过 Android 与串行 USB 设备通信

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21800932/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 05:05:56  来源:igfitidea点击:

Communicating with serial USB device over Android

androidserial-portftdiusb-otg

提问by Josef

I have one custom made device for measuring current. This device can be connected to PC and communication is done over USB. It is based on FTDI chip. I have application written in Java and that application is using rxtxSerial.dll library and gnu.io.rxtx_2.1.7.4.jar. Now I want to port this application on my android device and I'm litte bit confused what to do that? All I have is android tablet (os version 4.1.1), OTG cable and this measuring device.

我有一个用于测量电流的定制设备。该设备可以连接到 PC 并通过 USB 进行通信。它基于FTDI芯片。我有用 Java 编写的应用程序,该应用程序使用 rxtxSerial.dll 库和 gnu.io.rxtx_2.1.7.4.jar。现在我想在我的 android 设备上移植这个应用程序,但我有点困惑该怎么做?我只有安卓平板电脑(操作系统版本 4.1.1)、OTG 电缆和这个测量设备。

Should my device be rooted? Is there any kind of library that I can simply add to my Java Android application and read data over USB? Where to start?

我的设备应该植根吗?是否有任何类型的库可以简单地添加到我的 Java Android 应用程序并通过 USB 读取数据?从哪儿开始?

I have tried to port existing application for PC using same library, but rxtxSerial.dll is missing and I can't transfer it to my android device.

我曾尝试使用相同的库为 PC 移植现有应用程序,但缺少 rxtxSerial.dll,我无法将其传输到我的 android 设备。

回答by Frank D.

I can really recommend the USB-Serial-For-Android library, it supports multiple popular usb-to-serial chips (also FTDI) and there is no rooting required. Check out the GitHub project here.

我真的可以推荐 USB-Serial-For-Android 库,它支持多种流行的 USB 转串口芯片(也包括 FTDI)并且不需要 root。在此处查看 GitHub 项目。

回答by yegorich

There is a project dedicated to serial communication on Android. android-serialport-api. I think, it is a good resource to start with.

有一个专用于 Android 上的串行通信的项目。android-serialport-api。我认为,这是一个很好的资源。

FTDI also provides Android related resources.

FTDI 还提供 Android 相关资源

回答by Jakub Turcovsky

I think there's currently only one properly maintained library for serial USB communication and it's felHR85/UsbSerial. It supports several USB chips including FTDI (see Devices Supported).

我认为目前只有一个正确维护的用于串行 USB 通信的库,它是felHR85/UsbSerial。它支持多种 USB 芯片,包括 FTDI(请参阅支持的设备)。

Unfortunately mik3y/usb-serial-for-androidseems to be dead.

不幸的是mik3y/usb-serial-for-android似乎已经死了。

And no, you don't need to root your device for connecting to and communicating with a USB device.

不,您无需根植您的设备即可连接到 USB 设备并与之通信。

EDIT:We have a maintained fork of mik3y's library. See kai-morich/usb-serial-for-android

编辑:我们有一个维护的 mik3y 库的分支。参见kai-morich/usb-serial-for-android

EDIT2:It seems that all of these libraries are maintained again, mik3y joined forces with kai-morich and they are working together.

EDIT2:似乎所有这些库都再次维护,mik3y 与 kai-morich 联手,他们正在合作。