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.
07-10-2014 12:04 PM
Hi everyone,
I am trying to call a .dll using the Call Library Function Node. This .dll controls a piece of test equipment that sets a GPIO to "1" or "0". The .dll file function I want to use is called IOWriteEx.
The vendor documentation gives the following information for this function:
BOOL IOWriteEx(BYTE PinNum, BOOL status);
Where IOWriteEx = The .dll function expression
PinNum = The GPIO pin number you want to write to
status = The state you want to write the GPIO to
How do I configure the Call Library Function Node for this? I tried setting everything up with parameters but I am not seeing the GPIO toggle externall.
Thanks!
07-10-2014 12:32 PM
Confusingly, BOOL is a 32-bit value, but BOOLEAN is only 8 bits: http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751%28v=vs.85%29.aspx
So, you should configure the Call Library Function Node with two parameters: PinNum as a U8, and status as an I32. Pass a 1 or 0 as the value for status.
If that doesn't work, attach your code. Make sure you're using the correct calling convention.
07-10-2014 01:42 PM
NathanD,
Thanks for your response. I tried it out and no luck. I have not used Call Library Function ever before. I may have set up the configuration wrong. I have attached my example code. The VI will be broken because I am not sending the actual .dll file.
Can you take a look at it?
Also, I have a question about the Call Library Function Node.
1. What is the return type output used for?
2. For this example, do I need to configure the inputs as "Pass Pointer To Value?"
Thanks for your help!
07-10-2014 01:57 PM - edited 07-10-2014 01:58 PM
And boolean is a C++ type and generally 8 bits, but the C standard does not require any specific size as C does in fact with all it's datatypes. C only mandates that long >= int >= short >= byte and byte is defined to be the smallest addressable memory quantity. char must be also >= byte just as boolean. But there exist CPU architectures where a byte is not 8 bits, and it is imaginable that on some CPUs a byte might be 9 or 15 bits or some other odd value.
Also a C compiiler defining long = int = short = char = byte is still fully C standard compliant (but will most likely break just about every C code ever written )
07-10-2014 02:24 PM
Sorry, I'm still on LabVIEW 2012 here and can't open your VI.
There is no need for pointers anywhere in calling this function; all parameters should be passed by value.
The return type is the value that the function returns. In your case it's a BOOL (as indicated by BOOL IOWriteEx). The documentation should explain the meaning of that value: it could tell if the function succeeded, it could be the new state of the output, it could be something else entirely. Many functions in DLLs don't have a return value at all, in which case they're marked with Void.
07-10-2014 05:05 PM
You definitely will want to change both PinNum and status to be "Pass: Value". As you have configured it now the prototype of your function would need to be:
BYTE IOWriteEx(BYTE *PinNum, BOOL *status);
but you want to make it
BOOL IOWriteEx(BYTE PinNum, BOOL status);
according to your definition in the first post. Please note the two stars in front of the parameters. Basically it would be strange if that wouldn't crash!!
So your return value should be an int32, and PinNum and status should be passed as Value rather than Pointer to Value.