我想在 Java 上将数据写入 USB 摄像头。为此,我正在使用LibUSBJava。output endpoint
我可以打开USB摄像头并成功读取数据,但是当我尝试写入数据时,我在打开的设备上找不到任何数据。对于 find output endpoint
,我已经实现了这个功能。当我调用这个函数时,它返回null
. 我调试了这个方法,发现dev
有4个接口。它们都有input endpoint
,但output endpoint
这些接口上没有。
private static Integer getActiveOutputEndPoint(Device dev) {
try {
Configuration cd = dev.getConfiguration();
if (cd == null)
System.out.println("Configuration Descriptor: null!");
else {
for (int i = 0; i < cd.getNumInterfaces(); i++) {
Interface ifc = cd.getInterface(i, 0);
if (ifc == null)
System.out.println("Interface Descriptor: null!");
else {
for (int k = 0; k < ifc.getNumEndpoints(); k++) {
Endpoint ep = ifc.getEndpoint(k);
if (ep == null)
System.out.println("Endpoint Descriptor: null!");
else {
if (ep.isInput()) {
continue;
} else {
return ep.getEndpointAddress();
}
}
}
}
}
}
} catch (IOException e) {
System.out.println("ERROR ! Configuration Descriptor: null! or Interface Descriptor: null!");
}
return null;
}
有没有人可以帮助我?