Menu

Error during controlMsg

Help
Tompps
2007-10-31
2012-12-06
  • Tompps

    Tompps - 2007-10-31

    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

     
    • andi

      andi - 2007-10-31

      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...

       
    • Tompps

      Tompps - 2007-11-01

      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 :)

       
    • Tompps

      Tompps - 2007-11-02

      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.

       
    • poutsjr kiki

      poutsjr kiki - 2008-01-25

      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

       
      • Tompps

        Tompps - 2008-01-25

        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.

         
    • andi

      andi - 2008-01-25

      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

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.