Android: Communicating with a USB device which acts as host

血红的双手。 提交于 2019-12-06 04:07:58

问题


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 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.


回答1:


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.



来源:https://stackoverflow.com/questions/3434107/android-communicating-with-a-usb-device-which-acts-as-host

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!