Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI
8 ratings:
 2.62 out of 5     Rate this Document

Calling External Code in LabVIEW PDA and Touch Panel

Hardware: PXI/CompactPCI>>Controllers

Problem:
I would like to call external code in my LabVIEW application for PDA or Touch Panel. How can I use the Call Library Function Node to call this code?

Solution:
Calling external code in LabVIEW PDA and LabVIEW Touch Panel Modules is very similar to calling code in LabVIEW for Windows. Calling external code can be done through the Call Library Function Node in all versions of LabVIEW, or through the Inline C Node in LabVIEW 8.5 and newer.
 

Using the Call Library Function Node (All Versions of LabVIEW)

The Call Library Function node requires the function name and parameters to be defined correctly. There are two methods of defining the parameters. One is to manually type in the correct name of the function that you will be calling, along with the correct parameters and parameter types. The second method is to create a stub DLL.

  1. Configuring the Call Library Function Node Manually

    If configuring the Call Library Function Node manually, please refer to the LabVIEW Help on Configuring the Call Library Function Node.

  2. Building a Stub DLL

    The terminals of the Call library Function Node will be created automatically if the node is linked to a DLL with the correct function prototypes for the C code that you want to call. This DLL is called a stub DLL, and is a Win32 DLL. The stub DLL does not contain the actual code that will be called. The only purpose for the DLL is ensuring the function name and parameters are correct for the Call Library Function Node.

    The stub DLL can be built with any compiler such as LabWindows/CVI or MSVC++. If using a C++ compiler the functions in the stub DLL should be declared as extern "C" to prevent function name mangling by the compiler.

    The C file that you wish to call is also required. The code needs to have the same function declarations as those being called in LabVIEW from the stub DLL. Its exported functions should also be declared as extern "C" in order to prevent function name mangling, otherwise the function names in the stub DLL and the C code may not match and will not link correctly.

    Instead of LabVIEW using the function code from the stub DLL during the building process, it uses the code for the function from the .c file.  The C file must be included in the Additional files of the build specifications.

Once the Call Library Node has been configured with the correct function and function parameters, either done through a stub DLL or manually, the code is ready to be built. Create a new Build Specification to create an Executable and add the .c file to the Additional files field in the Build PDA Application dialog box.  Once the VI is built it can be downloaded to the device and executed.

There are several examples that ship with the LabVIEW PDA Module and LabVIEW Touch Panel Module that call external code.


Using the Inline C Node (LabVIEW 8.5 and above)

The easiest way to execute C code in LabVIEW 8.5 is to use the Inline C Node. To execute C code using the Inline C Node, simply place the node on the block diagram where you want the code to execute, and type the C code into the node. Parameters can be passed in and out of the node through input and output tunnels.

For more information on using the Inline C Node, see the LabVIEW Help or the Calling External Code example for the LabVIEW PDA Module and LabVIEW Touch Panel Module.


Related Links:
LabVIEW 8.5 Help: Configuring the Call Library Function Node
LabVIEW 8.5 PDA Module Help: Inline C Node (Embedded Targets, PDA Module, Touch Panel Module)
Developer Zone Tutorial: An Overview of Accessing DLLs or Shared Libraries from LabVIEW
KnowledgeBase 290FIKDM: Troubleshooting Call Library Node Problems in LabVIEW
Developer Zone Tutorial: Calling External Code in LabVIEW PDA for Palm OS - Battery Information Example
Developer Zone Tutorial: Calling External Code in LabVIEW PDA for Pocket PC - Battery Information Example

Attachments:





Report Date: 11/13/2003
Last Updated: 05/06/2009
Document ID: 33CARIQS

Your Feedback! poor Poor  |  Excellent excellent   Yes No
 Document Quality? 
 Answered Your Question? 
  1 2 3 4 5
Please Contact NI for all product and support inquiries.submit