Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Using External Code in LabVIEW.pdf
Скачиваний:
47
Добавлен:
29.05.2015
Размер:
1.85 Mб
Скачать

Chapter 2 Shared Libraries (DLLs)

use the enum keyword. The Constants section presents an example of this identification process.

Calling Conventions

Your library call can fail when certain operating systems use calling conventions other than the C calling convention and the Standard (__stdcall) calling convention. The calling convention defines how data is passed to a function, and how clean up occurs after the function call is complete. The documentation for the API should say which calling convention(s) you must use. The Standard (__stdcall) calling convention is also known as the WINAPI convention or the Pascal convention.

Use of calling conventions other than the C or Standard calling conventions frequently causes the failure of library calls in LabVIEW, because those other calling conventions use an incompatible method for maintaining the stack.

Example 1: Call a Shared Library that You Built

This example describes how to complete an averaging VI called Array Average in which the LabVIEW Call Library Function calls myshared.dll. (In UNIX the shared library file has a .so or .sl extension.) The section Building a Shared Library (DLL) describes how to begin building the Array Average VI and how to create myshared.dll. This section describes the three stages for completing the Array Average VI so that it can call the avg_num function in myshared.dll.

Complete configuration of the Call Library Function icon.

Create the front panel.

Create the block diagram.

Configuration of Call Library Function

Complete the configuration of the Call Library Function object as follows.

1.If necessary, create an Array Average VI as described in the Task 1: Build the Function Prototype in LabVIEW section.

2.In the block diagram of the Array Average VI, right-click the Call Library Function icon and select Configure in the shortcut menu to invoke the Call Library Function dialog box.

3.For the Library Name or Path control, browse and select myshared.dll as the shared library that Call Library Function calls.

Using External Code in LabVIEW

2-16

www.ni.com

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]