我正在关注this库中的libusbjava教程。但是,当我尝试运行它时,它会引发以下错误。
ch.ntb.usb.USBException: No USB endpoints found. Check the device configuration
以下是该计划的相关部分
public static void testDevice(){
//Vendor ID, Product ID
Device dev = USB.getDevice((short) 0x0bda, (short) 0x2838);
try{
//Data to write to device
byte[] data = new byte[]{0,1,2,3};
//Data to read from device
byte[] readData = new byte[data.length];
dev.open(1, 0, -1);
dev.writeInterrupt(0x81, data, data.length, 2000, false);
dev.readBulk(0x81, readData, readData.length, 2000, false);
logData(readData);
dev.close();
}
catch(USBException e){
e.printStackTrace();
}
}
以下是USB View中设备的信息
Device Descriptor:
bcdUSB: 0x0200
bDeviceClass: 0x00
bDeviceSubClass: 0x00
bDeviceProtocol: 0x00
bMaxPacketSize0: 0x40 (64)
idVendor: 0x0BDA
idProduct: 0x2838
bcdDevice: 0x0100
iManufacturer: 0x01
iProduct: 0x02
iSerialNumber: 0x03
bNumConfigurations: 0x01
ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed: Full
Device Address: 0x02
Open Pipes: 1
Endpoint Descriptor:
bEndpointAddress: 0x81
Transfer Type: Bulk
wMaxPacketSize: 0x0200 (512)
bInterval: 0x00
答案 0 :(得分:1)
您的设备有一个bulk IN
类型端点 - 只能以批量模式向主机发送数据。
但你试着写信给它:
dev.writeInterrupt(0x81, data, data.length, 2000, false);
这不起作用,你需要一个interrupt OUT
类型的端点。它也有一个不同的端点地址。