发送并通过Android应用程序上的USB端口接收数据 [英] Send and Receive Data on USB Port via Android App

查看:966
本文介绍了发送并通过Android应用程序上的USB端口接收数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想建立一个Android应用程序,将通过URL获取一些数据,并将其发送我的Andr​​oid平板电脑的USB端口上。 USB端口连接到USB串口转换器。

I am trying to build an android app which will fetch some data from a URL and send it on the USB port of my android tablet. The USB port is connected to a USB-Serial Port Converter.

我无法弄清楚的部分,你的USB端口上发送数据。
很多谷歌上搜索,我发现亚洲开发银行后, HTTP://$c$c.google.com/ p /微桥/ 等,但他们都没有可以使用的Java库。

I am not able to figure out the part where you send data on USB port. After lot of googling I found ADB, http://code.google.com/p/microbridge/ etc but none of them have a java library that can be used.

有什么建议?

推荐答案

您需要有相应的USB转串口的设备驱动程序编译进内核或加载到它作为一个模块,可以手动创建一个的/ dev / ttyUSB0设备文件或有东西,会自动创建它。

You need to have the appropriate usb-serial device driver compiled into your kernel or loaded into it as a module, and either manually create a /dev/ttyUSB0 device file or have something that automatically creates it.

和我们假设你的转换器插入该供电并具有主机模式驱动程序支持它工作的USB主机端口。

And we are assuming your converter is plugged into a working USB host port that supplies power and has a host-mode driver backing it.

从本质上讲这个作品以同样的方式作为对桌面Linux - 你可能想尝试在桌面Linux转换器要弄清楚它是使用哪个驱动程序

Essentially this works the same way as on a desktop linux - and you may want to try the converter on a desktop linux to figure out which driver it is using.

如果它不工作了平板电脑的盒子,很有可能你需要根除它,才能加载驱动程序模块(或更改内核),创建在/ dev目录并设置权限,这样节点(文件)该程序可以访问它。

If it's not working out of the box on your tablet, most likely you will need to root it, in order to load the driver module (or change kernels), create the node (file) in /dev and set permissions so that programs can access it.

访问是通过打开设备文件,调用一些的ioctl的配置它,然后只需阅读和写作。开幕式和配置可能需要JNI本地code(尽管你也许可以从Java做),之后,你应该能够读取和编写Java。

Access would be by opening the device file, calling some ioctl's to configure it, and then just reading and writing. The opening and configuring may need to be jni native code (though you can probably do it from java), after that you should be able to read and write from java.

这可能是值得探讨的是使用蓝牙串口适配器另一种选择 - 这是独立的多个设备,可能不需要生根

Another option that may be worth looking into is using a bluetooth-serial adapter - this is more device independent and probably does not require rooting.

这篇关于发送并通过Android应用程序上的USB端口接收数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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