Thomas Jansen
Thomas Jansen

Reputation: 1

Using libusb-win32 to communicate with USB to DMX512 interface, can't find any endpoints

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

Upvotes: 0

Views: 944

Answers (2)

Thomas Jansen
Thomas Jansen

Reputation: 1

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.

Upvotes: 0

dryman
dryman

Reputation: 660

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

Upvotes: 1

Related Questions