软件基于Android的配件在Windows [英] Software based Android accessory on Windows

查看:232
本文介绍了软件基于Android的配件在Windows的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想打开我的电脑变成一个Android配件使用我的应用程序。因此,而不是一个专门的硬件,这将只是电脑,将手机切换到辅助模式,从而启动与主机的硬件相关的部分手机的Java应用程序,并创建一个沟通渠道。

I would like to turn my computer into an Android accessory using my application. So instead of a specialized hardware this will be just PC that will switch the phone into accessory mode, thus launching some Java app on the phone associated with the host hardware and create a communication channel.

我已经找到了样品code (加上一些Java的Andr​​oid应用程序),这样做在Linux上使用libusb的。它的工作原理是开放使用标准的VID和PID的手机。然后它发送href="http://developer.android.com/guide/topics/usb/adk.html#start">命令打开的附件模式一个

I've found a sample code (plus some Java Android app) to do this on Linux using libusb. It works by "opening" the phone using the standard VID and PID. Then it sends a command to turn on the accessory mode, along with the metadata like model, version etc.

如果手机支持附件模式,那么它会断开并重新枚举了不同的PID。样品code,则检查其是否确实,并打开新的设备。

If the phone supports accessory mode it'll then disconnect and reenumerate with a different PID. The sample code then checks if it did and opens the new device.

不过,我试图让这个运行在Windows上。我发现了几个USB库,如 LibUsbDotNet ,但他们似乎都需要使用了WinUSB设备/ libusb的驱动程序。我用的LibUsbDotNet一个工具生成的libusb驱动程序我的手机,在旧通用的可移动驱动器使用一个安装。但是,这意味着我现在不能访问手机作为一个可移动驱动器时,我想,所以这不是一个解决方案。

However, I'm trying to get this running on Windows. I've found a few USB libraries, like LibUsbDotNet, but they all seem to require the device using a WinUSB/libusb driver. I've used a tool in LibUsbDotNet to generate a libusb driver for my phone, installing it over the old generic removable drive one. But this means I now can't access the phone as a removable drive when I want to, so this is not a solution.

有没有一种方法(preferably库),可以打开基于VID和PID的任何连接的USB设备,然后派几个原始的命令呢?

在该装置将用不同的PID,我可以用它来创建自己的了WinUSB驱动程序,所以这不是一个问题重新枚举。我只需要通过注入一些命令/各地默认的驱动程序打开附件模式。

After that the device will reenumerate with a different PID, which I can use to create my own WinUSB driver, so that is not an issue. I just need to inject some commands through/around the default driver to turn the accessory mode on.

(我会preFER .NET解决方案,但任何Windows是不错,我可以写我自己的Interop包装)

(I would prefer .NET solution, but anything Windows is fine and I can write my own interop wrapper)

推荐答案

我也在寻找一个类似的解决方案。我试过的L​​inux版本,用的libusb,很少hickups,能够与设备进行通信。 虽然搜索的解决方案,在Windows上我试过很多黑客。 如果需要在ADK模式与设备进行通信,我需要发一些供应商的命令,现在这个我需要做的,而其在大容量存储模式连接。这是不可能使用大容量存储驱动程序。我试图让连接的USB设备节点手柄,看看是否可以发送厂商的命令,但我只能文件中获取描述符请求。于是我就丑的方法,取代大容量存储驱动程序的libusb-win32的,看到它可以做同样的,是的,它的工作,但根本不是一个很好的解决方案。

I am also searching for a similar solution. I tried the Linux version, with libusb, with little hickups, was able to communicate with the device. While searching for the solutions on windows I tried many hacks. If need to communicate with device in ADK mode, I need to send several Vendor Commands, now this I need to do while its connected in Mass Storage mode. This is impossible using Mass Storage driver. I tried to get the Node handle of connected USB device to see if could send vendor command, but there I could only file Get Descriptor requests. So I went ugly method, replaced mass storage driver with libusb-win32, to see it could do the same, YES, it worked, but not at all a good solution.

仍在寻找。

这篇关于软件基于Android的配件在Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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