-1

我正在学习 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 视图的设备信息

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
4

1 回答 1

1

您的设备有一种bulk IN类型的端点——它只能以批量模式向主机发送数据。但是您尝试写信给它:

dev.writeInterrupt(0x81, data, data.length, 2000, false);

这不起作用,您需要一个interrupt OUT类型端点。它也将具有不同的端点地址。

于 2013-02-01T18:48:15.520 回答