对purejavahidapi库openDevice函数进行故障排除

时间:2019-06-05 22:54:25

标签: java hid

尝试打开与我的HID设备的连接时,在fedora 30上显示errno 13

我尝试设置udev规则并更改dev文件所有权(我知道这是一个短期解决方案),但没有帮助

我已经尝试联系purejavahidapi库创建者,因为他们担心自己不是linux用户,所以他们不知道如何解决它,也不是与库相关的问题,因此请在Internet上查找修复

public static void setup ()
    {
        List<HidDeviceInfo> devList = PureJavaHidApi.enumerateDevices();
        for (HidDeviceInfo info : devList)
        {
            if (info.getProductString().contains("Reader"))
            {
                System.out.println("Product String: " + info.getProductString());
                readerDevice = info;
                break;
            }
        }
        try
        {
            System.out.println("ReaderDevice content: ");
            System.out.println(readerDevice.getProductString());
            HidDevice dev = PureJavaHidApi.openDevice(readerDevice);

            dev.setInputReportListener(new InputReportListener()
            {
                @Override
                public void onInputReport(HidDevice hd, byte b, byte[] reportData, int i) {
                    System.out.println(reportData.toString());
                }

            });
        }
        catch (IOException ex)
        {
            System.out.println("IO Exception Encountered");
            System.out.println(ex.toString());
        }
    }

预期结果是程序建立了与HID设备的连接,实际上是给我的

  

java.io.IOException:open()失败,错误号13'

堆栈跟踪:

java.io.IOException: open() failed, errno 13
    at purejavahidapi.linux.HidDevice.<init>(Unknown Source)
    at purejavahidapi.linux.LinuxBackend.openDevice(Unknown Source)
    at purejavahidapi.PureJavaHidApi.openDevice(Unknown Source)
    at rfid.project.RfidProject.setup(RfidProject.java:41)
    at rfid.project.RfidProject.main(RfidProject.java:22)

0 个答案:

没有答案