Referencing the openldv component, Using multiple threads or multiple processes – Echelon OpenLDV User Manual

Page 22

Advertising
background image

14

Using the OpenLDV API

Referencing the OpenLDV Component

You can develop applications that use the OpenLDV API with any Windows

application development environment that supports the use of standard Windows

DLL components and (for xDriver Extensions) COM components. Echelon has

tested the OpenLDV software with Microsoft Visual Studio 2008, using the

Microsoft Visual C++

®

, Visual C#

®

, and Visual Basic

®

components.

To develop an applicatikon with the OpenLDV API, first install the OpenLDV

driver and the OpenLDV SDK. During the installation, the ldv32.h and

ldv32.lib files are copied to the L

ON

W

ORKS

\OpenLDV SDK\Include and

\OpenLDV SDK\Lib folders.
To develop your OpenLDV application, include the ldv32.h header file in your

application and link it with the ldv32.lib library. See your development

environment’s documentation for information about linking to external libraries.

End users of your OpenLDV application do not need to install any of the files

included in the OpenLDV SDK; they need only install the OpenLDV driver.
The OpenLDV SDK includes the OpenLDV Developer Example, which uses many

of the functions described in this chapter. To compile and debug the OpenLDV

Developer Example, install Microsoft Visual Studio 2008 (or later), with the

Microsoft Visual C++ component. The example application is available from the

Examples & Tutorials folder in the Echelon OpenLDV 4.0 SDK program

folder; it is also installed as a ZIP file to the \LonWorks\OpenLDV

SDK\SourceArchive folder. The OpenLDV Developer Example contains

numerous helpful comments. See Chapter 4, The OpenLDV Developer Example,

on page 89, for a description of the architecture of the OpenLDV Developer

Example and of the different classes that it contains.

Using Multiple Threads or Multiple Processes

The OpenLDV software supports communication with multiple network

interfaces at the same time, with the following restrictions:

1. A single process can access multiple network interfaces simultaneously.

However, a single process should access a network interface with at most

one writer thread and one reader thread. You must program your

application to enforce this restriction, because it is not enforced by the

OpenLDV software. See the OpenLDV Developer Example for a

demonstration of the proper use of separate reader and writer threads.

2. Multiple processes cannot access the same network interface

simultaneously. Attempts to access the same network interface by more

than one process result in the LDVX_ACCESS_DENIED failure code

from the ldv_open() functions.

3. The SmartServer and i.LON network interfaces allow a single session at

a time. If you attempt to open such a network interface while another

session is active (usually from another computer), the call to ldv_open()

might initially appear to have succeeded (the connection is established in

the background). However, when you call ldv_read() or ldv_write() to

read or write a message to the network interface, the functions return the

LDVX_READ_FAILED or LDVX_WRITE_FAILED return codes,

which indicate that the session has failed. See ldv_open() on page 24 for

more information.

Advertising