struct dll to the cluster of LabVIEW

Hello. Currently I'm trying to read the data struct dll writen and see the data in the cluster of LabVIEW, accordingly, I want to use this data in my project of futher. But I am facing a problem. The main problem is, that I can read the data, but those data are incorrect.

Here is the structure of the dll:

typedef struct PHAROS_MOTOR_CONTROLLER_state_tag
{
SYSTEMTIME TimeStamp;
unsigned char MotorControllerState;
unsigned long MotorPosition;
MotorCurrent short unsigned;

unsigned int AmbientHumidity;

float moisture;
float temperature;
float point dew;

float Detector_2Ph;

} PHAROS_MOTOR_CONTROLLER_state;

This is the function I try to call using the node library function call:

bool PHAROS_API_Motor_Get_State (PHAROS_MOTOR_CONTROLLER_state * State)

Returns the value true and fill State structure with the latest information from the State received from the motor controller or
Returns false if no status message received or interval of time since the last receipt.
This function returns immediately.

So, maybe you have a suggestion how to recive correct cluster data?

Thank you in advance!

SIMAS

It is quite easy to do and asked several times on this forum.  Despite Zoomzoomzoom comments, there is no need to write any sort of wrapper in C.  All you have to do is to create a cluster in LabVIEW that reproduces available to the C struct.  When you configure the call library function node, configure it as "Adapt to type" and the cluster thread entry for this parameter.  It will be automatically passed by reference (like a pointer).  The output of this parameter will be your data.  You may need to add a few items of padding to the cluster - struct elements in C are normally aligned, while clusters of LabVIEW are packed - but once you have this right, it will work.  You will need to replace the SYSTEMTIME component with an equivalent cluster within the plu cluster (search for SYSTEMTIME will show you that it is just 8 2 byte values).

You should check if the header file includes a line #pragma pack(), which indicates if the structure is aligned in a non-standard way.  If it follows standard packaging, you will need to add 3 bytes of padding after MotorControllerState and 2 bytes after MotorCurrent.  I assume here that your DLL "int" and "long" are equivalent, even if MotorPosition is defined as long and AmbientHumidity is defined as int.

If you are able to recover some data, but it is data incorrect, most likely, it's because you're missing the padding.  If you can not understand where the padding is necessary, or are unable to work, please attach your code showing what you're trying to do.

Tags: NI Software

Similar Questions

  • Passage Cluster containing strings in a C DLL in the Struct

    Hello everyone.

    I have a C DLL that I call you inside a Labview application.

    Some of the C functions use structs as inputs. These structures contain strings. The C DLL expects normal char * string type.

    Currently, I create a cluster that matches the structure and then passing in the DLL. It seems to work fine for everything except the strings. I think it has something to do with the operation of the library function call. Normally, you can select the format of string for strings as parameters. But given that you must use to adapt it to the type of parameter for the cluster, you seem to lose this control.

    I don't know exactly what I need to do to create the string of C, the DLL requires the chain of labview.

    Any help would be appreciated.


  • move the cluster for sub vi

    Hello

    I want to spend a cluster that can change its content to one under VI. The cluster does not change by program, but during programming, that is, I could add or remove items in the / cluster. Using direct wire or local variables I would have to change each sub VI that uses the cluster updated the. I also tried the typedefs, but I met the same problem.

    At the same time the Subvi should be able to update the cluster I spent.

    In C++, I use classes like struct (equivalent to the cluster of LV) and pass a pointer to a class object to a function. Within the function, I choose the members of the class I want to use inside this function. If I change the class structure, the functions of the Word are not affected (of couse only as long that I remove irrelevant of class members of the called function).

    Example (from C++):

    settings * param;  'settings' is a class that I use to group variables

    doSomethingUseful (param);

    / * the doSomethingUseful function uses the pointer to parameter and accesses the members of

    Param-> variable1

    Param-> variable2

    ...

    Hereby, I can change the values of variables stored in the param object

    */

    Best,

    Max


  • Enqueue cluster for Labview Teststand, return a cluster by notification

    Hi all

    I get very very frustrated that I can't find a way to spend

    an asynchronous VI with a cluster of Teststand reflecting a LV

    cluster using a queue.

    This works if wire you the cluster Teststand for the VI is there

    an order appropriate to link to. Yet, the VI has no

    Connector, he expects that a cluster in queue, read of the

    PropertyObject by 'GetValVariant', do some magic

    and is supposed to return another cluster using Teststand

    a notification

    I can read singular elements of the cluster in queue, but cannot

    Run in a cluster of LV with, say, the good old 'VariantToData '.

    which indeed works great inside LV

    Same thing happens when I try to regain a Teststand cluster

    using 'SetValVariant' even if both the Teststand cluster

    and the cluster of LabView are the same format and structure.

    The 'Wait' Teststand notifier action is linked to the right cluster

    property, but Labview fails at the "SetValVariant", because not of

    the right type, even if I have sunk the variant data.

    I wonder if I do wrong or Teststand and Labview

    are simply not designed to work together seamlessly.

    Here's the example I'm putting in place, but the reading of the

    cluster fails, while the alternative 'False' works (123.00)

    Defining the notifier cluster fails too, but its definition the

    elements indivualy also fails because Labview is

    What are 'Compliance' and 'Comments' in

    the 'True' alternative, although I tried all

    hierarchy tree.

    You might have figured out, but I really really need to

    get this working, and I can't understand where the

    default is (next between the Chair and the keyboard) because

    the principle works in LabView.

    David Koch

    Okay guys, I give up all hope, that I had to do this work.

    This is a WIP Teststand container/Labview cluster motor relay.

    TestStand 2013-> TCS_main_2.0.4.seq (run TCS_teststand_2.0.0.vi)
    LabVIEW 2013-> TCS_teststand_2.0.0.vi (run TCS_instruments_2.0.0.vi)
    LabVIEW 2013-> TCS_instruments_2.0.0.vi (interface instruments)

    The main idea was to catch Teststand queued of containers,
    convert a Variant, to analyze their structure and
    to match with their counterpart of cluster of Labview.

    The engine is initialized to 'learn' the Labview
    data structures, storing the data type and the names of the clusters
    different elements, as well as the cluster hierarchy.

    A format of target data type and an associated action are also
    stored for each identified cluster/container.

    Then the engine is waiting for incoming Teststand queue
    containers, convert them to a Variant, to analyze their
    structure and * TRY * to match with the stored
    having been analyzed Labview homologous groups.

    This is what I call the "footprints".

    The three main problems were... are:

    1 - different naming convention (TCS_string_teststand_name_convert_2.0.0.vi)

    2 - format of different data type (TCS_variant_tree_convert_2.0.0.vi)
    3 - different (TCS_propertyobject_tree_parse_2.0.0.vi) data structure

    I think I was very close to resolving these issues, but I'm
    short on time. As an entrepreneur, I've spent
    more than a month of work on this value. Who is
    too many given my dead line.

    I'm quite sad to be leaving this unfinished, he would have
    was great to get the motor relay pole upward and
    running, having just to place a container Teststand
    to get something done automatically at the other end
    and just wait for a notification sent for analysis.

    What's left to do is the following, as an exercise
    left for the reader:

    To "explode" the data structure to correspond to of Teststand "
    still more verbose simpler data format

    This means for example that a Labview wave have to
    be transformed into a cluster of 3 datas. You can read the
    suite of document, but it is not very clear on how
    The LabVIEW data type formats are converted to their
    corresponding Teststand counterpart:

    http://zone.NI.com/reference/en-XX/help/370052N-01/tsref/infotopics/labview_data_types/

    Beware, this involves a lot of trial and error, as
    creating a large Labview cluster with all data
    type of support, import it in Teststand and create
    a custom, data type and then compare each converted

    a data type.

    B point A would improve the adequacy between Teststand
    containers and clusters of Labview.

    With a longer data structure mirrored, it will indeed
    help 'TCS_fingerprint_search_2.0.0.vi' to compare
    the structure of the Teststand container with the correspondent
    LabVIEW cluster structure, the elements names
    Always different Convention.

    Conversion of data format C - needs to be done, place holders
    are ready to be filled.

    There are still a lot of work to do in 'TCS_variant_tree_convert_2.0.0.vi '.

    Remember that the type of data "FileGlobals.tcscluster".
    mirrors (wise Teststand) the 'TCS_instruments_2.0.0.ctl '.
    type definition.

    This means that a string has not transformed a waveform.
    Data format should be very close to each other. That's why
    There is no need to focus too much on these "exotic" data
    format conversions.

    Thanks again to all the people who have invested some time
    in trying to help me solve this issue.

    Thanks to nathand for its cluster monitor not recursive.

    David Koch

  • Call the function in LabView from a DLL, and then access the global variable of DLL

    I've created a DLL in LabWindows with a function and structure.  I want to call the function from LabView and then access the overall structure.  I am able to call the function in the DLL with a "call library function node" and has access to the return value, but I can't understand how to access the overall structure.  The structure is declared in the header DLL with __declspec (dllimport) struct parameters file.

    Is it possible to access this structure without using the library of network variables?

    My guess is that you need two bytes of padding after "in_out" and another to two bytes of padding after "anin."  The reason being that ints are 4 bytes, and most of them C compilers will align on 4-byte boundaries.  The struct will naturally start to such a limit (in fact, in Windows, it will probably start to an 8 byte boundary).  If you then count bytes in your structure, you are 70 byte after "in_out."  70 is not divisible by 4, so you need 2 bytes more to reach the next 4 byte boundary.  You can also you could reorganize your struct so that "anin" follows "in_out" and this is probably the best option if it won't cause you other problems.

    Unlike most C compilers, LabVIEW compressed structures as closely as possible, without filling.  I don't know enough about the history of LabVIEW and internal parts to explain the reasons and to do this performance penalty, but, as choice of LabVIEW "endianness", it is probably a remnant of the first versions of LabVIEW that were running on the Mac.

    If for some reason you want to force your C struct to match package LabVIEW, you can use the #pragma pack (x) directive, but I wouldn't recommend that here because you can control the C and LabVIEW.

    EDIT: in the cases where it was not clear, add padding to your cluster of LabVIEW, insert appropriate size or items at the place desired in the cluster.

  • [BUG] TestStand 2013 receives corrupt data to LabVIEW adapter if the cluster contains waveform array

    Hi all

    I am having trouble with the corruption of the data. My minimal test case is below.

    I have a VI that returns an array of clusters. My TestStand sequence simply call this VI and connects to its output:

    When I run the (with my open VI) .seq file, I can see the update of the Panel before LabVIEW with expected values:

    However, TestStand receives all these values. Waveform bays have the correct values, but everything else is empty / null:

    If I delete my typedef waveform table, all elements of the cluster are correctly registered by TestStand.

    I've attached an example of test (2013 TestStand, LabVIEW 2013) case.

    Any ideas on how to make it work?

    Hey JKSH,

    Thanks for the detailed on this report. I looked into it a little bit last week.

    I think that it is closely related to the 206892 of CAR, which describes a problem where data will not appear on the report unless a property or variable is specified for the output waveform parameter. However, this does not completely cover your case, because you see incorrect digital data in the row with the waveform of your cluster. I filed 462209 CAR for that matter, and we will investigate it more thoroughly.

    This problem only affects data that appears "below" the waveform in the cluster. In the case of the sample, if you put the waveform as the last element of the bunch, I think that it works correctly. I know that your real data could be more complex than this example, but this workaround solution would help in the meantime? You could also consider separating the waveform of the rest of the data, that would probably work too.

    As I said, please let us know, and it is classified in our system now for a developer to investigate the matter. Please let me know if solutions are not appropriate for your application, we would be happy to know a little more about your overall use case order to work around the problem.

  • How to set the value of a variable in a cluster in LabVIEW to c#?

    Hi guys, I'm working on a small c# program, which by using the interface provided by LabVIEW.  And I know that, with the help of lv. SetControlValue (name, value) can set a variable just on the front panel. But in my case, there are several groups on the front panel. Then it confused me how to set the variables in these groups. For example, there is a cluster named clusterA and a variable named a., I tried something like this:

    lv.SetControlValue("clusterA.valueA",1);
    

    but it totally inoperable. Everyone has some experience with this sort of thing? Thank you very much!!

    Hey guys, thanks a lot for all your response. I just found a simple way to solve this problem. For example, there is a cluster named "ClusterA", and there are only two witnesses, who are: an int value named "IntA" (default = 10 IntA value) and a string value named "StringA" (by default the StringA = 'abc'). In c#, if you call the method:

    var clusterA is vi (Array). GetControlValue ("ClusterA");

    you will get a table looks like: clusterA = {10, 'abc'}; So if you want to change IntA 123, you simply do:

    clusterA.SetValue (123, 0); 123 the value, 0 is the index of IntA in clusterA, after this clusterA table = {123, 'abc'}

    After that, simply to make the table in LabVIEW using:

    VI. SetControlValue ("ClusterA", clusterA);

    and now you see the LabVIEW, IntA is changed.

  • Strategies for bridge (structs) containers to the c dll table ++

    Does anyone have any suggestions for the passage of tables of containers (C structs) between TS and c ++ dll? I have exhausted my understanding here. I noticed that when I create a type which is an array of containers (size = 1), allow to move like a C struct but exclude the container as C struct, and then type presents itself as a struct rather than an array ref in the C++ dll parameters dialog box. I was hoping that I could exploit something here, but not luck.

    As a last resort, I could try to flatten the structures in an array of double, pass it as a VARIANT and rebuild on the other side - yuck!  I have hundreds of different transfers to manage that way, so I'm still holding hope for something better.

    In C/C++, I think that if you define a structure with a table like this:

    struct {Topic2

    int sizeVar;

    Topic1 array [size];

    }

    Then, the size is fixed. It doesn't really change because the compiler whenever you allocate a variable of the type of structure, must allocate enough space to store all the items that you have declared in the definition of struct. In other sizeof (Topic2) includes the full size of the array defined using the constant of 'size' that must be a constant, not a variable. If you want something more dynamic, you declare your structure as follows:

    struct {Topic2

    int size;

    Topic1 * array;

    }

    you dynamically allocate the memory for the array pointer and release it dynamically when you're finished with it.

    A simpler approach, that you can take, if the size range is quite small, is to make the Board as large as size max you will ever need and add another Member to say how many items in the table is actually being used. And it seems that your def struct is close to that, but not quite right. For example, I'm sure that you can not use the size for the variable field and the size of the array. Instead, you probably need something more like this

    struct {Topic2

    int numElements.

    Topic1 table [taille_max];

    }

    Hope this helps,

    -Doug

  • Can I automate creating a cluster in LabView using the structure of data created in a generated automatically. CSV, C header or XML file?

    Can I automate creating a cluster in LabView using the data structure created in an auto generated. CSV, C header or XML file?  I am trying to take the data structure defined in one or more of these files listed and have LabView automatically create a cluster with structure types and the same data.  (Ideally, I would like to do it with a C header file only.)  Basically, I'm trying to avoid having to create the cluster by hand, as the number of cluster elements could be very large. I looked in EasyXML and contacted the rep for the add-on.  Unfortunately, this feature was not created yet.  Did anyone done something like this before? Thanks in advance for the help.


  • Error-18004; Access to the DLL of the LabVIEW Run-Time Error engine. TS 4.2.1 / LV 2010

    When I try to run a VI that is reentrant in an execution at the same time, I get this error.  The details of the error is: LabVIEW: the method or property is not supported in this version of LabVIEW.

    This is performed under the LV 2010 Simple operator Interface.  The TestStand engine is version 4.2.1 with runtime adapter 2010 LV.

    If I save to an earlier version to LV 2009 SP1, then assign the adapter TS 9.0.1 (2009 SP1), it works.

    Can anyone reproduce this error (bug?)?

    you have the latest updates for TestStand using LabVIEW 2010?

    http://digital.NI.com/public.nsf/allkb/7D728B70F167CE088625776E00582C7B?OpenDocument

  • Call the library function does not find the DLL in the directory where are my LLBs

    I'm using LabVIEW 8.6.  I have a set of screws in several LLBs.  All LLBs located in a directory.  Most of my screws is wrappers for the functions in a DLL.  I was told to put my DLL in the directory where are the LLBs, and apparently this is how the previous programmer has worked (using an earlier version of LabView).

    In the configuration of the library call, I've specified .dll without path.  (This is how we want our screws are an API that will integrate other programmers, so I don't know where they put things and I can't use absolute paths).

    When I insert the VIs in LabVIEW, LabVIEW can not find the DLL and wonder of spotted.  It's just that here in the directory with the LLBs and when I double click on it, everything works fine.  However my absolute path to the DLL now appears in the library to call configuration, and we don't want that.

    Does anyone know how to make this work?  I guess the location of the screw (or LLBs, in this case) should be the current directory and thus Windows search there for the DLL.  However, it seems that this is not the case (in the least, in the latest version of LabVIEW).

    Thank you.

    Batya

    Well someone using your library should not have to dig into your screws and do it all on his own. Instead your library must wrap that and hide disorders it altogether.

    The cluster of error has been added when the dynamic path option has been added. It is not useful hide this error output, so it's always there. As well as the dynamic path, there was the improved error handling added the CLN. One of them is that the level of verification when calling function errors (exception handling) can be specified. I guess that some of these options may generate an error code instead of bring up a dialog box, as they did before and that the output of error code can be useful even in the case of static calls.

    As to what you want to do, I would have long managed that with a DLL that has essentially the same functions as your other wrapper DLLs and an initiliasation function that returns a pointer to a structure of functional distribution based on the actual DLL you want to call. Quite like what an object-oriented function dispatch table is. Then, when your interface initilising you call initialize function and specify the device interface/type that you want to use and after that all other functions take a pointer extra function parameter expedition as the first parameter, in addition to the parameters of the real function. This dispatch function pointer would be just a pointer to a structure that contains the table of function for this interface pointers and the sake of LabVIEW would simply be an integer of size pointer.

    The wrapper function then checks the pointer structure validity send feature and call the actual function with the remaining parameters. It is a C programming and may require a planning and desigining the different interfaces to facilitate this kind of technique of the expedition, but it will certainly pay to long-term and make your library even can be used in previous versions of LabVIEW, so that VB etc. without delicate dynamic loading in the level high, programming environment.

    Rolf Kalbermatter

  • Cannot run Simulink DLLs at the same time that the execution of the target time real VI

    Hello

    What I try to do is run a dll created in the Simulink model to control some servo through a CompactRio 9014.

    For the moment, I managed to create three screws

    (1) in the FPGA target that performs the PWM channel desired

    (2) which takes the value of a variable that contains the desired position and network that feeds to the 1st VI

    (3) a VI that is running on the host computer that changes the value of the network variable to change the position

    I can get these three work screw and the servo controlled, but when I try to update the value of the network variable using simulation, by deploying to the target of RT simulation and running, he said:

    ' Access denied: this objective is already used by another host or project. »

    I guess that's because the project is already connected the cRio, so I unplug and am able to deploy the model files.

    However, when I try to run one of the screws in the Targer RT as well as simulation I get the error:

    "This VI is downloaded to the target, but is not present in the project you are trying to deploy.  All the screws on the target will be closed unless you choose to add the missing project VI. »

    With a large number of missing screws...

    I'd do this wrong, i.e. is there a simpler way to control inputs FPGA using the simulation, or is there something I have missed?

    Thank you

    Geoff

    Hi Geoff,

    I think I understand what you're trying to do and what you've done so far.

    If I'm not mistaken you have passed through the SIT connection manager, set your target RT (select DLL, mappings and hardware i/o) and this is his 'magic '.   If this is the case of look for the project pilot LabVIEW which was created by the SIT connection manager.  This should live in the same folder where is your DLL.  Open the pilot project, search for VI driver and open it.  Then go into the Sub - VI # 5 has with the name of the loop rate Base.  It's the Subvi who reads/writes on the material and the reads/writes the data to the DLL/OUT model.  If you want to read the output of your model and then manipulate the data that is where you need to add your code.

    Inside of this Base rate loop VI there is a Subvi with number 4 and called SIT take model Timestep.  This VI is the one who makes the call to the DLL model.  The output of this VI is your data from the model.  This data goes into slot - VI # 5, which is responsible for the drafting of these data to the material.  Since you want to manipulate that data from the model, you need to recover data from the wire coming from the Subvi 4 (SIT take model Timestep) before it gets to the Subvi # 5.

    In this VI of Base rate loop, you will see that there are a few empty block structures.  These images are for you to put any code you want.  The reason is that any changes you make to the driver VI and subVIs that aren't inside of these frame structure will be lost if you decide to go in the connection manager to sit DOWN again and make some changes.  The VI pilot gets new script whenever you do something in the SIT connection manager.  Whatever it is inside these frames will not be erased.

    So, if you have a code you want to run in parallel to the simulation you just have to drop it inside this driver VI.  Very probably within this Subvi 5 (Base rate loop). To add your code just drop the VI in one of these settings and make any changes that him so that he can read the data in the model.    Furthermore, the model (Subvi 5) data in a table.  For the index of each element in the array and its meaning look for a file in the same folder where the DLL is named readme.txt ports.  This file has a description of the inports and small ports and their indexes.

    This VI driver is called when run you the host VI so you won't have to run sepearately.

    Kind regards

    Ricardo

    National Instruments

    Systems engineering

  • How to read COM of DLL (Component object method) in Labview 8.6.1

    Hi all:

    Today, I found it difficult to read the COM (Component Object Method) in the DLL file in Labview. I've only managed to read a function exported in the dll file using the library call with Labview function block diagram, software programming. Please give me advice or solution to solve my current problem encounter. Thank you.

    The figure below is the way I recover the function of dll file. The function block manage only recover the function exported in the dll file.

    Hello

    I just want to share a solution that works for your problem:

    1. save the DLL in Windows
    -Go to \WINDOWS\system
    folder
    -Copy-paste your dll file in
    This file, TraceDataV28_test18.dll
    -Open the command prompt (cmd), go to the directory<>
    file > \WINDOWS\system
    and type REGSVR32
    'TraceDataV28_test18.dll '.

    -A pop-up window should appear to inform you that
    It has been registered

    2. use
    Node property/invoke:
    -Open
    LabVIEW
    -Drag and Drop invoke node to
    Range of functions > Application control > invoke node
    -Right click on it and Select
    Class > ActiveX > Browse...

    Find your DLL file, and you can choose what COM method you want
    use.

    Hope its helpful.

    Sincerely,

    Krisna

  • Remove the cluster of clusters table

    Hi I have this program where you have an array of clusters and when you press a Boolean 'Add' button, you can add clusters to the table up to a certain limit, and it is written in a spreadsheet file. I would like also to such a function when you click on 'Remove' Boolean you can remove the cluster from the table so that the new table takes place 1 old and cluster information are removed from the worksheet so file. How can I do?

    It does not need to have the cluster, use instead to build table (for best performance initialize the array and use replaces primitive subset of table). You cannot delete items in a file, but you can read the file and remove the item and he write to the file. If it is a sub VI, you add/remove items and writing to a file each time that the sub vi is called? Do not write to the spreadsheet VI file in this case, use instead write to text file primitive. See examples of LabVIEW for some useful examples on file i/o.

  • How to access the property of ListBox inside the Cluster element names?

    In LabVIEW 2010, I have a group of controls on the front panel. In this group, I have a ListBox. How can I access the Item property for the ListBox object names in my block diagram.

    Of the bunch, I can get control ListBox, but which returns a value of I32, probably the index of the selected item.

    In the block diagram, how can I get the name property of the item in the ListBox control since a reference to the Cluster?

    Thank you.

    using the table 'orders' in your cluster, you can access each item. Next, you will need to convert the reference to a 'class more specific' with a reference to an arbitrary list box (or a constant reference of the required type), then you can access all the properties of your listbox.

Maybe you are looking for

  • iPad available incompatible storage

    Hello, everyone. I just check the available space on my iPad and apparently I have 6.5 GB free even though yesterday there was a 6.9 GB free. I have not downloaded or installed anything. Then I check the storage available through iTunes and it says I

  • Viewer does not, winning 8.1

    It all started like this: I opened iTunes after another day to ignore updates (if it is not broke, don't fix it) and was struck quite oddly with a message "unsupported video playback. Then I googled the error and somehow, it seems that iTunes had man

  • my screen will Dim when I plug my battery cable

    whenever I plug my battery cable into the light going darker and I like it on the lighter, I see that I do not see

  • Well Yes, I'm new here

    Hi all, I just bought an Acer like A10-nice tab to replace my old Iconia tab. So, I'm old and new, LOL

  • ES1-512-C5YW - black screen

    When I was with this laptop, the screen suddenly really turned very dark. If I looked closely, I could see that the open Web page was still there and everything properly. I turned off the laptop and then on again, but now nothing can be seen even whe