On 10/3/2012 12:56 PM, Xiaofan Chen wrote:
On Wed, Oct 3, 2012 at 6:42 PM, Ramon Zambelli
<ramon.zambe...@bluewin.ch> wrote:
I'm trying to update my project which uses libusbx 1.0.12 to 1.0.14 but I'm
experiencing some problem which where not present before. For instance in my
application I'm discovering all the devices with a known VID PID, opening
them to read some more information and then closing them again.
After discovering is done I try to open the device again but using the
latest version of libusbx I get LIBUSB_ERROR_ACCESS. It seams that the close
is not performed correctly. Below the trace log:
Maybe you want to post the codes corresponding to your debug log
as well.
And your debug does not seem to show the error.
Reducing the debug level to LIBUSB_LOG_LEVEL_INFO****I get those message
logs:
libusbx: info [cache_config_descriptors] could not access configuration
descriptor (dummy) for '\\.\USB#VID_058F&PID_6254#7&132A1C36&0&2': [31]
A device attached to the system is not functioning.
libusbx: info [cache_config_descriptors] could not access configuration
descriptor (dummy) for '\\.\USB#VID_058F&PID_6254#7&132A1C36&0&3': [31]
A device attached to the system is not functioning.
libusbx: error [winusbx_open] could not open device
\\.\USB#VID_1FC9&PID_7701#6&CFD999F&0&2#{A5DCBF10-6530-11D2-901F-00C04FB951ED}
(interface 0): [5] Access is denied.
As for my code, it is written in JAVA and used JNA to acces the dll.
Below is the function causing the problem. The first time a call the
function the function everithing works, while the second time I get the
error when I try to open the device.
static public void discover(List<IDiscoverCu> listeners) {
int r;
if (sRefCtx == null) {
sRefCtx = new PointerByReference();
r = Libusb.libusb_init(sRefCtx);
if (r != 0) {
return;
}
}
Libusb.libusb_set_debug(sRefCtx.getValue(), 3);
PointerByReference refDevices = new PointerByReference();
int count = Libusb.libusb_get_device_list(sRefCtx.getValue(),
refDevices);
Pointer[] devices = refDevices.getValue().getPointerArray(0,
count);
for (Pointer device : devices) {
UsbDeviceDescriptor descriptor = new UsbDeviceDescriptor();
r = Libusb.libusb_get_device_descriptor(device, descriptor);
if (r != 0) {
continue;
}
if ((descriptor.idVendor == 0x1FC9) &&
(descriptor.idProduct == 0x7701)) {
PointerByReference refHandle = new PointerByReference();
r = Libusb.libusb_open(device,
refHandle);//LIBUSB_ERROR_ACCESS on second call
if (r != 0) {
continue;
}
r =
Libusb.libusb_set_configuration(refHandle.getValue(), 1);
if (r != 0) {
Libusb.libusb_close(refHandle.getValue());
continue;
}
r = Libusb.libusb_claim_interface(refHandle.getValue(), 0);
if (r != 0) {
Libusb.libusb_close(refHandle.getValue());
continue;
}
ComPacket pkt = new ComPacket(CMD.CMD_DISCOVER_CU);
IntByReference len = new IntByReference();
byte[] rxData = new byte[64];
ComPacket pktReset = new
ComPacket(CMD.CMD_RESET_CONNECTION);
r = sendData(refHandle.getValue(),
ByteBuffer.wrap(pktReset.getBuffer()), pktReset.getBuffer().length, len,
100);
if (r != 0) {
sLog.log(Level.INFO, "Reset connection error: " + pkt);
Libusb.libusb_close(refHandle.getValue());
continue;
}
// Remove any remaining segment remained from previous
session
while (recvData(refHandle.getValue(),
ByteBuffer.wrap(rxData), rxData.length, len, 100) == 0) {
sLog.log(Level.INFO, "Dirty segment, len: " +
len.getValue() + ", bytes: " + DataConvert.u8ArrayToHexString(rxData, 0,
len.getValue()));
}
r = sendData(refHandle.getValue(),
ByteBuffer.wrap(pkt.getBuffer()), pkt.getBuffer().length, len, 1000);
if (r != 0) {
Libusb.libusb_close(refHandle.getValue());
continue;
}
sLog.log(Level.FINE, "Sent " + len.getValue() + "bytes: ");
r = recvData(refHandle.getValue(),
ByteBuffer.wrap(rxData), rxData.length, len, 100);
Libusb.libusb_close(refHandle.getValue());
sLog.log(Level.FINE, "Recv " + len.getValue() + "bytes: ");
if (r == 0 && len.getValue() > 0) {
DiscoverDescriptor desc = new DiscoverDescriptor();
desc.initFromByteBuffer(rxData, 4);
for (IDiscoverCu listener : listeners) {
listener.onDiscoverCuFound(new ComUsb(desc,
device));
}
}
}
}
}
Hope this helps.
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel