I'm trying to write a driver for Maxim-IC's DS2490 USB to 1-Wire bridge. Windows found the device and LibUsb were able to create an .inf file. The device opens ok and I can get various descriptors from it but won't accept controlMsg writes, it times out. I made the board myself and checked it with Maxims OneWireViewer, wich found it.
This is the exception I get:
ch.ntb.usb.USBTimeoutException: LibusbJava.controlMsg: usb_control_msg: sending
control message failed, win error: The I/O operation has been aborted because of
either a thread exit or an application request.
at ch.ntb.usb.Device.controlMsg(Device.java:552)
at USBTest.main(USBTest.java:28)
Try to use some standard control messages. Have a look at the method ch.ntb.usb.test.DeviceTest.controlMsg() for some examples.
Are you able to write to one of the other endpoints?
Unfortunately I don't have a clue what the reason for the error could be. Maybe you get some more specific info about the error on the libusb-win32 mailing list as this is not related to the Java code.
Hope that helps...
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for your fast reply! I can send bulk data and read the device status using an interrupt read.
Thanks for the tip on the DeviceTest class, I'll check it out!
I signed up on the libusb-win32 mailing list so I'll try there for some more help. Hope I get it to wrok, it's for my engineering thesis :)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I tried copying the GET_STATUS from ch.ntb.usb.test.DeviceTest.controlMsg() and it works! I also tried the board with an external program and it also worked. Still no luck with my own controlMsg tries though :(. Can the reason be that I send some bogus data of length one with the request? The data sheet for the devices says it should be empty but the controlMsg method won't accept an empty array or zero as size for these parameters.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
ch.ntb.usb.USBTimeoutException: LibusbJava.controlMsg: usb_control_msg: sending
control message failed, win error: The I/O operation has been aborted because of
either a thread exit or an application request.
at ch.ntb.usb.Device.controlMsg(Device.java:552)
at USBTest.main(USBTest.java:28)
and i want to read data from USB :(
i don't know what i have to do
how did you do to fix this error ?
thanks
Thierry
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My problem was a bug in the libusbjava library. Specifically in the handling of the send/recieve buffer and length. According to the USB standard, this data is not mandatory, but libusbjava wouldn't accept zero length/no data. I reported it to spandi and got a corrected version, numbered 0.5.6. I don't know when (if) it will be released to the public.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A new version (20080125) with the bugfix is released. Set the length to 0 and use a dummy byte buffer (without dummy byte buffer it would need quite a bit of rewriting of the shared library). I will check in the source code and update the Javadoc shortly.
Regards, Spandi
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello.
I'm trying to write a driver for Maxim-IC's DS2490 USB to 1-Wire bridge. Windows found the device and LibUsb were able to create an .inf file. The device opens ok and I can get various descriptors from it but won't accept controlMsg writes, it times out. I made the board myself and checked it with Maxims OneWireViewer, wich found it.
Thanks in advance for any help!
Here's the code I use:
import javax.swing.SwingUtilities;
import ch.ntb.usb.usbView.*;
import ch.ntb.usb.*;
public class USBTest {
private static final int COMM_CMD = 0x01;
// Bogus data since none needed
private static final byte[] nb = new byte[]{0};
private static boolean debug = true;
public static void main(String[] args) {
Device device = USB.getDevice((short)0x04FA, (short)0x2490);
try {
debug("Opening device");
device.open(1, 0, 3);
device.controlMsg(0x40, COMM_CMD, 0x0843, 0x0, nb, 1, 1000, false);
debug("Closing device");
device.close();
} catch (USBException ue) {
ue.printStackTrace();
}
}
private static void debug(String msg) {
if (debug) System.out.println(msg);
}
}
This is the exception I get:
ch.ntb.usb.USBTimeoutException: LibusbJava.controlMsg: usb_control_msg: sending
control message failed, win error: The I/O operation has been aborted because of
either a thread exit or an application request.
at ch.ntb.usb.Device.controlMsg(Device.java:552)
at USBTest.main(USBTest.java:28)
And here's the output from TestLibUsb:
bus-0/\\.\libusb0-0001--0x04fa-0x2490 04FA/2490
wTotalLength: 129
bNumInterfaces: 1
bConfigurationValue: 1
iConfiguration: 0
bmAttributes: e0h
MaxPower: 50
bInterfaceNumber: 0
bAlternateSetting: 0
bNumEndpoints: 3
bInterfaceClass: 255
bInterfaceSubClass: 255
bInterfaceProtocol: 255
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 32
bInterval: 10
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 02h
bmAttributes: 02h
wMaxPacketSize: 16
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 83h
bmAttributes: 02h
wMaxPacketSize: 16
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 0
bAlternateSetting: 1
bNumEndpoints: 3
bInterfaceClass: 255
bInterfaceSubClass: 255
bInterfaceProtocol: 255
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 32
bInterval: 10
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 02h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 83h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 0
bAlternateSetting: 2
bNumEndpoints: 3
bInterfaceClass: 255
bInterfaceSubClass: 255
bInterfaceProtocol: 255
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 02h
bmAttributes: 02h
wMaxPacketSize: 16
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 83h
bmAttributes: 02h
wMaxPacketSize: 16
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bInterfaceNumber: 0
bAlternateSetting: 3
bNumEndpoints: 3
bInterfaceClass: 255
bInterfaceSubClass: 255
bInterfaceProtocol: 255
iInterface: 0
bEndpointAddress: 81h
bmAttributes: 03h
wMaxPacketSize: 32
bInterval: 1
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 02h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 0
bRefresh: 0
bSynchAddress: 0
bEndpointAddress: 83h
bmAttributes: 02h
wMaxPacketSize: 64
bInterval: 0
bRefresh: 0
bSynchAddress: 0
Hi
Try to use some standard control messages. Have a look at the method ch.ntb.usb.test.DeviceTest.controlMsg() for some examples.
Are you able to write to one of the other endpoints?
Unfortunately I don't have a clue what the reason for the error could be. Maybe you get some more specific info about the error on the libusb-win32 mailing list as this is not related to the Java code.
Hope that helps...
Thanks for your fast reply! I can send bulk data and read the device status using an interrupt read.
Thanks for the tip on the DeviceTest class, I'll check it out!
I signed up on the libusb-win32 mailing list so I'll try there for some more help. Hope I get it to wrok, it's for my engineering thesis :)
Hello again.
I tried copying the GET_STATUS from ch.ntb.usb.test.DeviceTest.controlMsg() and it works! I also tried the board with an external program and it also worked. Still no luck with my own controlMsg tries though :(. Can the reason be that I send some bogus data of length one with the request? The data sheet for the devices says it should be empty but the controlMsg method won't accept an empty array or zero as size for these parameters.
hello
i have the same error
ch.ntb.usb.USBTimeoutException: LibusbJava.controlMsg: usb_control_msg: sending
control message failed, win error: The I/O operation has been aborted because of
either a thread exit or an application request.
at ch.ntb.usb.Device.controlMsg(Device.java:552)
at USBTest.main(USBTest.java:28)
and i want to read data from USB :(
i don't know what i have to do
how did you do to fix this error ?
thanks
Thierry
My problem was a bug in the libusbjava library. Specifically in the handling of the send/recieve buffer and length. According to the USB standard, this data is not mandatory, but libusbjava wouldn't accept zero length/no data. I reported it to spandi and got a corrected version, numbered 0.5.6. I don't know when (if) it will be released to the public.
Hi
A new version (20080125) with the bugfix is released. Set the length to 0 and use a dummy byte buffer (without dummy byte buffer it would need quite a bit of rewriting of the shared library). I will check in the source code and update the Javadoc shortly.
Regards, Spandi