LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

When

I create a DLL file in which a function returns a pointer to an 1-D array.
Then I call a CLF.
But when my program runs, labVIEW closes automatically.
I don't know what's wrong with my program?
Can someone help me?
0 Kudos
Message 1 of 27
(6,645 Views)
Oh,I forgot the title!
0 Kudos
Message 2 of 27
(6,623 Views)
There is no pointer data type in LabVIEW.
 
you can configure DLLs to get the pointer of input data instead of the value itself, but if the function's output is a pointer you can not use it directly.
 
Try this: As you've seen in DLL nodes, there are input and output terminals for any data, whether you have defined it as input or as output. so if the function's output is a pointer to a 1D array of bytes (or anyother type of data) I suggest you connect an initialized 1D array to the input terminal and get it from the output terminal.
 
attached bmp may clarify what I mean.
Hope this helps.
 
0 Kudos
Message 3 of 27
(6,611 Views)

Thank you,Soroush!

I've seen an example,as the attached bmp file below.

you can see the CLF's first input parameter conneted to nothing,but it gets an 1-D array output.

So can you explain how the CLF and DLL work? I'm confused.

Thanks!

0 Kudos
Message 4 of 27
(6,587 Views)

Hi,

Right Click the DLL node and select "configure..." to see DLL's settings. In the "parameter" box, select data related to 1D array and check settings.

I think it is quite different from my example. As a general law, whenever you have pointer values as outputs of DLL nodes, you should do some tricks to get that data correctly.

Don't hesitate to ask more if you think it'll be helpful.

 

0 Kudos
Message 5 of 27
(6,577 Views)
Hello!
I think maybe the function in that DLL returns an pointer to an 1D array in the example I attached.
So I created a DLL file in which a function returns a pointer to an 1D array.
I tried to get the output,but I failed.
Maybe you can do this experiment too,will you?
I'm very glad to E-mail you the DLL's C++ resource code.
It's very simple.
Thanks!
0 Kudos
Message 6 of 27
(6,563 Views)
Hi,
 
I've attached the configuration window of the VI in my first post. See the Function prototype window. As you notice, the "data" is a pointer to an unsigned byte. in that case I knew that the pointed byte is the first byte of a byte array. the length of that array is different for any "object type". I emphasize that the DLL is saying that it will accept a pointer to the byte. but I've fed what you saw in the first bmp.
 
you should think of some similar trick. forget using pointers as outputs. There should be a way to use any DLL with any function prototype in LV.
 
The source code of your DLL is not necessary. upload only the function prototype description file (*.h or something like this) and highlight the function you wanna use. I encourage you to discover it yourself, but I'll be glad to try it too.
 
Regards.
0 Kudos
Message 7 of 27
(6,544 Views)
forgot the attachment!
0 Kudos
Message 8 of 27
(6,543 Views)
Hi,thanks!
I'v been busy these days.I will try later as you advised.
0 Kudos
Message 9 of 27
(6,491 Views)
I am having a little trouble with pointers in labview. Can anyone verify if what I am doing in labview is correct on the CRC button?
 
Here is my code for the CRC.

_declspec(dllexport) unsigned int CRCMode(unsigned char *start_addr,unsigned char *end_addr,unsigned char* data)
{

DWORD iBytesWritten;
DWORD iBytesRead;
unsigned char ch[36];
unsigned char putin[15];

  putin[0]='C';
  putin[1]= ' ';
  memcpy(&putin[2],start_addr,4);
  putin[6]= ' ';
  memcpy(&putin[7],end_addr,4);
  putin[11]='\0';
  putin[12]='\r';
     WriteFile(hCom,putin,13,&iBytesWritten,NULL);
  ReadFile(hCom,&ch,sizeof(ch),&iBytesRead,NULL);
  ch[35] = '\0';
  data = &ch[0];
  return 0;
}

Message Edited by Newguy100 on 08-22-2005 10:56 AM

0 Kudos
Message 10 of 27
(6,377 Views)