开发者

Android: Communicating with a USB device which acts as host

开发者 https://www.devze.com 2023-01-10 21:30 出处:网络
We have made a device which can act as an USB host or slave and processes the data it receives. I want to use the Android phones to send the data to it via USB.

We have made a device which can act as an USB host or slave and processes the data it receives. I want to use the Android phones to send the data to it via USB.

My research leads me to conclude that we cannot use Android devices in USB Host mode without modifying the hardware or OS. Doing so is not an option开发者_JAVA技巧 as this is going to be a commercially deployed device.

However, I couldn't find any information on using the Android phone as a slave. This is already technically possible because it can connect to the PC in a similar configuration. Can we do the same via an application? If so, any information on how to achieve this will be greatly appreciated. I have full access to our device's embedded system, so custom code there should not be a problem.


This is already technically possible because it can connect to the PC in a similar configuration.

Only for things baked into the firmware. Your SDK application cannot invent new Linux device drivers, nor does it have any access to the Android device side of the adb connection.

Can we do the same via an application?

Since you have not said what you are trying to do, this is impossible to answer in a definitive fashion.

Say, for example, the "device which can act as an USB host or slave and processes the data it receives" wants screenshots off of the Android device. That is eminently possible via adb, because adb has a protocol for that built in. All you would need to do is have your device connect to the Android device via the adb protocol and request screenshots, no different than does DDMS or hierarchyviewer.

So, I would look at the problem from a different perspective: if you can accomplish it via DDMS, you can do it via your custom device. If you can accomplish it via adb shell commands, you can do it via your custom device. If you cannot accomplish your goals via existing interfaces, though, since you have no way to invent new ones over USB, you will be stuck.

Conceivably, you could plug your custom device into a Bluetooth or WiFi dongle, then use those on Android for communication.

0

精彩评论

暂无评论...
验证码 换一张
取 消