Jump to content

wrapping windows dll


Recommended Posts

I trying to communicate via USB with a labbrick generator.It uses the hid.dll to communicate. I tried using the driver wizzrd in labview but the raw driver shows up

in max as a unknow device and it comes up in the windows device manager with my driver name and under the usd ni visa,

Windows says it works fine and max can't open a session.

I try the library function and called the setupapi and selected the SetupDiGetDeviceInterfaceDetail but i'm not sure how to configure the parameters.

Then I tried to import the driver but it asks me for a header file.I beleive you need to get them from Microsoft by downloading the windows development kit.

When I search for the kit all i get is the one for 2008 sever,

thanks

Link to comment

QUOTE (mattdl68 @ Mar 31 2008, 12:47 AM)

I trying to communicate via USB with a labbrick generator.It uses the hid.dll to communicate. I tried using the driver wizzrd in labview but the raw driver shows up

in max as a unknow device and it comes up in the windows device manager with my driver name and under the usd ni visa,

Windows says it works fine and max can't open a session.

I try the library function and called the setupapi and selected the SetupDiGetDeviceInterfaceDetail but i'm not sure how to configure the parameters.

Then I tried to import the driver but it asks me for a header file.I beleive you need to get them from Microsoft by downloading the windows development kit.

When I search for the kit all i get is the one for 2008 sever,

For HID devices I do not think you can use MAX at all and it doesn't make to much sense either as you would have to implement the HID Class protocol again in LabVIEW using VISA Nodes. HID devices are well known to Windows and it will claim them and VISA won't really be able to hook them if I'm not mistaken.

Instead you will need to go the Windows API route as you have started out but that is not for the faint at heart without some fair C programming knowledge.

So what device is it you want to access? Because I do not think VISA USB Raw is gonna help and the Windows API is likely at least one league to complicated for you.

Even if you manage to access the Windows API for the HID device this will not be your end of the troubles. HID itself is also very basic with just a bytestream for read and write. How this bytestream needs to be formatted (usually binary) will be another problem to tackle and without proper documentation from the manufacturer likely not possible. Doesn't the manufacturer have a DLL to communicate with that device already? That would reduce to problem to interface that DLL and get its documentation.

Rolf Kalbermatter

Link to comment

Thanks RolfK.

I was able to get MAXs to reconize the Visa Raw but it had an error. It reconized thre device and forund the id and serial number of the device.

See attached.

After fighting with the visa raw. I tried using the library function.

I do have the doucumintation. It says I have to use the SetupDIGetDeviceInterfaces.

This is some of what the manuals says.

Use the SetupDiGetDeviceInterfaceDetail function to get the symbolic link name for

the interface, which the operating system uses to encode its enumeration information

describing the device. The string contains the VID and PID of the device found

by the operating system. Test each string to find the one (or more if you have

multiple Lab Bricks attached) that contains the VID and PID values in it. For the

Microsoft Windows environment, the portion of the device strings containing the

VID and PID are in the format:

sDevSubstring1 = “vid_041f&pid_1201”; // VID and PID for LSG-402

sDevSubstring2 = “vid_041f&pid_1202”; // VID and PID for LSG-152

sDevSubstring3 = “vid_041f&pid_1203”; // VID and PID for LSG-251

Once you have identified a Lab Brick, open it by using the DevicePath from the

Interface Device Detail Data structure, using the normal CreateFile function. Once

you have opened the device1 you can read the Lab Brick’s serial number using the

HidD_GetSerialNumberString function.

I have the commands to communicate with the device.

I'm having difficulty on configuring the dll parameters when using the call library function. I made a simple VI that just adds one to the input.I put this vi in a labview prodject and created a dll.

I called the dll I made using the call library funtion and it automatically confiured the parameters.That worked great.

What I tried next was to find the header file for the setupapi.dll and create a wrapper around the setupapi dll. it had errors creating the wrapper.

Do you know of any documatation that has a step by step instruction of using windows dll in in labview.

Thanks

Link to comment

QUOTE (mattdl68 @ Apr 1 2008, 07:40 PM)

Thanks RolfK.

I was able to get MAXs to reconize the Visa Raw but it had an error. It reconized thre device and forund the id and serial number of the device.

See attached.

After fighting with the visa raw. I tried using the library function.

I do have the doucumintation. It says I have to use the SetupDIGetDeviceInterfaces.

This discription does not sound completely right. I don't remember having had to parse the string for VID and PID. Unfortunately my sources won't help you to much since they are for a specific device.

There is however enough code to show you how it needs to be done.

Search for usbhidioc on the net. I've used a Visual C 6 version as inspiration. Specifically

http://www.lvr.com/hidpage.htm and there halfway down Visual C++ 6 section. You won't get around installing the WinDDK from MS I'm afraid, unless the newest PSDKs come with the necessary definitions too.

In that example you find the actual code to search for a HID device in usbhidiocdlg.cpp/CUsbhidiocDlg::FindTheHID()

The code in that function in itself is just standard C but the project is in C++.

And no I will not even consider to look into the possibility to call these APIS directly from LabVIEW with the Call Lbrary Node. It's very very maybe possible but it will be such a pain that even if you have to install and configure an entire C environment and have to learn C too it will not be less painful and time consuming than getting you to the point where such a direct LabVIEW interface would work reliable.

Rolf Kalbermatter

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.