问题
In making use of JNA in an Android app, I encounter a LastErrorException
with the message Device or resource busy
when I attempt to perform an ioctl operation on a USB device. I cannot guess why this is or what to do about it. Can anyone offer any guidance at all?
I am in fact using a 3rd-party snippet, whose source is viewable here.
The error I get reads as follows:
E/AndroidRuntime: FATAL EXCEPTION: Thread-556
Process: edu.ucdavis.auditoryenhancer, PID: 31335
com.sun.jna.LastErrorException: [16] Device or resource busy
at com.sun.jna.Native.invokeInt(Native Method)
at com.sun.jna.Function.invoke(Function.java:390)
at com.sun.jna.Function.invoke(Function.java:323)
at com.sun.jna.Library$Handler.invoke(Library.java:236)
at java.lang.reflect.Proxy.invoke(Proxy.java:393)
at biz.source_code.usb.$Proxy0.ioctl(Unknown Source)
at biz.source_code.usb.UsbIso.setInterface(UsbIso.java:414)
My own code that leads up to this error stack is as follows:
// the variable "dev" is an instance of android.hardware.usb.UsbDevice
UsbInterface interface = dev.getInterface(2);
UsbEndpoint endpoint = dev.getEndpoint(0);
UsbDeviceConnection connection = usbMgr.openDevice(dev);
new UsbIso(connection.getFileDescriptor(), 1, endpoint.getMaxPacketSize());
try {
usbIso.setInterface(getInterfaceNumber(), getAlternateSetting());
} catch (IOException e) {
e.printStackTrace();
return false;
}
来源:https://stackoverflow.com/questions/37356148/android-app-device-or-resource-busy-when-accessing-usb-device-via-jna