HID Test Application for Visual Basic .NET
Project: usbhidio
Version: 2.0
Date: 7/1/04
Purpose:
Demonstrates USB communications with a HID-class device
Description:
Finds an attached device that matches the vendor and product IDs in the forms
text boxes.
Retrieves the devices capabilities.
Sends and requests HID reports.
Uses RegisterDeviceNotification()
and WM_DEVICE_CHANGE messages
to detect when a device is attached or removed.
The RegisterDeviceNotification code doesn't work under Windows 98.
A list box displays the data sent and received, along with error and status messages.
Combo boxes select data to send, and 1-time or timed, periodic transfers.
You can change the size
of the hosts Input report buffer and request to use control
transfers only to exchange Input and Output reports.
To view additional debugging
messages, in the Visual Studio development environment,
select the Debug build (Build > Configuration Manager > Active Solution
Configuration)
and view the Output window (View > Other Windows > Output)
The application uses a
Delegate and the BeginInvoke and EndInvoke methods to read
from the device asynchronously.
If you want to only receive
data or only send data, comment out the unwanted code
(the "Success = " line and the "If Success" block that
follows it).
This project includes
the following modules:
frmMain.vb - routines specific to the form.
Hid.vb - routines specific to HID communications.
DeviceManagement.vb - routines for obtaining a handle to a device from its
GUID
and receiving device notifications. This routines are not specific to HIDs.
Debugging.vb - contains a routine for displaying API error messages.
HidDeclarations.vb - Declarations
for API functions used by Hid.vb.
FileIODeclarations.vb - Declarations for file-related API functions.
DeviceManagementDeclarations.vb - Declarations for API functions used by DeviceManagement.vb.
DebuggingDeclarations.vb - Declarations for API functions used by Debugging.vb.
Companion device firmware
for several device CPUs is available from www.Lvr.com/hidpage.htm.
You can use any generic HID (not a system mouse or keyboard) that sends and
receives reports.
This application has been tested under Windows 98SE, Windows 2000, and Windows XP.
For more information about
HIDs and USB, and additional example device firmware to use
with this application, visit Lakeview Research at http://www.Lvr.com .
Send comments, bug reports, etc. to jan@Lvr.com .