5.2. DriverWizard Walkthrough

To use DriverWizard, follow these steps:

  1. Attach your hardware to the computer:
    Attach your device to a USB port on your computer.
  2. Run DriverWizard and select your device:
    1. Start DriverWizard — <path to WinDriver>/wizard/wdwizard. On Windows you can also run DriverWizard from the Start menu: Start | Programs | WinDriver | DriverWizard.
      On Windows 7 and higher you must run DriverWizard as administrator.
    2. Click New host driver project to start a new project.

      Figure 5.1. Create a New Driver Project

      Create a New Driver Project

    3. Select your device from the list of devices detected by DriverWizard.

      Figure 5.2. Select Your Device

      Select Your Device

  3. Generate and install an INF file for your device [Windows]:
    On the supported Windows operating systems, the driver for Plug-and-Play devices (such as USB) is installed by installing an INF file for the device. DriverWizard enables you to generate an INF file that registers your device to work with WinDriver (i.e., with the windrvr1260.sys driver). The INF file generated by DriverWizard should later be distributed to your Windows customers, and installed on their PCs.
    The INF file that you generate in this step is also designed to enable DriverWizard to diagnose Plug-and-Play devices on Windows. Additional information concerning the need for an INF file is provided in Section 11.1.1.

    If you don't need to generate and install an INF file, skip this step.

    To generate and install the INF file with DriverWizard, do the following:

    1. In the Select Your Device screen (see Step 2), click the Generate .INF file button or click Next.
    2. DriverWizard will display information detected for your device — Vendor ID, Product ID, Device Class, manufacturer name and device name — and allow you to modify this information

      Figure 5.3. DriverWizard INF File Information

      DriverWizard INF File Information

    3. For multiple-interface USB devices, you can select to generate an INF file either for the composite device or for a specific interface.
      • When selecting to generate an INF file for a specific interface of a multi-interface USB device the INF information dialogue will indicate for which interface the INF file is generated.

        Figure 5.4. DriverWizard Multi-Interface INF File Information — Specific Interface

        DriverWizard Multi-Interface INF File Information — Specific Interface

      • When selecting to generate an INF file for a composite device of a multi-interface USB device, the INF information dialogue provides you with the option to either generate an INF file for the root device itself, or generate an INF file for specific interfaces, which you can select from the dialogue.
        Selecting to generate an INF file for the root device will enable you to handle multiple active interfaces simultaneously.

        Figure 5.5. DriverWizard Multi-Interface INF File Information — Composite Device

        DriverWizard Multi-Interface INF File Information — Composite Device

    4. When you are done, click Next and choose the directory in which you wish to store the generated INF file. DriverWizard will then automatically generate the INF file for you.

      You can choose to automatically install the INF file by checking the Automatically Install the INF file option in the DriverWizard's INF generation dialogue.
      If the automatic INF file installation fails, DriverWizard will notify you and provide manual installation instructions (refer also the manual INF file installation instructions in Section 11.1).

    5. When the INF file installation completes, select and open your device from the list in the Select Your Device screen.

  4. Uninstall the INF file of your device [Windows]:
    On Windows, you can use DriverWizard to uninstall a previously installed device INF file. This will unregister the device from its current driver and delete the copy of the INF file in the Windows INF directory.

    In order for WinDriver to correctly identify the resouces of a USB device and communicate with it — including for the purpose of the DriverWizard device diagnostics outlined in the next step — the deivce must be registered to work with WinDriver via an INF file (see Step 3).

    If you do not wish to uninstall an INF file, skip this step.

    To uninstall the INF file, do the following:

    1. In the Select Your Device screen (see Step 2), click the Uninstall .INF file button.
    2. Select the INF file to be removed.

  5. Select the desired alternate setting:

    Figure 5.6. Select Device Interface

    Select Device Interface

    DriverWizard detects all the device's supported alternate settings and displays them, as demonstrated in Figure 5.6 below.
    Select the desired alternate setting from the displayed list.

    DriverWizard will display the pipes information for the selected alternate setting.

    For USB devices with only one alternate setting configured, DriverWizard automatically selects the detected alternate setting and therefore the Select Device Interface dialogue will not be displayed.
  6. Diagnose your device:
    Before writing your device driver, it is important to make sure your hardware is working as expected. Use DriverWizard to diagnose your hardware. All of your activity will be logged in the DriverWizard log so that you may later analyze your tests:
    1. Test your USB device's pipes: DriverWizard shows the pipes detected for the selected alternate setting. To perform USB data transfers on the pipes, follow these steps:
      1. Select the desired pipe.
      2. For a control pipe (a bidirectional pipe), click Read / Write. A new dialogue will appear, allowing you to select a standard USB request or define a custom request, as demonstrated in Figure 5.7.

        Figure 5.7. USB Control Transfers

        USB Control Transfers

        When you select one of the available standard USB requests, the setup packet information for the selected request is automatically filled and the request description is displayed in the Request Description box.

        For a custom request, you are required to enter the setup packet information and write data (if exists) yourself. The size of the setup packet should be eight bytes and it should be defined using little endian byte ordering. The setup packet information should conform to the USB specification parameters (bmRequestType, bRequest, wValue, wIndex, wLength).

        More detailed information on the standard USB requests, on how to implement the control transfer and how to send setup packets can be found in Section 8.2.
      3. For an input pipe (moves data from device to host) click Listen to Pipe. To successfully accomplish this operation with devices other than HID, you need to first verify that the device sends data to the host. If no data is sent after listening for a short period of time, DriverWizard will notify you that the Transfer Failed.

        To stop reading, click Stop Listen to Pipe.

        Figure 5.8. Listen to Pipe

        Listen to Pipe

      4. For an output pipe (moves data from host to device), click Write to Pipe. A new dialogue box will appear asking you to enter the data to write. The DriverWizard log will contain the result of the operation.

        Figure 5.9. Write to Pipe

        Write to Pipe

      5. You can reset input and output pipes by pressing the Reset Pipe button for the selected pipe.
  7. Generate the skeletal driver code:
    1. Select to generate code either via the Generate Code toolbar icon or from the Project | Generate Code menu.
    2. In the Select Code Generation Options dialogue box that will appear, choose the code language and development environment(s) for the generated code and select Next to generate the code.

      Figure 5.10. Code Generation Options

      Code Generation Options

    3. Save your project (if required) and click OK to open your development environment with the generated driver.
    4. Close DriverWizard.
  8. Compile and run the generated code:

    • Use this code as a starting point for your device driver. Modify where needed to perform your driver's specific functionality.
    • The source code DriverWizard creates can be compiled with any 32-bit compiler, and will run on all supported platforms without modification.

    For detailed compilation instructions, refer to Section 5.2.2.

5.2.1. Automatic Code Generation

After you have finished diagnosing your device and have ensured that it runs according to your specifications, you are ready to write your driver. Generating the Code

Generate code by selecting this option either via DriverWizard's Generate Code toolbar icon or from the wizard's Project | Generate Code menu (see Section 5.2, Step 7). DriverWizard will generate the source code for your driver. The files are saved in a directory DriverWizard creates for every development environment and operating system selected in the code generation dialogue. The Generated USB C Code

In the source code directory you now have a new xxx_diag.c source file (where xxx is the name you selected for your DriverWizard project). This file implements a diagnostic USB application, which demonstrates how to use WinDriver's USB API to locate and communicate with your USB device(s), including detection of Plug-and-Play events (device insertion/removal, etc.), performing read/write transfers on the pipes, resetting the pipes and changing the device's active alternate setting.
The generated application supports handling of multiple identical USB devices.

5.2.2. Compiling the Generated Code Windows Compilation

As explained above, on Windows you can select to generate project, solution, and make files for the supported compilers and development environments — MS Visual Studio, Windows GCC (MinGW/Cygwin).
For integrated development environments (IDEs), such as MS Visual Studio, you can also select to automatically invoke your selected IDE from the wizard. You can then proceed to immediately build and run the code from your selected IDE.

You can also build the generated code using any other compiler or development environment that supports the selected code language and target OS. Simply create a new project or make file for your selected compiler/environment, include the generated source files, and run the code.

  • For Windows, the generated compiler/environment files are located under an x86 directory — for 32-bit projects — or an amd64 directory — for 64-bit projects. Linux Compilation

Use the makefile that was created for you by DriverWizard in order to build the generated code using your favorite compiler, preferably GCC.