03-22-2011 04:14 AM
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.
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
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
03-22-2011 04:57 AM
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.
03-22-2011 01:38 PM
@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?
03-22-2011 02:18 PM
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.