問題があります: Windows 8 ラップトップで usb4java を使用しています。USBポートに赤外線リモコンを差し込んでいます。次に、このコントローラーにアクセスしたいと思います。次のコード例を取得しました (コードが機能するかどうかを確認したいだけなので、プログラムされた例外はなく、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 Result: 1 BUILD SUCCESSFUL (合計時間: 0 秒)
Zadig 経由で WinUSB (v6.1.7600.16385) ドライバーをインストールしましたが、まだこのエラーが発生します。いつも助けてくれてありがとう:)