支持OTG的Android设备中的USB主机模式 [英] USB host mode in Android device supporting OTG

查看:134
本文介绍了支持OTG的Android设备中的USB主机模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道默认情况下,支持USB-OTG的Android设备处于哪种模式-在USB主机模式还是USB从机模式下?
我想,如果设备处于从属模式,那么使用下面链接中描述的API没有意义吗? https://developer.android.com/guide/topics/connectivity/usb/host.html
有没有办法以编程方式从主机模式切换到从机模式,反之亦然?

I'd like to know in which mode a USB-OTG-supporting Android device is by default, - in the USB host mode or USB slave mode ?
I guess, if the device is in slave mode, then there's no point of using API described on link below ? https://developer.android.com/guide/topics/connectivity/usb/host.html
Is there a way to programmatically switch from host to slave mode and vice versa ?

如您所知,USB OTG(移动中)设备会自动切换到主机或从机模式,具体取决于已将 OTG 专用电缆的哪一端插入设备

As you know, a USB OTG (On the go) device automatically switches to host or slave mode, depending on which end of an OTG-specific cable has been inserted into device

第二个问题是,如果设备具有必要的OTG端口,但内核尚不支持OTG,则应基于以下内容修改内核的哪些部分,以便能够设置主机-从机模式:电缆末端检测?(无需实施HNP)

And the second question is, in case if a device has necessary OTG ports, but the kernel does not support OTG yet, which parts of the kernel should be modified in order to be able to set host-slave mode, based on cable end detection ? (no need to implement HNP)

推荐答案

USB OTG中没有默认"模式.OTG控制器检测USB的第五个引脚(ID引脚)的状态.如果ID引脚接地或悬空,则说明连接的设备是主机或设备.

There is no "default" mode in USB OTG. OTG controller detects the state the USB's fifth pin(ID pin). If the ID-pin is grounded or floating, the connected device is a Host or device.

USB 2.0规范引入了3个新协议,即ADP,SRP,HNP.请参考HNP,以了解以编程方式从主机模式切换到从机模式,反之亦然"的方法.

USB 2.0 spec introduced 3 new protocols, ADP, SRP, HNP. Pls reference HNP for "a way to programmatically switch from host to slave mode and vice versa".

作为第二个问题,我认为检测ID引脚是OTG控制器的功能.

As your second question, I think detect the ID-pin is a function of OTG controller.

这篇关于支持OTG的Android设备中的USB主机模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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