【发布时间】:2016-03-02 13:34:53
【问题描述】:
我有一个设备,我必须通过 USB 与之通信。
它有 1 个活动配置,有 1 个接口。
界面有更多的备用设置(IDLE、PROF1、PROF2)。默认情况下,IDLE 处于活动状态。
我的问题是,我怎样才能激活 PROF2 设置?
bNumConfigurations: 0x01
bNumInterfaces: 0x01
[IDLE]
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
[PROF1]
bInterfaceNumber: 0x00
bAlternateSetting: 0x01
[PROF2]
bInterfaceNumber: 0x00
bAlternateSetting: 0x02
代码...
UsbConfiguration config = (UsbConfiguration) device.getActiveUsbConfiguration();
UsbInterface iface = config.getUsbInterface((byte)0x00);
UsbInterface alt = iface.getSetting((byte)0x02); // <= Setting is not active.
UsbEndpoint endpoint = alt.getUsbEndpoint((byte)0x83);
UsbPipe pipe = endpoint.getUsbPipe();
pipe.open(); // <= Pipe is not active.
【问题讨论】:
-
如果您告诉我们您使用的是什么库,我们可能会更容易。