Ejemplo n.º 1
0
static void OpenUsbDevice()
	{
	CUsbIo::DestroyDeviceList(g_DevList);

	// Enumerate attached USB devices supported by USBIO
	g_DevList = CUsbIo::CreateDeviceList(&g_UsbioID);

	// Open first device in list
	dwRC = g_UsbDev.Open(0, g_DevList, &g_UsbioID);

	PRINT_IF_VERBOSE1("\nCUsbIo::Open returned <0x%X>\n", dwRC);

	if (dwRC == USBIO_ERR_VERSION_MISMATCH)
		{
		printf("\n* Error: \"The API version reported by the USBRFLCT driver\n" \
			   "*         does not match the expected version.\"\n");
		printf("* The driver will need to be updated as follows:\n");
		printf("* 1. Connect the device to the PC & start T_USB,\n" \
			   "* then find the USB device in the Windows Device Manager\n" \
			   "* ('Control Panel'->'System'->'Hardware'->'Device Manager').\n" \
			   "* Right click on the device name and choose 'Uninstall...'.\n");
		printf("* 2. In c:\\winnt\\inf\\, find (by searching for \"Symbian\") and\n" \
			   "* delete the *.INF file that was used to install the existing\n" \
			   "* version of USBRFLCT.SYS. Make sure to also delete the\n" \
			   "* precompiled version of that file (<samename>.PNF).\n");
		printf("* 3. In c:\\winnt\\system32\\drivers\\, delete the file USBRFLCT.SYS.\n");
		printf("* Then unplug & reconnect the USB device and, when prompted, install\n" \
			   "* the new USBRFLCT.SYS driver using the .INF file from this distribution.\n" \
			   "* (All files can be found under e32test\\win32\\usbrflct_distribution\\.)\n");
		}
	}
Ejemplo n.º 2
0
void DVS128Interface::sendVendorRequest(UCHAR req, const char *buf, DWORD bufSize){
    CUsbIo dev;
    DWORD status;
    // open the device
    if(!dev.IsOpen()){
        status = dev.Open(devIndex,devList,&usbIoID);
        if ( status != USBIO_ERR_SUCCESS ) {
            printf("Could not open device: %x",status);
            return;
        }
    }
    printf("Sending Vendor Request: %x\n", req);
    USBIO_CLASS_OR_VENDOR_REQUEST request;
    ZeroMemory(&request,sizeof(request));
    request.Flags = 0;
    request.Type = RequestTypeVendor;
    request.Recipient = RecipientDevice;
    request.RequestTypeReservedBits = 0;
    request.Request = req;
    request.Value = 4;
    request.Index = 0;
    status = dev.ClassOrVendorOutRequest(
                buf,
                bufSize,
                &request
                );
    printf("Status: %x\n",status);
    dev.Close();
}
Ejemplo n.º 3
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);
}
Ejemplo n.º 4
0
void DVS128Interface::startReading(){
    CUsbIo dev;
    USB_DEVICE_DESCRIPTOR devDesc;
    DWORD status;
    bool found = false;

    devList = CUsbIo::CreateDeviceList(&usbIoID);
    if (devList == NULL){
        printf("Unable to build a device list!\n");
    }

    // Open and query usb devices to find the right one
    for (int i = 0; i < 127; i++){
        status = dev.Open(i,devList,&usbIoID);
        if ( status != USBIO_ERR_SUCCESS ) {
            if ( status != USBIO_ERR_NO_SUCH_DEVICE_INSTANCE ){
                fprintf(stdout,"UsbDev.Open returned with error 0x%08X\n",status);
            }
            break;
        }
        // Query device descriptor for comparison with PID and VID
        status = dev.GetDeviceDescriptor(&devDesc);
        if ( status == USBIO_ERR_SUCCESS ){
            found = true;
            if ( devDesc.iSerialNumber!=0 ){
                dev.Close();
                if (devDesc.idVendor == VID && devDesc.idProduct == PID){
                    fprintf(stdout,"Device found, starting reader.\n");
                    devIndex = i;
                    startReaderThread(devIndex);
                    break;
                } else {
                    fprintf(stdout,"Device not recognized\n");
                }
            } else {
                fprintf(stdout,"Querying device descriptor failed, status:0x%08X\n",status);
                dev.Close();
            }
        }

        if ( !found ) {
            fprintf(stdout,"There are no USB devices attached to the USBIO driver.\n");
        }
        else
            fprintf(stdout,"Device found...");
        CUsbIo::DestroyDeviceList(devList);
    }
}