LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem about calling a DLL in LABVIEW

Hi,
I have a problem using Labview to call a DLL file, when I call the function " commandinterp() in labview, labview will always return error message"an error occured in external code, it might  have corrupted labview memory..."  attached is the DLL file and the labview code .so did the code i attached have any problem? or is it the problem of the DLL?  thanks
 
Download All
0 Kudos
Message 1 of 10
(4,100 Views)
Did you develop the DLL using the N.I. guidelines? Doesn't look like what I'm familiar with. Only other thing I see that you should correct is the type of the return value for the "commandinterp" function. In the DLL code its an "int", in the Call Libary Function its an unsigned char. Make the one in the Call Libary Function an I32 since you're returning a "-1" in the function.
0 Kudos
Message 2 of 10
(4,097 Views)
It looks to me that he might be missing an input parameter. 
 
The line shows   int commandinterp (char cmd_line[]) {
 
So is a char type being input in the function to be used as the variable name cmd_line?
 
The attached VI does not show any input parameters doing into the DLL call.
 
(I am not entirely sure.  Since the dll itself was not attached, I had to tell Labview to ignore the item when it looked for it.  Perhaps the way the VI opens up when the dll doesn't exist on my machine is different then if the dll did exist.)
0 Kudos
Message 3 of 10
(4,084 Views)
It looks to me that he might be missing an input parameter. 
 
The line shows   int commandinterp (char cmd_line[]) {
 
So is a char type an input argument for the function to be used as the variable name cmd_line?
 
The attached VI does not show any input parameters doing into the DLL call.
 
(I am not entirely sure.  Since the dll itself was not attached, I had to tell Labview to ignore the item when it looked for it.  Perhaps the way the VI opens up when the dll doesn't exist on my machine is different then if the dll did exist.)

Message Edited by Ravens Fan on 07-20-2007 12:01 AM

0 Kudos
Message 4 of 10
(4,087 Views)
I don't know why my message got entered twice.Smiley Surprised
 
But this looks like a new message thread based on a conversation already going on here http://forums.ni.com/ni/board/message?board.id=170&message.id=260212#M260212.
 
You really should keep the conversation in one thread rather than creating a new thread on the same topic.
0 Kudos
Message 5 of 10
(4,076 Views)
You're right, Raven's Fan.....good catch. What I think is happening is that the DLL function is thinking its popping the input parameter (pointer to char string) off the stack, but instead its popping the return address since the input parameter never got pushed on the stack in LabVIEW. It tries to dereference the "cmd_line" parameter using the return address. Before its done it apparently tried to corrupt LabVIEW memory (or maybe even succeeded).
0 Kudos
Message 6 of 10
(4,072 Views)
Hi,
I am not aware of developing the DLL using the N.I. guidelines, could you please let me the detail on where to find this NI guidelines? thanks,
 
 
0 Kudos
Message 7 of 10
(4,050 Views)
Hi Bill,
Is the following link the one you mentioned for developing a DLL in VC++ for use in Labview? the link is old and for labVIEW 6.0, so does it still work for labVIEW 8.0?
http://digital.ni.com/public.nsf/allkb/BDB89D1B9EEA138E86256CCD005C3AE7
0 Kudos
Message 8 of 10
(4,042 Views)
Unfortunately, I haven't done anything with DLL's or  CIN's since LabVIEW 6.1 so I'll defer your question to someone who has more up to date domain knowledge. In the meantime I'll also search the NI website for any DLL info pertinent to LabVIEW 8.x
0 Kudos
Message 9 of 10
(4,025 Views)
Hi Happybird,
 
The outline for creating a DLL should be the same regardless of which version of LabVIEW you are calling the DLL from.   The following link describes how to call your DLL into LabVIEW with a Call Library Function Node:
 
Call Library Function Node
 
Regards,
Elizabeth S.
Applications Engineer
National Instruments
0 Kudos
Message 10 of 10
(3,985 Views)