我遇到了一个问题:我在我的windows 8笔记本电脑上使用usb4java。我在我的usb端口上插入了一个红外线遥控器。现在我想访问这个Controller.I,我得到了下面的示例代码(没有编程的异常,NullPointers也没有处理,因为我只想看看我的代码是否有效):
public class IRController_Test {
/**
* @param args the command line arguments
* @throws javax.usb.UsbException
*/
public static void main(String[] args) throws UsbException {
UsbServices usbServ = UsbHostManager.getUsbServices();
UsbHub hub = usbServ.getRootUsbHub();
List<UsbDevice> list = hub.getAttachedUsbDevices();
UsbDevice device = null;
for(UsbDevice dev : list){
if(dev.getUsbDeviceDescriptor().idVendor() == (short)0x0755 &&
dev.getUsbDeviceDescriptor().idProduct() == (short)0x2026){
device = dev;
System.out.println("Found the port!!");
}else{
System.out.println("Not the port!");
}
}
UsbConfiguration config = device.getActiveUsbConfiguration();
List<UsbInterface> listInf = config.getUsbInterfaces();
UsbInterface inter = listInf.get(0);
inter.claim();}
因此,它找到了端口,但是当我调用"inter.claim()“时,我得到了这个异常:
Exception in thread "main" javax.usb.UsbPlatformException: USB error 12: Can't open device Bus 002 Device 003: ID 0755:2026: Operation not supported or unimplemented on this platform
at org.usb4java.javax.ExceptionUtils.createPlatformException(ExceptionUtils.java:39)
at org.usb4java.javax.AbstractDevice.open(AbstractDevice.java:226)
at org.usb4java.javax.AbstractDevice.claimInterface(AbstractDevice.java:406)
at org.usb4java.javax.Interface.claim(Interface.java:102)
at org.usb4java.javax.Interface.claim(Interface.java:93)
at IRController_Test.main(IRController_Test.java:48)Java结果:1成功构建(总时间:0秒)
我通过Zadig安装了一个WinUSB (v6.1.7600.16385)驱动程序,但是仍然有这个error.Is可以帮助我吗?(谢谢各位的帮助:)
发布于 2014-05-01 12:00:58
我用我的一些设备测试了你的代码。它在跑。我想说这是司机的问题。使用ZADIG时,您应该检查菜单项“列出所有设备”,然后必须从下拉列表中选择正确的设备。然后按下“替换驱动程序”按钮。
但是要小心:如果这样做,您只能在Java应用程序之外与设备进行通信。再也没有其他应用程序可以访问该设备了。但是,如果有问题的话,您可以从windows设备管理器重新安装旧的。
https://stackoverflow.com/questions/23386118
复制相似问题