06-09-2010 03:10 PM
Hi Rolf;
Thank you so much for your response. I 've committed so much time on this that I am more willing to use labview dlls. I am wondering if you have any suggestions as to what to change on the read. vi (my read vi is on my previous post) so that I can convert it into dll and read it in the vc++ environment. I did this successfully for a double number. In this application, my server sends a double number, and I read this number with Labview read.dll on the vc++ side just fine. Now, I am trying to do the same with an array. I would really appreciate if you could let me know how to do this.
Again thank you so much for your response.
Kind Regards.
06-09-2010 03:43 PM - edited 06-09-2010 03:44 PM
Whe creating the DLL, define for the function parameter to be an Array Data Pointer instead of an Array Data Handle. Now the DLL will accept a simple double *arr parameter as any C compiler can handle it. Allocate the array in the caller to the correct size and also pass in the size to which it is allocated.
06-09-2010 03:44 PM
Hi Rolf;
I am wondering if I could use LabVIEW "Flatten to String" function and unpack it in the c++ environment. The array that I want to pass to my c++ application is a 2d double fixed size array. So the only thing that I have to unpack this...I am wondering if this is a valid approach and if yes, can you guide me how to unpack this on the c++ side.
Thank you so much.
06-09-2010 03:55 PM
You can write the Unflatten function for this specific data array easily yourself in C. First read in from the TCP/IP stream two 32 bit integers (8 Bytes). If you are on a little endian machine, then change the endianess of these two integers (MSB to LSB conversion).
These two values indicate the two dimensions of the array. Now multiply these two integers which will tell you how many 8 byte doubles are contained in that array. Read in this number multiplied by 8 bytes from the TCP/IP stream. This is now the array data. This data should be also byteswapped and there you have your double number array in C.
06-09-2010 03:59 PM
Hi Rolf,
Thank you so much for the response. Are you typecasting the output of the tcp-ip read block? Because in my vi I am using "unflatten from string" when I do that my vi output, I can not see an option for Array Data Pointer as you can see in the picture attached.
Thank you so much!
06-09-2010 04:08 PM - edited 06-09-2010 04:09 PM
06-09-2010 06:41 PM
07-12-2010 02:14 PM
Hi;
I am wondering if there is anyone out there who can help me out with the problem defined in this thread. In a nutshell, I am sending a 1d array to a port using Labview TCP/IP blocks and I am using three Labview dll files to read the 1d array at the port in c++ environment. The labview dll files were converted from vi files and named as, init, read and close, respectively. "Init" initializes the port, "read" supposedly reads the port and write the content of the port to an array called Myarray, and finally close closes the connection. I attached the labview created read.h file along with the read.vi file. I would appreciate any answer.
Kind Regards,
Serdar