LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use Call Library Function node to convert C++ source codes

Solved!
Go to solution

Hi all,

     There are two DLLs name "QMSL_WLAN_Transport.dll" and "QCAMSL_MSVC10R.dll" ,and some c++ codes to connect to DUT. The two DLLs work together to communicaite with DUT.

     I am confused that how to use Call Library Function node to load the function in "QCAMSL_MSVC10R.dll" like 

 

g_hResourceContext = QLIB_ConnectServer_UserDefinedTransport((HANDLE) USER_HANDLE,
UserDefinedSend,
UserDefinedReceive,
UserDefinedFlushTxRx,
true,
true);

It seems that " UserDefinedReceive,UserDefinedSend,UserDefinedFlushTxRx " are Processaddress?  And  "UserDefinedReceive,UserDefinedSend,UserDefinedFlushTxRx" are functions in "QMSL_WLAN_Transport.dll"

UserDefinedReceive = (_UserDefinedReceive)GetProcAddress(hUDT,"UserDefinedReceive");
UserDefinedSend = (_UserDefinedSend)GetProcAddress(hUDT,"UserDefinedSend");
UserDefinedFlushTxRx = (_UserDefinedFlushTxRx)GetProcAddress(hUDT,"UserDefinedFlushTxRx");

 

Attached DLLs and C++ code snippets.

Needs help.

Thanks.

----
czhen
Win 10 & LabVIEW 2014 SP1
Download All
0 Kudos
Message 1 of 7
(3,630 Views)

Read this http://digital.ni.com/public.nsf/allkb/DCB90714981A1F148625731E00797C33

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 7
(3,609 Views)
Solution
Accepted by topic author czhen

Those parameters are callbacks - pointers to functions which are called by the DLL - and there's no way to duplicate that purely in LabVIEW. Search this forum for the word "callback" and you'll find similar questions (for other DLLs). You'll need to write your own DLL (in C, C++, etc) that implements those functions and provides a way to transfer data back to LabVIEW.

0 Kudos
Message 3 of 7
(3,545 Views)

Thank you. I get it.

 

 

----
czhen
Win 10 & LabVIEW 2014 SP1
0 Kudos
Message 4 of 7
(3,536 Views)

Thanks.

I am new to callback functions, maybe i should try another way.

----
czhen
Win 10 & LabVIEW 2014 SP1
0 Kudos
Message 5 of 7
(3,534 Views)

Well if what you describe here would be all that you need to do in terms of callback pointers, then it could be done fairly easily in LabVIEW. However I'm afraid that this is just the tip of the iceberg and you will end up with much more of this and possibly even more complicated stuff. If that would be the case, I definitely would advocate the creation of an additional DLL in C, which wraps this one and provides a more LabVIEW friendly Call Library Node interface.

For the little you have shown, the attached project would be actually all that is needed to make this work. Just remember, I created this quick and dirty and had no way of testing it in any way. Also the header file you show does leave various things unspecified such as the calling convention of the functions and other things. So I simply assumed the Visual C defaults for these things. 

Rolf Kalbermatter
My Blog
0 Kudos
Message 6 of 7
(3,511 Views)

A pretty good example.

Thank you rolfk.

 


rolfk 已写:

Well if what you describe here would be all that you need to do in terms of callback pointers, then it could be done fairly easily in LabVIEW. However I'm afraid that this is just the tip of the iceberg and you will end up with much more of this and possibly even more complicated stuff. If that would be the case, I definitely would advocate the creation of an additional DLL in C, which wraps this one and provides a more LabVIEW friendly Call Library Node interface.

For the little you have shown, the attached project would be actually all that is needed to make this work. Just remember, I created this quick and dirty and had no way of testing it in any way. Also the header file you show does leave various things unspecified such as the calling convention of the functions and other things. So I simply assumed the Visual C defaults for these things. 


 

 

----
czhen
Win 10 & LabVIEW 2014 SP1
0 Kudos
Message 7 of 7
(3,488 Views)