LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Labview.lib was not called from a labview process

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. 

0 Kudos
Message 11 of 18
(1,353 Views)

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.

 

DLL Array Parameter.PNG

Message Edited by rolfk on 06-09-2010 10:44 PM
Rolf Kalbermatter
My Blog
0 Kudos
Message 12 of 18
(1,341 Views)

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.

 

0 Kudos
Message 13 of 18
(1,340 Views)

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.

Rolf Kalbermatter
My Blog
0 Kudos
Message 14 of 18
(1,330 Views)

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! 

0 Kudos
Message 15 of 18
(1,328 Views)
No typecast at all.And I can't see anything in your picture as you have not selected the array parameter Smiley Wink
Message Edited by rolfk on 06-09-2010 11:09 PM
Rolf Kalbermatter
My Blog
0 Kudos
Message 16 of 18
(1,320 Views)
Hi Rolf;
I really really appreciate your answers! I have one more question (hopefully last). When creating the dll, I defined the function parameter as Array Data Pointer as you suggested. I also made some modification as shown in the picture attached. Now I am using the following simple c++ code to read the output. However, I can't see anything on the screen. Do you have any idea why? Again, thank you so much!!
Kind Regards 
 
 
int main(int argc, char* argv[])
{

      uInt32 a;
      
          double MyArray[8];      //Initialization of array
  
 a=Init();      //Initialization of THE PORT

 int i=0;
  
  while (i<1000)
  {
      
 Read(a,MyArray,8); //READING THE OUTPUT OF READ.DLL
 
          std::cout << "The result is" << MyArray[2] << '\n'; \\PRINTING ONE MEMBER ON THE SCREEN
      
          i=i+1;
 
  }
 
Close(a);  //close the port
   return(1);
}
Download All
0 Kudos
Message 17 of 18
(1,303 Views)

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

0 Kudos
Message 18 of 18
(1,221 Views)