简体   繁体   English

usb4java中的设备处理

[英]Device Handling in usb4java

I'm using libusb for communicating with usb device in java. 我正在使用libusb与Java中的USB设备进行通信。 My operating system is linux. 我的操作系统是linux。 But I have problem about open device. 但是我有关于开放设备的问题。

    DeviceHandle handle = LibUsb.openDeviceWithVidPid(null, VENDOR_ID, PRODUCT_ID_1);

    if(handle == null){

        System.out.println("Device Not Opened");
    }else{

        System.out.println("Device Opened");
    }

I'm getting the error that "handle must not be null". 我收到“句柄不能为空”的错误。

How can I solve this problem. 我怎么解决这个问题。 Thanks for your reply from now. 多谢您的回覆。

I came across your question while searching for another problem. 我在寻找另一个问题时遇到了您的问题。 I don't usually program in Java, so there might be some slight differences in the names of the function. 我通常不使用Java编程,因此函数名称可能会略有不同。

I think the first step you have to do is obtain a Session Handle, which describes the entire operation you are trying to do. 我认为您要做的第一步是获取会话句柄,该句柄描述您要尝试执行的整个操作。 Then pass that session handle instead of the NULL to the function you used above. 然后将该会话句柄(而不是NULL)传递给上面使用的函数。

Here's a reference to MonoUsbSessionHandler: http://libusbdotnet.sourceforge.net/V2/html/b35376bb-ab07-ee75-8c90-b9f9b12ce067.htm 这是对MonoUsbSessionHandler的引用: http ://libusbdotnet.sourceforge.net/V2/html/b35376bb-ab07-ee75-8c90-b9f9b12ce067.htm

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM