From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
01-22-2007 01:37 PM
01-22-2007 03:39 PM
01-22-2007 04:27 PM
@alrite wrote:
Hi!I am using a dll to run a program from labview. The dll file has a function error_msg(int16 code, char *dst). I am using the Call Library Function node to call up the command. However, am not sure what type and data type I should use for the char *dst since there is no option in the configure menu.
Thank you for your time and help.-Amrit
Hi Amrit,
You'll need to obtain the instructions for the DLL to know how to interpret "char *dst" - it might mean a pointer to a single char, but more frequently this specifies a "string" parameter - or even an array of bytes! If this parameter is really a pointer to a single char, then tbob's instructions are perfect!
Cheers.
01-22-2007 05:15 PM
01-23-2007 04:17 AM - edited 01-23-2007 04:17 AM
Watch out! From the context of the function name I assume this parameter is a string buffer the function will use to write the message into. And that means you will have to create a LabVIEW string that is long enough to contain the longest possible string the function might return. Configure the parameter in the CLN to be a string, passed as a C string pointer.
It is very important that you do not pass in a to short string or even an empty string. The function has no way of resizing the string as a LabVIEW node could, so it just assumes the buffer is big enough to write in whatever it needs to write. If your buffer is to small it will overwrite more or less important data in LabVIEW causing symptoms such as immediate crashes (exeception dialog), random crashes at a later stage, corrupted VIs when saving them to disk, or even only a crash dialog when exiting LabVIEW. Whatever you get it is a bad sign and could change at any time into more serious problems and if any of these symptoms arise you know almost for sure that a DLL function gets called with a to small buffer somewhere.
Rolf Kalbermatter
Message Edited by rolfk on 01-23-2007 11:18 AM
01-23-2007 05:40 PM
Thank you for your assistance! It has been extremely useful. So I have a question, how do you set the string length that you want to pass in, I want my string length to be 150, but do you just type '150' into the string constant box, or is there something else that must be done?
Thanks again for your time and help!
-Amrit
01-23-2007 06:05 PM
You can create a U8 array with 150 elements, set all elements = 0 (NULL). Use Replace Array Subset to put other characters (ASCII code of each char) into the array. The array should always be 150 elements in length. Pass this U8 array into the Call Library node. Be sure to set it to pass by pointer.
Or make a string of 150 zero's. Substitute characters where needed, but leave the length 150 and leave zeros after the meaningful characters. Pass this to the DLL as a C string.
01-23-2007 09:31 PM - edited 01-23-2007 09:31 PM
Hey tbob, who 4-starred you?
To construct a fixed-length (empty) character-buffer, do what tbob said!
(... though this works too - )
Message Edited by tbd on 01-23-2007 09:32 PM
01-24-2007 10:44 AM
01-24-2007 01:24 PM