Jump to content

c/c++ and LabVIEW


Recommended Posts

hi

I am perlexed in my current work! How to pass an array to LabVIEW for computing, and return the result from LabVIEW? The result is array format. Fortunately, i have done an example to handle a double value not array, so, i want to ask somebody who have done the similiar work for help:-)

I know that it need make a function prototype in the process, is it achievable below?

//the input array is from c/c++,and this function should return an result which is an double //array format, how can i build prototype through the App Builder

double [] HandleByLV(double input[], LVBoolean f, char s[], long len);

At present, i just make a function like this:

void HandleByLV(double input[], LVBoolean f, char s[], long len double output[],long len2);

or

void HandleByLV(double input[], LVBoolean f, char s[], long len, TD1Hd1 *output);

Who can help me to solve this problem?

thanks very much!

Email:lyy_csu@hotmail.com

Link to comment
hi

I am perlexed in my current work! How to pass an array to LabVIEW for computing, and return the result from LabVIEW? The result is array format. Fortunately, i have done an example to handle a double value not array, so, i want to ask somebody who have done the similiar work for help:-)

I know that it need make a function prototype in the process, is it achievable below?

//the input array is from c/c++,and this function should return an result which is an double //array format, how can i build prototype through the App Builder

double [] HandleByLV(double input[], LVBoolean f, char s[], long len);

At present, i just make a function like this:

void HandleByLV(double input[], LVBoolean f, char s[], long len double output[],long len2);

or

void HandleByLV(double input[], LVBoolean f, char s[], long len, TD1Hd1 *output);

Who can help me to solve this problem?

thanks very much!

Email:lyy_csu@hotmail.com

I'm no expert in c++ but LabVIEW will only be able to handle standard C types. They also are the only types that are really standard across C compilers.

I think the best is to declare your function prototype as standard C such as:

#if defined(__cplusplus) || defined(__cplusplus__)

extern "C" {

#endif

int MyFunction(double array[], int length);

<other function protoypes you want to export from the DLL >

#if defined(__cplusplus) || defined(__cplusplus__)

}

#endif

This should tackle most of the problems with C++.

Rolf Kalbermatter

Link to comment

Hello;

The simple answer to your question is yes, you can return an array from labview.

Or you can pass a pointer to an array and labview will modify it.

By default, labview passes values using pointers.

Indeed the previous poster is correct in that you are limited to certain function definitions;

but if you are the one writing the code, you can usually find a way to recast things so they work.

The first thing to decide is who do you want to allocate the memory ?

Labview or your C++ program ?

Let's assume you assume you want your C++ to handle memory.

Then you simply configure the call library function to pass the variables from labview by values.

You can also do it the other way around and leave all the memory management to labview.

Good luck.

Walt

thanks for your reply

You said that it is need a function prototype like below:

int MyFunction(double array[], int length);

However,the function just return a int value not an array! Can LabVIEW return an array to c program in a time? How do it?

Link to comment

thanks for your reply.

In fact , i just want to use VIs in LabVIEW to do a calculation. All the datas from the c or java and LabVIEW handle them.Meanwhile, LabVIEW should return the result which are arrays or other data types.

Now, i am perplexed, i don't know how to obtain the array and how to program with c or java. i guess that it should operate on the pointer ? how to realize it?

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

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