#include <stdio.h>
#include <stdlib.h>
#include <libusb-1.0/libusb.h>

uint8_t g_data[0x583E0];

void error(char* s, int err) {
    if(err) {
        fprintf(stderr, "%s Error: %s\n", s, libusb_error_name(err));
        exit(err);
    }
}

int main(int argc, char *argv[]) {
    libusb_device_handle* dev;
    libusb_init(NULL);
    int err;
    int transfer_size = 0;
    dev = libusb_open_device_with_vid_pid(NULL, 0x1111, 0x2222);
    if(dev == NULL) {
        fprintf(stderr, "Device not found, exiting\n");
        return -1;
    }

    //err = libusb_set_configuration(dev, 1);
    //if( err )
    //    fprintf(stderr, "Cannot set configuration\n");

    err = libusb_claim_interface(dev, 0);
    error("Cannot claim interface", err);

    //err = libusb_set_interface_alt_setting(dev, 0);
    //error("Cannot set alternate setting", err);

    err = libusb_bulk_transfer(dev, LIBUSB_ENDPOINT_IN | 0x02, g_data,  sizeof(g_data), &transfer_size, 1000);
    error("Bulk IN failed!", err);

    printf("transfer size: %x\n", transfer_size);

}
