Permission Errors when opening device (Using Windows 10)

1,325 views
Skip to first unread message

Matt

unread,
Jan 7, 2016, 12:14:09 AM1/7/16
to usb4java
Hi everyone,

I'm working on a small Java project (my Programming knowledge is still a work in progress...). I require to read in from a USB device on a Windows 10 machine. I've used the quick start guide for The low-level (libusb) API and that has been very helpful.

I've been stuck on a problem for numerous days now and I'm not getting very far. I'm sure it's probably something easy, but with my experience I'm stuck.

When I run the LibUsb.open(device, Handle) I receive the following error: USB error 3: Unable to open USB device: Access denied (insufficient permissions).

As per the help pages and other questions I ran the zadig program and that did fix some previous issues I was having, but I can't seem to get around this one and the solution I haven't been able to find online. Hoping someone could help me?

I've been using eclipse. Thanks for any support you can give me.

Matt

Sample Code below

       public void actionPerformed(ActionEvent arg0) {
     
//Initialize the libusb
            context
= new Context();
           
int result = LibUsb.init(context);
           
if (result != LibUsb.SUCCESS) {
               
throw new LibUsbException("Unable to initialize libusb.", result);
           
}
           
//Find the Device on the System
           
short vendorId = (short)1545;
           
short productId = (short)797;
           
Device device = findDevice(vendorId,productId);
           
DeviceHandle handle = new DeviceHandle();
            result
= LibUsb.open(device, handle);

           
if (result != LibUsb.SUCCESS) {
 //This fails with USB error 3: Unable to open USB device: Access denied (insufficient permissions).
                throw new LibUsbException("Unable to open USB device", result);
           
}
           
try
           
{
               
// Use device handle here
           
}
           
finally
           
{
               
LibUsb.close(handle);
           
}          
           
LibUsb.exit(context);
       
}
   
public Device findDevice(short vendorId, short productId)
{
   
// Read the USB device list
   
DeviceList list = new DeviceList();
   
int result = LibUsb.getDeviceList(null, list);
   
if (result < 0) throw new LibUsbException("Unable to get device list", result);
   
try
   
{
       
// Iterate over all devices and scan for the right one
       
for (Device device: list)
       
{
           
DeviceDescriptor descriptor = new DeviceDescriptor();
            result
= LibUsb.getDeviceDescriptor(device, descriptor);
           
if (result != LibUsb.SUCCESS) throw new LibUsbException("Unable to read device descriptor", result);
           
if (descriptor.idVendor() == vendorId && descriptor.idProduct() == productId) {
               
System.out.println("Found Device!");
               
return device;
           
}
       
}
   
}
   
finally
   
{
       
// Ensure the allocated device list is freed
   
}
   
// Device not found
   
return null;
}

Matt

unread,
Jan 7, 2016, 8:16:27 PM1/7/16
to usb4java
I tried completing a simply read from a USB device with both the low-level (libusb) API and the high-level (javax-usb) API and I receive similar permission errors. Has anyone gotten Usb4Java to work on Windows 10? I'm having a hard time finding any example that is not directly running from C or using Java from Linux.

Just curious if anyone has a working example for Windows 10? No idea how to get around the issue I'm having.

Awais Akhtar

unread,
Jul 24, 2017, 9:22:38 AM7/24/17
to usb4java
Hi Matt, 
did it work for you on windows? getting same problem with permission.
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages