Library Documentation
© 2011 Travis Lee Robinson. All rights reserved.
Using the Library

Where to begin and how to get started writing your new libusbK based application.

This library is divided into the following sections
USB General (LibK)

General libusbK library functions, defines, and structures.

USB Core (UsbK)

Module for core UsbK device functions.

Device List (LstK)

Module for USB device discovery and enumeration.

Overlapped I/O (OvlK)

Module for USB pipe specific async I/O.

Hotplug Event Notifier (HotK)

Module for USB device notification.

Pipe Stream (StmK)

Module for thread assisted USB pipe streaming transfers.

Advanced ISO (IsoK)

Module for advanced isochronous transfers.

Getting Started

Before you begin, connect your device and use the kList test application to verify one of the Supported Drivers has been properly installed. If kList cannot find your device then refer back to Installation.

There are several examples to help along the way, but the following are meant for user new to the library. These examples show basic library functionality like finding and opening a device:

  1. show-device.c
  2. open-device.c
  3. load-driver-api.c

Writing the code:

  1. Init and Free
    • All modules implement an Init and a Free function for creating and and detroying a handle or context specific to the module.
  2. Handles
  3. Function Returns
    • Nearly all function have a BOOL return type. If a function does not complete as expected it returns FALSE (0). To get extended error information, the user must call the GetLastError() Windows API function. These are very generalized errors, the Windows API/MSDN provides ways to lookup error strings for the extended error number but is advisable not to use them! Instead refer to this documentation under the function that caused the error.
  4. Structure Packing

Building the examples:

  1. Examples should be built from the dev-kit package. If you have not allready downloaded it, get it now.
  2. Choose your compiler/IDE:
    • VStudio 2008: Each example has a project file. All examples are contained within an examples solution.
    • WDK: Each example has a WDK sources file. You can use standard WDK building conventions to build all or a single example.
      • Get and install Windows Driver Kit.
      • Open a build environment command prompt
      • Navigate to the examples folder to build all or the examples project to build one.
      • Execute: build /cegZ
    • Mingw64: Each example has a Mingw64 build script for 32bit or 64bit GCC builds. All examples are contained in a single solution-like build script which can be used to build all or any of the examples.
      • Get and install TDM64-GCC
      • Open a Mingw64 build command prompt.
      • Navigate to the examples folder and execute make:
        • Mingw64 project make syntax:
          make [arch=amd64/x86] [Example name]
        • Mingw64 solution make syntax:
          make [all/multi-all]
        • make builds all 32bit examples.
        • make arch=amd64 builds all 64bit examples.
        • make show-device builds the 32bit show-device example.
        • make multi-all builds all 32bit and 64bit examples.

Running the examples:

The output EXEs will be placed in different locations depending on the compiler/IDE used. Generally they are placed in compiler/IDE default locations.
Most examples are meant to be modifed prior to use. It is not advisabe to run these examples as-is before reviewing the example code. The one exception is if your device is an official Benchmark USB Device.