Menu

Can't send control message

Help
2013-02-02
2013-02-02
  • Wnt2bsleepin

    Wnt2bsleepin - 2013-02-02

    I am new to USB and am trying to communicate with a dongle. So far, the only endpoint that is showing is 0x81, which is apparently an in only. I am trying to send it a status request.

    byte[] data= new byte[]{0,0,0,0}; 
            //Data to read from device
            byte[] readData = new byte[data.length];
    
            dev.open(1, 0, 0);
            int altInterface = dev.getAltinterface();
            int mainInterface = dev.getInterface();
            int maxPacketSize = dev.getMaxPacketSize();
    
            System.out.println("Main Interface: " + mainInterface + "\nAlternate   Interface: " + altInterface + " \nMax Packet Size: " + maxPacketSize);
    
              dev.controlMsg(USB.REQ_TYPE_RECIP_DEVICE,USB.REQ_GET_STATUS,0,0,data,0,2000,false);
    
            //dev.writeBulk(0x81, data,  data.length, 2000, false);
    
            dev.readBulk(0x81, readData, readData.length, 2000, false);
    
            logData(readData);
    
            dev.close();
    

    Here are the details on the device.

    Usb_Bus bus-0
    Usb_Device \\.\libusb0-0001--0x0bda-0x2838
        Usb_Device_Descriptor idVendor: 0xbda, idProduct: 0x2838
        Usb_Config_Descriptor bNumInterfaces: 0x1
            Usb_Interface num_altsetting: 0x1
                Usb_Interface_Descriptor bNumEndpoints: 0x1
                    Usb_Endpoint_Descriptor bEndpointAddress: 0x81
    

    Any help is much appreciated.

     
  • uniederer

    uniederer - 2013-02-02

    What happens if you send this control message? Error messages? Exceptions?

     
  • Wnt2bsleepin

    Wnt2bsleepin - 2013-02-02

    Yes, it throws an exception.

    ch.ntb.usb.USBException: LibusbJava.controlMsg: libusb0-dll:err [control_msg] sending control message failed, win error: The parameter is incorrect.
    

    The specific line is

    dev.controlMsg(USB.REQ_TYPE_DIR_HOST_TO_DEVICE,USB.REQ_GET_STATUS,0,0,data,0,2000,false);
    

    I also followed this guide to determine what to send for the Get-Status request.

     

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.