使用我的 Android 作为 USB 设备

发布于 2024-10-05 14:18:51 字数 354 浏览 0 评论 0原文

我已经在 StackOverflow 上找到了一些关于如何使用 Android 手机控制 USB 设备的帖子——我知道这是不可能的(Android 是一个 USB 设备等等。)

但是,我非常乐意设置我的应用程序作为 USB 设备与另一台计算机(Linux 主机)进行通信。 (就像一个非常昂贵的鼠标...)

有人知道如何设置 Android 应用程序/手机以使用 USB 连接并与主机交换数据吗?显然,它已经在某种程度上起作用了——这就是 Eclipse 和 Android SDK/调试器的工作方式,但我仍在寻找某种方法在应用程序中执行此操作。

(顺便说一句,我现在的手机是 Droid Incredible。)

谢谢, R。

I've been able to find a few posts on StackOverflow about how to control USB devices using an Android phone -- which I understand is impossible (The Android being a USB device and all.)

However, I would be perfectly happy to set up my application to communicate with the other computer (a Linux host) as a USB device. (Like a really expensive mouse...)

Does anybody have information about how to set up an Android app/phone to use the USB connection and exchange data with a host computer. Obviously, it already works at some level -- it's how Eclipse and Android SDK/debugger do what they do, but I'm still looking for some way to do this in an application.

(My current phone, BTW, is a Droid Incredible.)

Thanks,
R.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

审判长 2024-10-12 14:18:51

基本上,您需要从 SDK 安装 USB 设备驱动程序和 ADB 工具套件,或者对其功能进行逆向工程并将其构建到其他东西中。

然后在手机上启用USB调试。

然后,您可以执行诸如 adb 端口转发之类的操作,以允许 PC 上的应用程序连接到手机上的网络套接字侦听器。请注意,不能在另一个方向上建立连接,但一旦建立连接,它就是双向的。

如果您的 Android 版本支持 USB 网络共享,您还可以利用它在 PC 和手机之间隐式创建网络,此时您可以在任一方向建立连接。只需确保不会意外地通过手机的移动网络传输大量数据即可!

(许多 Android 手机实际上可以实验性地充当 USB 主机,但是您必须将新的驱动程序编译到内核中,安装新版本,并制作一条电缆来为设备提供 USB 电源,而手机则不能。而且您还会丢失 ADB通过 USB 通道,这使得调试变得很痛苦)

Basically you'd need to install the USB device driver and the ADB toolsuite from the SDK, either that or reverse engineer their functionality and build it into something else.

Then you enable USB debugging on the phone.

And then you can do something like an adb port forward to allow an application on the pc to connect to a network socket listener on the phone. Note that connections cannot be made in the other direction, but once a connection is made it is bidirectional.

If your version of android supports tethering over USB, you could also leverage that to implicitly create a network between the PC and the phone, at which point you can make connections in either direction. Just make sure nothing starts accidentally pumping lots of data through the phone's mobile network!

(Many android phones actually can experimentally function as USB hosts, but you have to compile new drivers into the kernel, install the new version, and make up a cable to provide USB power to the device as the phone cannot. Also you lose the ADB over USB channel which makes debugging a pain)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文