LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

clusters in DLL

Hello,

I have a problem which I am stuck at so I would really appreciate any help.

I have this function that i need to access in Labview.

ViStatus _VI_FUNC Ki_GetSystemInfo (ViSession instrumentHandle,
void *systemInfo);

Now the structure for systeminfo is as follows:

typedef struct _SYSTEM_INFO
{
char pchModelNum[MODEL_NUM_LEN];
char pchSerialNum[SERIAL_NUM_LEN];
char pchSysSoftwareVer[SOFTVER_LEN];
char pchPlatformVer[PLATVER_LEN];
char pchOpSystemVer[SYSTVER_LEN];
int bCardType[MAX_SLOTS]; // Enum slot_types
} systeminfo;

When i use the call Library Node function to access the above function what
should be mine
input and out paramteres. I tries making cluster of 5 strings and an array
o
f integers
It doesnt seem to work. Any help shall be appreciated.

Premal
0 Kudos
Message 1 of 6
(2,651 Views)
Hi Premal,

Here is an example that might get you going.

Also provided is a C file generated by clicking on the Library node found in template VI and Create C file.

You can use this to create the structure you C code will used to pass the cluster to and from your code.

Regards
Ray Farmer
Regards
Ray Farmer
Download All
0 Kudos
Message 2 of 6
(2,651 Views)
Hi,

See my comment to Setu query as well , http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=137&HOID=5065000000050000004F5C0000&HTHREAD=000010342000023601000023605000023624000023631&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0.

This passes an array of clusters.
Although its unsigned int an you are passing strings, it basicily the same process. You need to allocate enough space for your string before filling it with your data to pass back to labview.

Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 4 of 6
(2,651 Views)
Hi Ray


I would really appreciate if I could get some more information on how to
assign the size of the strings...I need to create strings of size 32......

ie in VB....
Dim str1 as string *32

I guess thats why the programe just crashes after it executes the dll
function as the size are not specified in labview..I can use this function
properly in VB...without any problems...

Any help shall be greatly appreciated..
Thanks,
premal


"Ray Farmer" wrote in message
news:506500000005000000B25D0000-1012609683000@exchange.ni.com...
> Hi,
>
> See my comment to Setu query as well ,
>
http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=137&HOID=5
065000000050000004F5C0000&HTHREAD=000010342000023601000023605000023624000023

631&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0.
>
> This passes an array of clusters.
> Although its unsigned int an you are passing strings, it basicily the
> same process. You need to allocate enough space for your string before
> filling it with your data to pass back to labview.
>
> Regards
> Ray Farmer
0 Kudos
Message 5 of 6
(2,651 Views)
Hi,

This is an extract from the example code I sent you,
this is looking at passing a string that you wish to change the size when its returned.

// Changes the size of a string
int32 DynamicStringResize(LStrHandle in_string, int32 size)
{
MgErr error;
int32 i;

// Strings have the first 32 bits determine how many characters are in the string
error = DSSetHandleSize(in_string, sizeof(int32) + size*sizeof(uChar) );
if (error != mFullErr && error != mZoneErr)
{
(*in_string)->cnt=size;
for (i=0; i (*in_string)->str[i]=(uChar)(65+i); //65 is decimal for character 'A'
return 0;
}
else return -1;
}

You need to call the function DSSetHandleSize to allocate an area of memory
for your string.
The function passes the size of the string to be returned, but you dont need to do that. you just have to ensure your set the size which is define in the string structure eg (*in_string)->cnt=size, as in the example above. Then copy your string to the structure string. Providing you follow the same procedure it should all work.

Another example, this is passing a cluster of which one of the elements is a string:

// Allocate space for LabVIEW string with 5 characters
DSSetHandleSize(in_cluster->lvString, sizeof(int32) + 5*sizeof(uChar) );
// Set the size paramater of the LV string structure
(*(in_cluster->lvString))->cnt=5;
// Fill the LV string with the string we want in the cluster
strcpy ( (*(in_cluster->lvString))->str, "hello" );

This bit of code allocates enough space to return a string of 5 chars. And the string returned is "hello".

Hope is helps


Regards
Ray Farmer
Regards
Ray Farmer
0 Kudos
Message 6 of 6
(2,651 Views)
Hello Premal!

LabView is not exactly excellent at passing complex parameters to
functions. If the parameter is an array or a cluster it seems to work fine,
but I've had trouble passing a combination of the two (an array of clusters
or a cluster that contains arrays). I have yet to find a concrete LabView
only solution, and scouring Google Groups has yielded nothing for me. My
usual solution is to write a C wrapper to the function that disects the
structure to something that LabView can handle easily. Best of luck!

~Petr~

"Premal Shah" wrote in message
news:3c5ed984@newsgroups....
> Hello,
>
> I have a problem which I am stuck at so I would really appreciate any
help.
>
> I have this function that i need to access in Labview.

>
> ViStatus _VI_FUNC Ki_GetSystemInfo (ViSession instrumentHandle,
> void *systemInfo);
>
> Now the structure for systeminfo is as follows:
>
> typedef struct _SYSTEM_INFO
> {
> char pchModelNum[MODEL_NUM_LEN];
> char pchSerialNum[SERIAL_NUM_LEN];
> char pchSysSoftwareVer[SOFTVER_LEN];
> char pchPlatformVer[PLATVER_LEN];
> char pchOpSystemVer[SYSTVER_LEN];
> int bCardType[MAX_SLOTS]; // Enum slot_types
> } systeminfo;
>
> When i use the call Library Node function to access the above function
what
> should be mine
> input and out paramteres. I tries making cluster of 5 strings and an array
> of integers
> It doesnt seem to work. Any help shall be appreciated.
>
> Premal
>
>
0 Kudos
Message 3 of 6
(2,651 Views)