Jump to content

Wolfcastle

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by Wolfcastle

  1. Hello there,

    I just checked out your example passing in an array of clusters.

    What I tried but did not work is this example:

    • I created an array of clusters of two elements.
    • then I selected "adapt to type", handle through value

    The resulting c Code for the types is this one

    typedef struct {

    double x;

    double y;

    } TD2;

    typedef struct {

    int32_t dimSize;

    TD2 Cluster[1];

    } TD1;

    typedef TD1 **TD1Hdl;

    So, how do I manage to acces e.g. the second cluster element? I tried this:

    int32_t funcName3(TD1Hdl arg1, int32_t size1, int32_t *value)

    {

    TD2 clusterElem = (*arg1)->TD2[1];

    return clusterElem.x;

    }

    But this code always returns 0.

    Does anybody know why?

    Regards

    Wolfcastle

    Hello,

    Thanks for your reply. I have figured out how to manipulate the data with the "Array Data Pointer" data format. It is actually quite easy. You simply need the type def for the cluster that you are passing in with the array. Then you change the void in the fct prototype created by labview to match whatever typedef you created. You can access individual elements in the array by incrementing the pointer to the array. For instance, passing in an array of simple clusters to the DLL (simple meaning just two unsigned 8 bit ints), you create the typedef in the header file and passing in say "ClusterArrayIn" with the prototype looking like so...

    void passClusterArray(TD1 *ClusterArrayIn)

    all you do is replace the void created by LV when you right click the Call Library Function Node with the Typedef defined by the type of cluster you are passing.

    with type def 1 being the cluster

    and the type def looking something like this

    typedef struct

    {

    uint8 num1;

    uint8 num2;

    } TD1;

    void passClusterArray(TD1 *ClusterArrayIn)

    {

    (ClusterArrayIn+1)->num1 = 10;

    (ClusterArrayIn+1)->num2 = 11

    }

    There may be an easier way to manipulate the data but this isn't too bad. It just took a while to figure out how to do this because the documentation on it is not great. Also,

    you must pass in the length of the array as a separate argument. But that is easy because you can pass that by value!

    Thanks for the assistance

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.