> I have read "Controlling an Instrument That Requires DLL Functions
> That Use Pointers to Complex Data Structures", Document ID: 2A5F7J5C,
> but need to start with a simpler example. I need to pass a pointer to
> an instrument vendor's C dll. In their reference manual they define
> the function as "int axSetChassis(int Controller, char *cntrlName)".
> Do I need a wrapper for "char *cntrlName" and if so what data type do
> I use as the output of my Wrapper.dll. Also, what LabVIEW data type
> do I use on my Call Library Function input for that parameter?
Unfortunately, C is really low level, and a function prototype in C
isn't definitive as to what the code being called needs or assumes.
From the name of the parameter, I think it is safe to assume that the
function really is going to use the char* for a string. This isn't
always the case as a pointer is often a void* or a char*, even if it
points to more complex things. Second, I'm guessing that the function
will only read the string, and not try to modify it. Again, since C
passes things by pointer, it isn't guaranteed that this is the case.
The LV Call Library Function node's configuration dialog will let you
define int as the return type, let you enter or select the function name
within the DLL, let you browse for the DLL on disk, and finally it will
let you define two parameters, and int and a string. On the string
choose to pass it as a C style string.
The resulting node will have both an input and output for the string.
You need to fill in the name on the diagram using a constant, a control,
or a computed string, and wire that to the Call Lib node. LV will NULL
terminate the string and pass the pointer to the DLL function as the
second parameter. The other options for strings are as a counted Pascal
string and as a LV string.
If my guess about the string direction is wrong, and the DLL will modify
the string value, then you will want the input string to be large enough
for the DLL to write into. How do you know what is large enough?
Hopefully the documentation of the DLL will define the assumptions. So
the string input acts as the buffer, and possibly the initial value to
the DLL, and after the call, the updated value will be on the right side
output. Again, LV will do the translation to and from the other string
conventions.
Greg McKaskle