LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Communicate with HID device

I need to communicate to a USB HID device.  I have some sample code written in Borland showing the different function calls I need to use including HidD_GetHidGuid, SetupDiGetClassDevs, SetupDiEnumDeviceInterfaces, etc., all of which are part of the HID library that comes with the Windows DDK.  I added the HID.lib and header files to my project, but I get compile errors on multiple items in the header files.  For example, the code:

 

 __checkReturn
__drv_maxIRQL(PASSIVE_LEVEL)
NTSTATUS __stdcall
HidP_GetCaps (
   __in      PHIDP_PREPARSED_DATA      PreparsedData,
   __out     PHIDP_CAPS                Capabilities
   );

 

generates the error message "Declared parameter 'HidP_GetCaps' is missing".  This error message indicates that CVI thinks this is an old-style parameter declaration.  I think that really means that CVI doesn't understand the _drv_maxIRQL(PASSIVE_LEVEL)" macro and is treating it as the function name.  I can't find any explanation on MSDN of where this macro is defined.   I'm starting to think that it is intrinsic to VC++.

 

Going a different direction, I found some references to a KB article on using VISA to control an HID device.   The KB mentions creating an INF file for my device and using that driver instead of the standard HID driver that gets installed by default.  I am going to be distrbuting my program to multiple non-technical users.  I can't ask them to go through the process of uninstalling a default driver and then installing the correct one (some of them may not even have admin privileges on their PCs).

 

This leads me to several questions:

 

1) Is there a way for me to include the HID library in my project so I can just use it?

2) Is there a way to use VISA for this without creating a custom driver for the device?

3) Is there an easier way to do this that I'm missing?

 

Tony

0 Kudos
Message 1 of 6
(7,079 Views)

Hi Tony,

I found a couple knowledgebase articles that you might find useful. The first one talks about using the hid.dll.

http://digital.ni.com/public.nsf/allkb/8FD4C1DC8E80637E862572EF00784338?OpenDocument

and the second tells you a way you can get around this in a more permanent manner be modifying the USB device.

http://digital.ni.com/public.nsf/allkb/273BB58D3B52CE6886256F3B00714D03?OpenDocument

Unfortunately, Windows default action of using the HID driver by default makes controlling a USB HID device with a custom driver more difficult. I don’t know of a way to use VISA without creating a custom driver for your application.

Matt
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(7,032 Views)

Thread Update:

 

I found an inexpensive HID DLL that can be easily called from a CVI project.  There's even a sample CVI project to show how to use it.  The website for the DLL is http://www.kadtronix.com/usbhidapi.htm.  FYI, there are a few issues with the CVI project.  I'm going to submit an updated CVI project to the Kadtronix website in a few days that fixes all the problems

 

Tony G

0 Kudos
Message 3 of 6
(6,095 Views)

Hi,

 

Before purchasing any file, you need to know which device you are working with.First, you need to know the device. Then you need the name of the chip providing USB communication (VID, PID). Generally, the chip manufacturer provides DLL files or source code to develop what you want. You should also know if the device is supported by VISA.


Can you answer the previous question?

Thanks

0 Kudos
Message 4 of 6
(6,089 Views)
0 Kudos
Message 5 of 6
(6,088 Views)

As mentioned in my original post, I did not want to use VISA due to the complicated process of removing the default driver for the device and installing the VISA driver.  The HID DLL I found completely eliminates this problem since it talks directly to the standard HID driver. 

 

The VID, PID, and name should be provided by the device manufacturer.  If not, you can use the CVI sample project to find this information.  That program lists all the HID devices and shows you the VID, PID, name, interface, etc.

 

Tony G

0 Kudos
Message 6 of 6
(6,079 Views)