예제 #1
0
void DVS128Interface::startReaderThread(int devIndex){
    CUsbIo dev; //Device instance
    USBIO_SET_CONFIGURATION config; // Device config
    DWORD status;

    // open the device
    status = dev.Open(devIndex,devList,&usbIoID);
    if ( status != USBIO_ERR_SUCCESS ) {
        printf("Could not open device: %x\n",status);
        return;
    }

    // set up the configuration request
    ZeroMemory(&config,sizeof(config));

    config.ConfigurationIndex = CFG_INDEX;
    config.NbOfInterfaces = CFG_NUM_INTERFACES;
    config.InterfaceList[0].InterfaceIndex = CFG_INTERFACE;
    config.InterfaceList[0].AlternateSettingIndex = CFG_ALTSETTING;
    config.InterfaceList[0].MaximumTransferSize = CFG_MAX_TRANSFER;
    // configure the device
    printf("Configuring...\n");
    status = dev.SetConfiguration(&config);
    if ( status != USBIO_ERR_SUCCESS ) {
        printf("Could not configure device: %x\n",status);
        return;
    }

    status = reader->Bind(devIndex,ENDPOINT,devList,&usbIoID);
    if ( status != USBIO_ERR_SUCCESS ) {
        printf("Binding failed.\n");
        dev.UnconfigureDevice();
        return;
    }

    if ( !reader->AllocateBuffers(ENDPOINT_FIFO_SIZE, NUM_BUFFERS) ) {
        printf("Unable to allocate buffer pool.\n");
        dev.UnconfigureDevice();
        return;
    }
    // start the reader thread
    printf("Starting reader thread...\n");
    if ( !reader->StartThread() ) {
        printf("Unable to start reader thread.\n");
        dev.UnconfigureDevice();
        return;
    }

    sendVendorRequest(START_READ);
}
예제 #2
0
static void SetConfiguration()
	{
	USBIO_SET_CONFIGURATION SetConfig;

	memset(&SetConfig, 0, sizeof(USBIO_SET_CONFIGURATION));

	// Set the first configuration as active
	SetConfig.ConfigurationIndex = 0;
	SetConfig.NbOfInterfaces = 1;
	SetConfig.InterfaceList[0].InterfaceIndex = 0;
	SetConfig.InterfaceList[0].AlternateSettingIndex = 0;
	SetConfig.InterfaceList[0].MaximumTransferSize = KBufferSize;
	dwRC = g_UsbDev.SetConfiguration(&SetConfig);
	PRINT_IF_VERBOSE1("CUsbIo::SetConfiguration returned <0x%X>\n", dwRC);
	}