0

I want to send a single package to an USB device (Arduino controller) using Usb4Java's Low-Level API but I receive following error:

 org.usb4java.LibUsbException: USB error 9: Pipe error

Here is the code for the critical part:

            ByteBuffer buffer = ByteBuffer.allocateDirect(8);
            buffer.put(new byte[] {'a', 'b', 'c'});
            int transfered = LibUsb.controlTransfer(handle,
                    (byte) (LibUsb.REQUEST_TYPE_CLASS | LibUsb.RECIPIENT_INTERFACE),
                    (byte) 0x09,
                    (short) 256,
                    (short) 0,
                    buffer,
                    1000);
            System.out.println(transfered);
            if (transfered < 0){
                throw new LibUsbException("Control transfer failed", transfered);

I think it could be driver-related or related to the parameters of LibUsb.controlTransfer(...); Maybe it's worth mentioning:The source machine is running Windows 7.

Bastian
  • 1,553
  • 13
  • 33
  • Which driver backend do you use? – dryman Sep 13 '16 at 07:32
  • I used Zadig 2.2 to modify the driver. – Bastian Sep 13 '16 at 07:34
  • OK that should work in general. Are you sure the control transfer you send is correct? The libusb API says following: "LIBUSB_ERROR_PIPE if the control request was not supported by the device". Looks like the control transfer you try to send is not supported. – dryman Sep 13 '16 at 07:38
  • Could you please give me some suggestions on how to tackle the problem or how to determine the which control transfers are supported by the device? – Bastian Sep 13 '16 at 07:39
  • Sry but this is device dependent and I don't know much about these devices. You have to consider these are USB-Serial Converters. I can tell you that most of them are a pain in lower body parts to work low level with. And since arduinos are build with quite a few different of them (even China 10 cent hardware) dependent on how much money you spend for the Arduino I honestly and personally would avoid it. What do you want to accomplish by using libusb with Arduino? – dryman Sep 13 '16 at 08:02
  • Thank you for your information! I need to send just basic comma-seperated strings from a desktop application to the arduino. The arduino then processes these this strings to trigger some lights. Well, it's not the cheapst one but I honestly have no clue how to determine which operations are supported and which are not. – Bastian Sep 13 '16 at 08:05
  • Why use libusb instead of the COM Port? Your best bet if you want to use libusb is sniffing the communication while using the Virtual COM Port with the original driver and than building the same behaviour with libusb. Guessing all the commands right without any beforehand knowledge is like winning the lottery. – dryman Sep 13 '16 at 08:10
  • The problem is that all COM ports of the system are occupied by other devices. You are right! I'll try to find some more informations! Thnak you very much! – Bastian Sep 13 '16 at 08:15
  • I never thought this would be possible but theres always a first time hearing from something. You are welcome. – dryman Sep 13 '16 at 08:36
  • I will just enter the answer from the beginning as real answer. – dryman Sep 13 '16 at 08:37

1 Answers1

1

The libusb API says following about errors in control transfer:

"LIBUSB_ERROR_PIPE if the control request was not supported by the device"

Looks like the control transfer you try to send is not supported. Maybe this is not what the controller expects as command.

dryman
  • 660
  • 6
  • 16