0

I am trying to send raw data to a set lights from my computer through a USB to DMX512 interface using libusb-win32. So far everything seems to be working well, except for some reason the program doesn't recognize any endpoints on the adapter. Here is a snippet of my code:

// initialize
usb_init();
usb_find_busses();
usb_find_devices();
usb_bus busses = *usb_get_busses();

// open the device
struct usb_device *dev = busses.devices;
usb_dev_handle *h = usb_open(dev);
usb_claim_interface(h, 0);

...

// close the device
usb_release_interface(h, 0);
usb_close(h);

When I look through the structs in the debugger, this is the data within them:

dev {

    next          //<NULL>
    prev          //<NULL>
    filename      //0x008a9938
    bus           //0x008a9710
    descriptor    //{bLength = 18 ... }
    config {

        bLength              //9
        bDescriptorType      //2
        wTotalLength         //18
        bNumInterfaces       //1
        bConfigurationValue  //1
        iConfiguration       //0
        bmAttributes         //128
        MaxPower             //250
        interface {

            altsetting {

                bLength             //9
                bDescriptorType     //4
                bInterfaceNumber    //0
                bAlternateSetting   //0
                bNumEndpoints       //0
                bInterfaceClass     //0
                bInterfaceSubClass  //0
                bInterfaceProtocol  //0
                iInterface          //0
                endpoint            //<NULL>
                extra               //<NULL>
                extralen            //0
            }
            num_altsetting   //1
        }
        extra                //<NULL>
        extralen             //0
    }
    dev           //<NULL>
    devnum        //1
    num_children  //0
    children      //<NULL>
}

As can be seen, there are no endpoints recognized, and on top of that there is only one device, one configuration, one interface, and one altsetting which is why I am at a dead end.

So I am trying to figure out what endpoint address to use for writing to the USB, or if it's possible that the adapter I have is just not compatible with this library.

Thanks in advance

2 Answers2

1

This simply means that you are limited to communication over control transfer on endpoint 0x00. Every device has to have an endpoint 0 and accept control transfer through this endpoint (because this is the endpoint the host controller will talk to to enumerate or configure a device). Control transfers can read and write on one endpoint.

Don't you have any description on how to control this device or any sniffed usb transfers? Figuring out all the data to use control transfer by random testing will take a long time. ;)

dryman
  • 660
  • 6
  • 16
  • I've mostly been hoping that [this](https://www.enttec.com/docs/rs232_spec.pdf) DMX communications protocol would work for my interface, the only problem is I'm not really sure how universal this protocol is. – Thomas Jansen Jun 10 '16 at 15:16
  • This describes a protocol for serial communication. Is there no serial driver for your device available? Using a com port is much easier than doing all the usb stuff a serial-to-usb device does. – dryman Jun 13 '16 at 13:31
  • I'm not exactly sure what you mean, is there software that allows me to interact with the USB as if it were a COM port? Because all I have is a device that kind of looks like [this](http://www.anyma.ch/wordpress/wp-content/wp_imgs/research/udmx5pin.png) – Thomas Jansen Jun 14 '16 at 15:44
  • At least the protocol you mentioned is working like that. Yes there is such software and most manufactures provide one. But it is not generic you need the one the manufacturer of your device provides if any. You can try to achieve results with libusb but I doubt anyone can guess the needed information in a short amount of time. The problem is the huge (not exaggerated) lack of information. You have two choices: Find a driver and corresponding manual of the manufacturer or implement your own driver which may take forever, except you have documentation (which only the manufacturer can provide). – dryman Jun 14 '16 at 16:01
  • If I were inclined to try and send the raw data myself through libusb, how would you suggest I do it? Should I use usb_control_msg(), and if so what kind of request would it be? – Thomas Jansen Jun 14 '16 at 17:43
  • Just as a follow up, I did end up getting it to work. I just had to use the following line of code: – Thomas Jansen Jun 16 '16 at 18:51
  • Congratulations. :) I don't know DMX interfaces really well so I had no idea how to set the values but if it was easy to guess for you thats good. Have fun with the device. – dryman Jun 17 '16 at 07:04
0

Just as a follow up I did manage to get the lights working. Dryman was correct in the fact that I had to use control transfer over endpoint 0x00. I actually didn't even need to claim the interface as I did in my example code for the question. It really just came down to using the following line of code:

usb_control_msg(h, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, cmd_SetSingleChannel, value, channel, buffer, sizeof(buffer), 5000);

Where h is my device handle, cmd_SetSingleChannel is an integer with value 1, value is an integer that represents the the value of the channel that you are setting, channel is an integer that represents which channel you are setting, and buffer is an empty char array of size 8.

  • Since things like claiming an interface and configuring the device also work over control transfer on endpoint 0x00 you don't have to do any thing to use it but the bus _may_ be a little bit faster after configuring and claiming but I don't think that matters with the size of the data you have to send. – dryman Jun 17 '16 at 07:04