in data 07-27-2010 09:06 AM
Hy to everyone,
I'm working on a external DLL and I can't configure properly the "Call function" node in order to retrieve a specific data strcture.
I tried all suggestions and directives founded in the NI forum and support guides, but without success.
I post a ZIP file contains:
1 - LV8.6 proj with main example (TEST_DCATcp_dll.vi) and DLL-functions wrapper
2 - the DLL
3 - a PDF with data type and function specs
The problem is on the DCATCP_CheckConnection.vi contains the data structure.
Thanks to everyone.
Regards,
A.Balvis
Risolto Andare alla soluzione.
in data 08-04-2010 09:27 AM
hi dyzzy,
Please take a look at this KB: http://digital.ni.com/public.nsf/allkb/7734838EB700153D86256A3F007478B8?OpenDocument.
I had good experiences using the first of the three methods that is based on casting your structure to a string and then passing it to Call Library Function Node.
Also the second option should be a solution but you should create a wrapper dll that converts the LabVIEW data to the structure needed by your function.
Hope it helps
Best Regards
in data 08-05-2010 12:29 PM
Morning Luca,
thanks for your reply and your link.
Let me explain better the problem.
The DLL function exported ha the following prototype:
function DCATcp_ConnectionStatus(ConnectionId : TConnectionId) : TTcpConnectionStatus;
so it returns a TTcpConnectionStatus struct:
TTcpConnectionStatus
HostName : TTcpString; (21 byte)
PortNumber : LongInt; (4 byte)
DomainName : TTcpString; (21 byte)
StatusCode : LongInt; (4 byte)
RcvMsgInQueue : LongInt; (4 byte)
SndMsgInQueue : LongInt; (4 byte)
LastSentMsgTime : TDateTime; (8 byte)
LastReceivedMsgTime : TDateTime; (8 byte)
RcvThreadOn : Boolean; (1 byte)
SndThreadOn : Boolean; (1 byte)
ConnectionThreadOn : Boolean; (1 byte)
Searching on the forum and on the web I've found that when a DLL function returns a data type different from the option available in the Calling Library Node (voi, numeric and string) the only way to retrive the output data is to set as output as numeric, in order to retrieve a pointer to data and then is possible to use the MoveBlock() function to copy the pointed data to the desidered struct (a cluster in this case).
I configured the MoveBlock as follow:
MoveBlock(ps, pd, size)
ps = int32 pointer source - value (coming out from the DCATcp_ConnectionStatus as numeric int32)
pd = adapt to type - handles by value (the struct I need to retrieve)
size = uint32 the size of data - value (77 byte)
The only problem is about the pd, because if I wire the "original" struct I receive error from MoveBlock, if wire a modified struct with only numeric I get wrong data (see the picture).
So the question is how should I set the input in order to have the right data.
Thanks,
Alessandro Balvis