LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling dll Help

Hello,

 

I have a question. Im trying to interface a Dll. The first function works. But the second on keeps giving errors. Im trying to get the devicenames but this doesnt work. See example code.

 

First I get the number of devices. This works.

 

Then trying to get the names of the devices and connect to it. In the Doc it says this.

 

WORD HLP_GetDeviceNames (LPSTR *DevNames, WORD Max_Len, WORD Max_Num)

Use this function to get the name list of the instruments.

 

Parameters:

DevNames        pointer to an array of char pointers

Max_Len          Length of strings, should be set to 256

Max_Num        Number of string pointers in the array

Return value:       number of actually committed names

 

DWORD HLP_OpenDevName (LPSTR DevName)

A connection to a specific instrument will be established. You can communicate only with one instrument simultaneously.

 

Parameters:

DevName          pointer to a null terminated char, the name of one of the instruments connected to the computer

Return value:       error code, on success 0

 

 

The parameters are hard to figure out in Labview. I need to translate the C parameters to the available parameters in labview.Please can someone help.?  Thanks in advance.

 

B Bakels

 

 

 

 

Labview CLD , Engineer/Manager

Promedes and DSM
using LV 7.1, 8.0, 8.2, 8.5 and 2009 SP1
http://www.promedes.nl
0 Kudos
Message 1 of 4
(2,311 Views)

An array of string pointers is not something you can do in LabVIEW with the Call Library Node. The best and most easy way to handle that, is writing an intermediate DLL that translates this into more LabVIEW friendly way.

Rolf Kalbermatter
My Blog
0 Kudos
Message 2 of 4
(2,305 Views)

 


@rolfk wrote:

An array of string pointers is not something you can do in LabVIEW with the Call Library Node. The best and most easy way to handle that, is writing an intermediate DLL that translates this into more LabVIEW friendly way.


Rolf - couldn't you call DSNewPtr in a for loop, generating an array of pointers (to arrays of 256 chars)?  I understand it wouldn't be automatic because you'd need to call MoveBlock to get the data back out, then search each array for a null-terminator and trim the string to size.  Is there a reason that wouldn't work, though?

 

0 Kudos
Message 3 of 4
(2,279 Views)

Of course you can, but try to explain that to someone who doesn't know C, without writing the whole VI for them! And once you know C, doing it in a wrapper DLL has definitely the preference.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(2,274 Views)