Jump to content

labviewbeginner

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by labviewbeginner

  1. thanks for the big explaining.

     

    Yes i tried it also with memcpy(pointer, datatable, sizeof(datatable));

    But all the time labview crashes (just close without warning) when i start labview.

     

    I made me a test.vi: in this i just want to get the data from c to an array in labview.

    I did this:    constant uint16 - bundle 7 times to get a cluster with 7 uint16 - then i made "initialize array" and wired the cluster in the above input and by the dimension size i made  "constant int32" (this data type came automatically) then i wired it to the CFN. In the CFN i made "return type = numeric, signed 32-bit Integer" "arg1 = Adapt to type -> Handles by value".

    My C code is this:

     

    struct{ 7xuint16_t Integer}table;

     

    table datatable[16];

     

    int32_t LV_DLL_EXPORT func(struct *pointer)  

    {

         copy_to_datatable();

     

        memcpy(pointer, datatable, sizeof(datatable));

     

        return 1;

    }

     

    in the CFN the prototype is this : "int32_t func(void *arg1);

     

    And then i wired the CFN with an indicator array. This array i build like this in the FP : i took array. Then i took a cluster and put this into the array. In this cluster i put 7 numeric constant of the data type uin16.

    So now i have an 1D array with one cluster with 7 numeric constants. now i just raise the size of the array that i have 16 clusters in line.

     

    But still if i want to start the vi. it crashes without saying anything. So i think that i write or copy something into a position in the memory where something is written so that it should not be copied there.

     

    Or can you explain me what i make wrong?

     

    thanks anyway for the big help to understand it better.

     

    regards.

    labviewbeginner

     

     

    ps: i put labview screenshots attached

    post-52525-0-24500500-1407226349_thumb.j

    post-52525-0-97473800-1407226350_thumb.j

    post-52525-0-64866800-1407226352_thumb.j

    post-52525-0-38227200-1407226355_thumb.j

  2. Thanks for the answer,

     

    1) yes you are right. But at least i have to try it :).

    2) But the memory usage of the C file should be fitting to the labview vi. Am i right? So i need to know how i can solve this difference between the C 224-Bytes and the labview 224+x Bytes for the dataspace management. How can i do this?

    3) ok thanks. So am i right that i need to use the CFN not the CIN?

    4) ok if i have the struct and the function like above:

    struct{ 7xuint16_t Integer}table;

     

    table datatable[16];  (here is C allocating the memory for the array with struct of integers if i am right)

     

    int32_t func (struct *pointer)

    {

         copy_in_table();  (this copies my data into the table)

     

        pointer = datatable;  (did you mean it like this? that i can give the pointer the data of the table, because C is using arrays as pointers as i read somewhere)

     

     return 1;

    }

     

    Is this correct? Because if you say yes i dont know why my Labview all the time crashes without any error warning. it just closes itself.

     

    Yes sorry for this i will stick to this forum.

     

    Thanks.

    LabviewBeginner

  3. Hello,

     

    i have a problem.

     

    I am writing a C code and i have to edit an existing Labview code.

    My big problem is with the CFN that i dont know how to get the data from the array of structs with integer (array of 16 structs with 7 integer elements) into an array of cluster of 7 integers.

     

    I tried it with struct {..7 integer (each uint16_t)..}table;  struct table[16];

    "int32 func (struct *pointer)" and memcpy( pointer, table, sizeof(struct)*16); , and then my labview crashes without any error warning. And i found out via debugger from visual studio, that i think memcpy is saving his data into the memory of labview where it isnt allowed to save it.

     

    so my first question is:

    1) if i make a numeric constant and bundle 7 types of it to one cluster and use "build array" and make all of this before the CFN, is the memory for this allocated and the value is "0"?

    Second:

    2) how much bytes are allocated for this? How can i look how much bytes does an array of 16 cluster with each 7 uint16-integers need?

    3) What is the difference between Call Library Function node and "call interface node" exactly?

    4) If i have another three function in C which copies some data into the C array "table" how can i get the data from this "table" into Labview when i only have the possibility to return void, numeric or string??

     

    Because as far as i know i need in Ansi C for the array of 16 structs with 7 uint16_t-Integers  224 Bytes (16*7*2Bytes) . Am i correct by this?

     

    I think the most problem is about the memory handling here.

     

    About help i am very grateful.

     

    Sincerly

    Labviewbeginner

×
×
  • Create New...

Important Information

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