readme.txt
author sl
Wed, 14 May 2014 07:52:21 +0200
changeset 0 316364bd7d25
permissions -rw-r--r--
First drop from janaxelson.com
     1 	///<summary>
     2 	/// Project: GenericHid
     3 	/// 
     4 	/// ***********************************************************************
     5 	/// Software License Agreement
     6 	///
     7 	/// Licensor grants any person obtaining a copy of this software ("You") 
     8 	/// a worldwide, royalty-free, non-exclusive license, for the duration of 
     9 	/// the copyright, free of charge, to store and execute the Software in a 
    10 	/// computer system and to incorporate the Software or any portion of it 
    11 	/// in computer programs You write.   
    12 	/// 
    13 	/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    14 	/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    15 	/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    16 	/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    17 	/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    18 	/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    19 	/// THE SOFTWARE.
    20 	/// ***********************************************************************
    21 	/// 
    22 	/// Author             
    23 	/// Jan Axelson        
    24 	/// 
    25 	/// This software was written using Visual Studio Express 2012 for Windows
    26 	/// Desktop building for the .NET Framework v4.5.
    27 	/// 
    28 	/// Purpose: 
    29 	/// Demonstrates USB communications with a generic HID-class device
    30 	/// 
    31 	/// Requirements:
    32 	/// Windows Vista or later and an attached USB generic Human Interface Device (HID).
    33 	/// (Does not run on Windows XP or earlier because .NET Framework 4.5 will not install on these OSes.) 
    34 	/// 
    35 	/// Description:
    36 	/// Finds an attached device that matches the vendor and product IDs in the form's 
    37 	/// text boxes.
    38 	/// 
    39 	/// Retrieves the device's capabilities.
    40 	/// Sends and requests HID reports.
    41 	/// 
    42 	/// Uses the System.Management class and Windows Management Instrumentation (WMI) to detect 
    43 	/// when a device is attached or removed.
    44 	/// 
    45 	/// A list box displays the data sent and received along with error and status messages.
    46 	/// You can select data to send and 1-time or periodic transfers.
    47 	/// 
    48 	/// You can change the size of the host's Input report buffer and request to use control
    49 	/// transfers only to exchange Input and Output reports.
    50 	/// 
    51 	/// To view additional debugging messages, in the Visual Studio development environment,
    52 	/// from the main menu, select Build > Configuration Manager > Active Solution Configuration 
    53 	/// and select Configuration > Debug and from the main menu, select View > Output.
    54 	/// 
    55 	/// The application uses asynchronous FileStreams to read Input reports and write Output 
    56 	/// reports so the application's main thread doesn't have to wait for the device to retrieve a 
    57 	/// report when the HID driver's buffer is empty or send a report when the device's endpoint is busy. 
    58 	/// 
    59 	/// For code that finds a device and opens handles to it, see the FindTheHid routine in frmMain.cs.
    60 	/// For code that reads from the device, see GetInputReportViaInterruptTransfer, 
    61 	/// GetInputReportViaControlTransfer, and GetFeatureReport in Hid.cs.
    62 	/// For code that writes to the device, see SendInputReportViaInterruptTransfer, 
    63 	/// SendInputReportViaControlTransfer, and SendFeatureReport in Hid.cs.
    64 	/// 
    65 	/// This project includes the following modules:
    66 	/// 
    67 	/// GenericHid.cs - runs the application.
    68 	/// FrmMain.cs - routines specific to the form.
    69 	/// Hid.cs - routines specific to HID communications.
    70 	/// DeviceManagement.cs - routine for obtaining a handle to a device from its GUID.
    71 	/// Debugging.cs - contains a routine for displaying API error messages.
    72 	/// HidDeclarations.cs - Declarations for API functions used by Hid.cs.
    73 	/// FileIODeclarations.cs - Declarations for file-related API functions.
    74 	/// DeviceManagementDeclarations.cs - Declarations for API functions used by DeviceManagement.cs.
    75 	/// DebuggingDeclarations.cs - Declarations for API functions used by Debugging.cs.
    76 	/// 
    77 	/// Companion device firmware for several device CPUs is available from www.Lvr.com/hidpage.htm
    78 	/// You can use any generic HID (not a system mouse or keyboard) that sends and receives reports.
    79 	/// This application will not detect or communicate with non-HID-class devices.
    80 	/// 
    81 	/// For more information about HIDs and USB, and additional example device firmware to use
    82 	/// with this application, visit Lakeview Research at http://Lvr.com 
    83 	/// Send comments, bug reports, etc. to jan@Lvr.com or post on my PORTS forum: http://www.lvr.com/forum 
    84 	/// 
    85 	/// V6.2
    86 	/// 11/12/13
    87 	/// Disabled form buttons when a transfer is in progress.
    88 	/// Other minor edits for clarity and readability.
    89 	/// Will NOT run on Windows XP or earlier, see below.
    90 	/// 
    91 	/// V6.1
    92 	/// 10/28/13
    93 	/// Uses the .NET System.Management class to detect device arrival and removal with WMI instead of Win32 RegisterDeviceNotification.
    94 	/// Other minor edits.
    95 	/// Will NOT run on Windows XP or earlier, see below.
    96 	///  
    97 	/// V6.0
    98 	/// 2/8/13
    99 	/// This version will NOT run on Windows XP or earlier because the code uses .NET Framework 4.5 to support asynchronous FileStreams.
   100 	/// The .NET Framework 4.5 redistributable is compatible with Windows 8, Windows 7 SP1, Windows Server 2008 R2 SP1, 
   101 	/// Windows Server 2008 SP2, Windows Vista SP2, and Windows Vista SP3.
   102 	/// For compatibility, replaced ToInt32 with ToInt64 here:
   103 	/// IntPtr pDevicePathName = new IntPtr(detailDataBuffer.ToInt64() + 4);
   104 	/// and here:
   105 	/// if ((deviceNotificationHandle.ToInt64() == IntPtr.Zero.ToInt64()))
   106 	/// For compatibility if the charset isn't English, added System.Globalization.CultureInfo.InvariantCulture here:
   107 	/// if ((String.Compare(DeviceNameString, mydevicePathName, true, System.Globalization.CultureInfo.InvariantCulture) == 0))
   108 	/// Replaced all Microsoft.VisualBasic namespace code with other .NET equivalents.
   109 	/// Revised user interface for more flexibility.
   110 	/// Moved interrupt-transfer and other HID-specific code to Hid.cs.
   111 	/// Used JetBrains ReSharper to clean up the code: http://www.jetbrains.com/resharper/
   112 	/// 
   113 	/// V5.0
   114 	/// 3/30/11
   115 	/// Replaced ReadFile and WriteFile with FileStreams. Thanks to Joe Dunne and John on my Ports forum for tips on this.
   116 	/// Simplified Hid.cs.
   117 	/// Replaced the form timer with a system timer.
   118 	/// 
   119 	/// V4.6
   120 	/// 1/12/10
   121 	/// Supports Vendor IDs and Product IDs up to FFFFh.
   122 	///
   123 	/// V4.52
   124 	/// 11/10/09
   125 	/// Changed HIDD_ATTRIBUTES to use UInt16
   126 	/// 
   127 	/// V4.51
   128 	/// 2/11/09
   129 	/// Moved Free_ and similar to Finally blocks to ensure they execute.
   130 	/// 
   131 	/// V4.5
   132 	/// 2/9/09
   133 	/// Changes to support 64-bit systems, memory management, and other corrections. 
   134 	/// Big thanks to Peter Nielsen.
   135 	///  
   136 	/// </summary>