java:找不到端点,但python有效 [英] java: No Endpoint found, but python works

查看:36
本文介绍了java:找不到端点,但python有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试来自 http://libusbjava.sourceforge.net 的 java libusb 甚至无法连接到我的设备...

I want to try out the java libusb from http://libusbjava.sourceforge.net and cant even connect to my device...

我之前有这个 python 代码:

I had this python code before:

def discover():
    my_device = None
    for bus in usb.busses():
        for dev in bus.devices:
            if dev.idVendor == 0x16c0 and dev.idProduct == 0x05dc:
                handle = dev.open()

效果非常好.现在我想在 java 中构建相同的并做了这个:

which worked really great. now i wanted to build the same in java and made this:

Device dev = USB.getDevice((short) 0x16c0, (short) 0x05dc);
try {
    dev.open(1, 0, -1);

} catch (USBException e) {
    }

但我现在得到的是

ch.ntb.usb.USBException: No USB endpoints found. Check the device configuration
    at ch.ntb.usb.Device.updateMaxPacketSize(Device.java:82)
    at ch.ntb.usb.Device.initDevice(Device.java:114)
    at ch.ntb.usb.Device.open(Device.java:194)
    at Main.main(Main.java:14)

这不是真的,因为我仔细检查了 lsusb 中的值,并且我有一个配置 1 和一个接口 0...连接到我的设备有什么困难?我不明白...

that cant be true because i double checked the values from lsusb and i have a Configuration 1 and an Interface 0... Whats could be so difficult to connect to my device? I dont get it...

推荐答案

我发现该设备只有一个中断端点,python 实现可以访问该端点,但 java 实现无法访问...我改变了它,现在它有效!

I found out that the device only had an interrupt endpoint, which is reachable for the python implementation but not for the java one... I changed that and now it works!

这篇关于java:找不到端点,但python有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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