Cluster array to c structure 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 st
rings and an array
of integers
It doesnt seem to work. Any help shall be appreciated.
Premal

Hi Premal,
Try to use arrays of [U8] instead of strings. Also, pay attention to INT - is OS dependent (assuming that you are using win9x/NT/2000, use [I32]). If you try with strings, be sure that the input string contains enough characters to store the result.
Hope this helps
p.s.: take a look on those articles mentioned in "cluster array to c structure in DLL" [http://exchange.ni.com/servlet/ProcessRequest?RHIVEID=101&RPAGEID=137&HOID=506500000005000000C05C0000&HTHREAD=000023744&UCATEGORY_0=_49_%24_6_&UCATEGORY_S=0]

Similar Messages

  • Resizing an array of struct inside a DLL using the memory manager

    Hi all,
    I dug deep inside the boards, but wasn't able to find a solution for my problem.
    I'm building a dll, which does some imageprocessing and should return an array of structs to labview, with one struct for every element in the image.
    As I don't know the number of elements beforehand and the limit of the number is numbers of magnitude larger then the expected one, I don't want to allocate such a huge chunk of memory prior to the dll call in labview.
    In a former version I used a 2d array for the elements, where each row holds the values of every element. Here I used the NumericArrayResize-function, which worked quite well. But I have to add more sub-processes and using structs (or clusters in labview) appears to be more usefull and cleaner for me, in addition I had to cast some of the elements back and foreward a few times.
    So one element-struct should hold 2 singles and 1 uint32. My question is now, how can I resize this array of struct with memory manager functions as the NumericArrayResize-functions does not suit this purpose?
    (Accessing a given array of structs inside the DLL and after that reading the changed values in Labview is surprisingly easy )
    Thanks in advance
    Solved!
    Go to Solution.

    Well, I was able to solve it myself. I found this thread, where the first post of rolfk made me thinking. It appeared to me, that the numericarrayresize-function behaves very similar to the realloc-function of c. So I used the type unsigned int 8 (which is just one byte) and multiplied it by the number of bytes used by one struct, in my case 12 bytes (4+4+4) and then multiplied it by the number of structs (elements in the image) i have. Luckily it worked and the memory block was resized exactly as I wanted it to be. Important to note: do not forget to adjust the size element of the handle, otherwise Labview does not know about the changed size.

  • Address element of only one line in cluster array

    Hi,
    I created an array of clusters. In each cluster the switching a binary element is supposed to activate/deativate the following elements. In my VI however either the elements of none or the elements of all clusters are activated/deactivated. Does anybody see, where I made the mistake?
    Thank you.
    Attachments:
    ClusterArray.vi ‏21 KB

    Hallo,
    in einem cluster-array können nur die Werte individuell verstellt werden. Eigenschaften gelten immer für alle Array-Elemente. Diese Frage wurde schon im ni-forum diskutiert, z.B. um LED-Farben einzustellen:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=27375&query.id=12471#M27375
    In deinem Fall hilft das aber nicht weiter, da ich nicht wüsste wie über ein Wert die Sichtbarkeit des Elements eingestellt werden kann.
    Noch eine Bemerkung am Rand: die For-Schleife benötigt in deinem Beispiel keinen Zähleingang, bei indizierten Array-Eingängen wird die FOR-Schleife genau einmal für jedes Array-Element durchlaufen.
    Vielleicht kann ja doch noch jemand weiterhelfen 
    Gruß,
               Magnus

  • Arrays to 3D-cluster arrays input Feed into draw Mesh

    Hi,
    I'm puzzzle with my own algorithm.
    I want to grab input then feed into 3D-cluster array . then feed into Mesh parameters array.
    The problem i had, I want to take 2 rows, feed into 3D-cluster, then send into mesh parameter,
    then redo it with another 2 rows moving down the array.
    So i will have 1 line that "move" in the 3D picture control
    Attached is my vi.
    Attachments:
    array-problem.JPG ‏72 KB

    Sorry here the VI ..   
    Attachments:
    moving3D-data work3.vi ‏18 KB
    zulhairi_1.csv ‏71 KB

  • Cluster resource SID.WORLD' (resource type '', DLL 'fsresodbs.dll') either crashed or deadlocked.

    Dear Friends,
    We are facing issue with our systems which is running on win2008 with oracle DB this is MSCS environment.
    Automatically some resource moved to node2 from node1 and database went down, in fail safe cluster management i can see error as below.
    Cluster resource 'SID.WORLD' (resource type '', DLL 'fsresodbs.dll') either crashed or deadlocked. The Resource Hosting Subsystem (RHS) process will now attempt to terminate, and the resource will be marked to run in a separate monitor.
    And
    The cluster resource host subsystem (RHS) stopped unexpectedly. An attempt will be made to restart it. This is usually due to a problem in a resource DLL. Please determine which resource DLL is causing the issue and report the problem to the resource vendor.
    Kindly help us to solve this issue.
    Thanks
    Basis

    Hi Deepak,
    Thanks for providing the link.
    I have seen the link and symptoms are same,  but only difference is, this link is talking about clusres.dll'  and we have issue with fsresodbs.dll'
    Our issue
    Cluster resource 'SID.WORLD' (resource type '', DLL 'fsresodbs.dll''') either crashed or deadlocked.
    and issue described in the Link
    Cluster resource 'SID.WORLD' (resource type '', DLL 'clusres.dll'') either crashed or deadlocked.
    Kindly guide.
    Thanks
    Basis

  • Hmi wizard for indicators inside cluster array

    I am setting up a config screen for use with the DSC and tag engine. I have an indicator and analog value inside a cluster array. Can you use the hmi wizard to make unique conditions for the indicator in each array element?? or would I have to use a sub vi to write the values to the elements inside the clusters??
    Attachments:
    TOOLPASS_CHANNEL_CONFIG_DATA.vi ‏17 KB

    Hi,
    The simple control in the cluster or in an array will not have a way to invoke the HMI Wizard to create simple HMI code because the control turns into a more complicated control type. Using a sub vi to unbundle the cluster should be a workaround for this application.
    Regards,
    Remzi A.

  • Scrollable cluster arrays as control, writing programmatically at the same time?

    I would like to have a cluster array (just an example, you may suggest better solution), where each row (cluster-element) contains signal selection from combobox, and its value and unit.
    I would like to have a signal list, where in each row, I can select which signal I want to show e.g. "motor speed", "motor torque", "motor power". And when signals are selected, the value of the
    signals are automatically updated elsewhere. So basicly, I want to select which signals I monitor, and then watch them change over time. I use single cluster array because I want it to be scrollable. The problem is:
    * let's say I have one row in the array. Then I add a row by editing the control in the GUI (now the array control has size 2).
    * I have property node (write: array control -> value) to update the values and units in my software.
    * I use array control output as the input in the subVI where I read my selections and write updated signal values.
    * It can happen that I use that array control output when it still has size 1, and while I have added the second element, the software updates the control, and overwrites my new element addition.
    So, I run into writing conflict. Only single user, just this problem. How should I avoid this?
    (e.g. how can I know that user is not interacting with the control, so that I can update its value and unit fields)

    First suggestion is to post the code you have.
    But that being said what you want to do can be done.  I think the problem you are having is a race condition between the user and the software.  Where the user chagnes the value and the software changes it back.  I suggest reading the value of the control and replacing its value but keep the signal names the user entered, then write that back to the control.
    Another suggestion is to have two separate arrays, one that is signal selection, and one is values.  Then you only need to update the values table with the new data and the signal names never get overwritten.  You'll likely want to couple the two arrays so when one index value changes the other changes with it.  This can be done with an independent scrollbar control.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Update combobox from cluster array

    I am looking to update a combo box from a cluster array. The array is indexed then unbundled by name and the element I want for the combo box is selected. How would i update the combo box from here or is this method even the right method of doing it?
    Paul Power
    I have not lost my mind, it's backed up on a disk somewhere

    Cluster to Array only works when the datatype of the cluser elements are all the same.  Here is what I was trying to say.  And by the way I sure hope your massive cluster is type def'ed.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.
    Attachments:
    Combobox.png ‏32 KB

  • Call library node - using a structure with dll

    Hi folks.
    I was hoping to recieve some help or advice on solving this problem I am having in labview:
    Some background info - I am trying to use the 'call library node' to allow me to use a .dll to allow for control of a remote power supply over RS-232.
    I have been doing fine up till now, however I am now trying to use the following:
    int TC4GetFnBlockSettings(struct T_FnBlock *p_fnblock, unsigned int type)
    int TC4SetFnBlockSettings(struct T_FnBlock *p_fnblock, unsigned int type)
    where
    struct T_FnBlock
    unsigned int BaseFunction;
    double Amplitude;
    double Offset;
    double Symmetry;
    double Frequency;
    int BipolarAmplitude;
    int RectifyAmplitude;
    double ExpTimeConstant;
    unsigned int NumPeriods;
    unsigned int UserDefAmplitude;
    unsigned int UserDefTimePrescaler;
    double UserDefPeriodLength;
    unsigned int UserDefNumPoints;
    unsigned int InactiveLevelType;
    double InactiveLevel;
    unsigned int AAPInputType;
    unsigned int AAPInputFilterKoeff;
    unsigned int AAPFlags;
    double AAPInputScaling;};  
    Obviously there is no such thing as a structure in Labview; I had hoped to use a cluster in it's place however the CLN does not allow for input or output of a cluster.
    Any help would be appreciated!
    Thanks
    Solved!
    Go to Solution.

    Akiel wrote:
    unfortunalty the call library node doesnt map labview types to c types very well. It can be done but took me a lot of time and effort (and overworking google) to manage it. In the end i abandoned the cln and write a c# code that interfaces between my dll and labview. 
    sorry cant be of much more help.
    I think NI need to improve this functionality as the CLN could be useful but hard to get working on anything beyond a simple dll interface
    That is not true!
    The Call Library Node does a tremendous job in providing configuration options to map LabVIEW data to most C datatypes. In most cases the two match directly except when arrays and strings are concerned. Those two are very different in LabVIEW than in C but the Call Library Node allows to configure parameters to map LabVIEW strings and arrays to according C string and array pointers.
    A structure in C is directly equivalent to a LabVIEW cluster unless it contains strings or arrays. Also there is the potential of structure element alignment which you have to take care of explicitedly but that is hardly the fault of LabVIEW but rather a direct consequence of the rather low level character of the C language.
    Since the OPs C struct only contains scalar datatypes you can directly create a LabVIEW cluster with the same elements and the same order of elements and pass that cluster to the Call Library Node parameter configured as Adapt to Type.
    The reason that you might have to get google overworked for such things is not because LabVIEWs support for interfacing to C code is bad, but because interfacing to C code is such a complex topic in itself. Without a lot of low level knowledge about what a C compiler really does when creating functions you are bound to do a lot of trial and error and googling. You get the same issue when trying to interface unmanaged code in C# (.Net).
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Calling structure in dll

    I am trying to call a dll that contains a nested structure. I am not a c-programmer so therefore I
    would lik to use the call library function but I do not know how to handle the union structure shown below??
    Function Name:
    cnc_rdparam
    Declaration:
    FWLIBAPI short WINAPI cnc_rdparam(unsigned short FlibHndl,short number,short axis,short length,IODBPSD *param);
    typedef struct iodbpsd {
    short datano ; /* data number */
    short type ; /* axis number */
    union {
    char cdata ;/* parameter / setting data */
    short idata ;
    long ldata ;
    char cdatas[MAX_AXIS] ;
    short idatas[MAX_AXIS] ;
    long ldatas[MAX_AXIS] ;
    } u ;

    I'm not sure, but I think that you have to wire the "param" output of "Call library function" to the cluster which consists of
    1. datano - I16
    2. type - I16
    3. the variable with type depending on the type of union - I8 for cdata, 116 for idata, I32 - for ldata, array of I8 for cdatas, array of I16 for idatas, array of I32 for ldatas.
    In other words you must know the type of cluster before calling of this function. May be this type depends on values of other parameters.
    I think that you have to organize the case structure in your diagram which calls this function and returns the appropriate cluster depending on other parameters.
    Oleg Chutko.

  • Array of doubles filled by DLL contains weird values

    Hello everyone
    I am working on a DLL invocation which needs to resize and fill an array of doubles named 'values' (2nd to last parameter). I have defined the signature as follows:
    _declspec (dllexport) uint8_t readDoubleArray(uint8_t handle, LStrHandle lPath, int64_t startTime,
    int64_t endTime, DblArrHdl *values, LongArrHdl *timebase);
    Where DblArrHdl is
    typedef struct {
    int32_t dimSize;
    double doubles[1];
    } DblArr;
    typedef DblArr **DblArrHdl;
    In the invocation I read doubles from a database, and resize the double array as follows:
    int size = doubleArray.size();
    if (NumericArrayResize(0x0A, 1, (UHandle*)values, size) != noErr) {
    setLastError(MG_ERR_LABVIEW_ERROR, "Failed to allocate memory");
    return FALSE;
     I set the size, and copy the values:
    (**values)->dimSize = size;
    for (int i = 0; i < size; i++) {
    (**values)->doubles[i] = doubleArray[i];
    When I use the DbgPrintF to validate the values it gives me a value around 120000 which is correct. However, when returned by labview the array contains strange data, like 5.38564E-315. Here is print out of the 'values' array after it has been through the DLL:
    Here is how I wired it, ignore the clustering, it occurs in the array of values which exits the DLL call.
    I have no idea how this can be. I followed the examples on the site. I also tried the normal DSSetHandleSize, but it didn't change anything. Any idea what I did wrong?
    Thanks in advance,
    Vincent
    Message Edited by DaVince on 10-22-2008 10:10 AM
    Solved!
    Go to Solution.
    Attachments:
    doubleArrayWeird.png ‏7 KB
    wireUpDoubles.png ‏18 KB

    You're right, this not directly described...  
    First you should read how LabVIEW stores data in memory,
    then read about structure packing pragma,
    and finally take a look to C/C++ preprocessor reference,
    then you will get feeling how to solve this problem...
    Otherwise own DLLs used in LabVIEW code pretty rarely, and Double precision also not very often...
    The same trouble you may get with clusters, but here behaviour described:
    "...The memory layout of a cluster depends on the platform you are running. LabVIEW may add padding between cluster elements so that those elements are aligned to certain address boundaries. Address boundaries relate to the concept of natural alignment. A piece of data is aligned on its natural boundary if the address at which it begins is a multiple of the size of the data. For example, a 4-byte integer is aligned naturally if it begins at an address which is a multiple of four. Most compilers have an upper limit on this boundary at which the restriction is relaxed. For instance, an 8-byte integer may be aligned on a 4-byte boundary. For the platforms on which LabVIEW runs, the alignment constraints are as follows:
    (Windows) Data is aligned only to 1-byte boundaries.
    (Mac OS and Linux) Data is aligned naturally up to 4-byte boundaries.
    (VxWorks PowerPC) Data is aligned naturally up to 8-byte boundaries.
    On all platforms, clusters adopt the alignment of their most restrictively aligned element..."
    best regards and happy wiring...
    Andrey.
    Message Edited by Andrey Dmitriev on 10-23-2008 03:38 PM

  • Complicated structure for DLL function

    I need LV6 to pass and get back parameters to a DLL function whose prototype is:
    int APIENTRY GetData(ACQDATA *Data)
    ACQDATA has the following structure
    typedef struct{
    unsigned long huge *s0;
    unsigned long far *region;
    unsigned char far *comment0;
    double far *cnt;
    HANDLE hs0;
    HANDLE hrg;
    HANDLE hcm;
    HANDLE hct;
    }ACQDATA;
    From the DLL documentation I could see that
    - the function modifies its argument
    - the (fixed) length of the second, third and fourth parameter is specified
    No idea of the length of "s0". I've tried several LV clusters including a cluster with four pre-allocated arrays (buffers) and four scalars. But no luck so far.
    If a C wrapper function is the only solution to pass the parameters correct
    ly, can anyone show me an example. Can I use the Code Interface Node for that purpose though I only own the Base Package version of LV or shall I write another DLL function?
    Please help asap

    Unfortunately I am new to C programming, but I'll try to give you the complete picture of what happens.
    There's no definition for HANDLE in the DLL documentation but windows.h is included, so I guess the following
    #define HANDLE void * //32bit?
    In my LV routine I tried U32 variables for the HANDLE typed parameters.
    In one of attempt LV passes to the function a cluster (I make no mistake with the order!) with four arrays and four U32, all of them preset to some value. Well.. these values (all)are not changed when the function returns. The return value of the function says no error, anyway.
    I tried other clusters: with and without arrays, with all (or part) scalars and all (or part) strings. No way either.
    Sometimes LV itself crashes, sometimes I get
    the original values I imposed before the call.
    I suspect the LV cluster structure makes me miss the right level of indirection for the first 4 variables in the structure (called *s0, *region, *comment and *cnt): when either I pass arrays or scalars as components of the cluster.
    Hope this helps you to help me
    Cheers
    Piero

  • Structure pointer dll

    Need some help here, as I have tried everything I can think of.
    Created a cluster, representing the structure and in die call function I have set 'Adapt to Type' and array data pointer, but this keeps failing as you can see below
    Will appreciate any help/advise to get this working...
    Solved!
    Go to Solution.

    You add strings to the cluster. They will be passed to the DLL as LabVIEW string handles, something only DLLs can handle that have been specifically written to work with LabVIEW datatypes.
    The real solution depends on how your structure is defined in C. If it contains fixed size string arrays, you have to replace that with a LabVIEW cluster with as many U8 or U16 integers as your fixed size string is defined. If they are defined as string pointers you have to place an uInt32 (for 32 bit LabVIEW) or an uInt64 (for 64 bit LabVIEW) for each string pointer and do some pretty convoluted memory management on your own (which you also would have to do if you used that function from a C program).
    Your structure is however defined to contain fixed size arrays so the first solution is applicable.
    You also need to check your structure again. aIPAddr is a cluster of 16*U8 elements and abMACAddr is a cluster of 6*U8 elements, not a single U8 element. Time is an int which is a signed integer that translates in LabVIEW to an int32. IsDHCPAssignedIP up to NumIPConnectionsIsValid are single char elements not a string and therefore translate to a single uInt8 in LabVIEW. And finally aPadding is again a cluster of 34*U8 not a single U8.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Nested IPE (In Place Element) usage when accessing Cluster/Array data via DVR

    I am sharing data across several VIs and loops via a DVR, and accessing the data via a DVR IPE. The data is a cluster of arrays. The diagram below (VI attached) illustrates the structures invloved, but not the structure of the application.
    (The diagram above does not include initialization of the arrays, as it is intended only to illustrate the Cluster1 data type. Array lengths could be 100.)
    The DVR (DVR1) is passed to multiple VIs of the application at startup.
    Each VI executes loops that either read or write particular elements of each array (fArray1 or fArray2).
    I believe the DVR IPE (B1-DVR) provides blocking so that only one task can modify the data (Cluster1) at any time.
    Case 1 illustrates how I currently WRITE to array elements. The outer IPE (block B1) is rolled into a VI (not shown) that takes DVR1, Index, and Value as inputs.
    Cases 2 - 4 illustrate 3 additional methods that remove one or both of the inner IPEs (B2-Cluster and B3-Array).
    Case 2: IPE B3 (Array Index/Replace Elements) is replaced with a non-IPE 'Replace Array Subset'.'
    Case 3: IPE B2 (Unbundle / Bundle Elemnts)' is replaced with a non-IPE cluster 'Unbundle'/'Bundle'.
    Case 4: removes both B2 and B3.
    I implemented case 1 a long time ago.  When I had to do the same thing again recently, I did case 4.  When I stumbled across my earlier implementation, I was a bit suprised
    Which of the 4 cases should take the least time (or resources) to execute? I think case 4 has as few array allocations as any of the other 3.
    The attached image did not capture the Buffer Allocation marks, so I marked the ones that differed with a red "B".
    I am only interested in differences in how the arrays are handled, so I see no signioficant differences.
    Is this one of those cases where LV doesn't need my help?
    Incidently, I recently wrote a small app with shared data and decided to try FGVs to share array data.  For small arrays, 10^7 iterations, and an FGV based array-element read followed by a element write, the FGV was faster.  1.2us per read/write for FGV vs 3us per r/w for an DVR/IPE based read/write (like above).
    Peter
    LV 2011 SP1, Windows 7 64-Bit
    Attachments:
    IPE.vi ‏9 KB

    Option 1 is a definite no and as far as I know it has been NI's explicit intention to steer clear from it. I believe there's an idea in the IE which asks for this.
    I agree that option 2 makes sense, but I don't think it should be something the user specifies. Either LV can detect it automatically or it can't, but I doubt NI would let you have an option which creates the possibility for this kind of bug.
    I'm not sure, but the mark as modifier option on the IPES might be the option you're looking for. I know that it exists and I know very roughly what it does, but the documentation for it is very limited and I never actually played around with it, as usually I don't need these kinds of optimizations.
    You may well be right that a new option on the IPES is desirable and you should probably add it to the idea exchange.
    As for NIWeek, I'm not going this year, so I have no idea what kinds of sessions are around, but it's a great place to find people who know what they're talking about and ask them about it directly. Certain people in LV R&D would probably be ideal for this and if you ask relevant people, you might even get their names. I'm sure buying them a beer would also help to loosen their tounges. If you ask me, this type of interaction is the main value of the conference, not the sessions themselves.
    Try to take over the world!

  • How to populate multi-cluster arrays using matlab code?

    Hi,
    I have an array of clusters containing two 'Double' elements in each cluster. I am looking for a method to populate this array using MATLAB code. I need around 1000 clusters in the array, so populating it using the front panel is not practical. There is also some calculation involved in deciding the value in each element. If there is an example or a method to do this, please point me in the right direction.
    Thanks

    altenbach wrote:
    Can you attach a typical file so we know that the structure is? It is easy to convert from any data structure to any other data structure. You could even read it as a 1D string array and parse each line into a cluster, for example. It all depends on how the fil is arranged. You could also read the file as a flat string and chop it up into the desired structure later.
    I have attached the .vi file. I need to convert the spreadsheet to an array of clusters, thats where I'm getting stuck. (The vi is an example from help libraries)
    That is the part where I need to change so that I can use a spreadsheet.
    Attachments:
    Buffered counter.vi ‏52 KB

Maybe you are looking for