我正在尝试从通过USB连接到具有usb4java库的Windows 10pro机器的RFID阅读器读取消息。
我设法声明了接口,打开了管道并为数据注册了侦听器,但是从未触发过该侦听器。 读取器充当键盘,其读取的内容最终都在活动应用程序(例如我已打开的IDE)中,而不是在侦听器中 。
UsbInterface usbInterface = activeInteface(device);
// there is only one endpoint in the list
UsbEndpoint endpoint = (UsbEndpoint)usbInterface.getUsbEndpoints().get(0);
UsbPipe pipe = endpoint.getUsbPipe();
try {
usbInterface.claim();
// true
System.out.println("claimed usb interface: " + usbInterface.isClaimed());
pipe.open();
// true
System.out.println("pipe open: " + pipe.isOpen());
pipe.addUsbPipeListener(new MessageListener());
// true
System.out.println("pipe active: " + pipe.isActive());
// keep main thread alive, async call should be done from another thread i guess
Threa