Im having issues with this line of code. I was able to successfully open the device and send .
Sending:
retCode = LibUsb.bulkTransfer(devHandle, endpointSend, buf, iBuf, timeout);
Receiving:
retCode = LibUsb.bulkTransfer(devHandle, endpointReceive, messageBuf, iBuf, timeout);
logger.debug("Receiving Message Status: "+retCode);
Output:
For Sending, I got a response of 0 but in receiving, I got -7.
Receiving Message Status: -7
libusb: error [init_device] program assertion failed: device address collision with root hub
Other logs
receiveMessage messageBuf: java.nio.DirectByteBuffer[pos=0 lim=1000 cap=1000]
receiveMessage iBuf: java.nio.HeapIntBuffer[pos=1 lim=1 cap=1]
References searched:
http://usb4java.org/apidocs/constant-values.html#org.usb4java.LibUsb.ERROR_TIMEOUT
public static final int ERROR_PIPE -9
public static final int ERROR_TIMEOUT -7
sometimes it is -9 when I disconnect and connect the device but usually -7. Since I have been playing with the timeout for a while now, I'm beginning to suspect that it is about the pipe. How do I resolve a -9 Error Code?
sometimes it is -9 when I disconnect
Should always be -9, as a disconnect clears the USB handle inside the kernel.
For Sending, I got a response of 0 but in receiving, I got -7.
That is the regular ERROR_TIMEOUT
, which may or may not be an error at all.
The basic meaning is just: The USB device did not send any data on the endpoint during the timeout
period.
In the (example) case of an USB2UART chip, the ERROR_TIMEOUT
would just mean that there were no bytes received on the UART RX line.
Fun fact: LibUsb.bulkTransfer() can receive zero bytes from a USB device, and would not return an error code in this case. USB bulk endpoints actually allow that (and it is different from the "no data at all" case).