Example: a simple openldv application – Echelon OpenLDV User Manual

Page 60

Advertising
background image

52

Using the OpenLDV API

Return Code

Numeric

Value

Description

LDV_BUFFER_CONFIGURATION_TOO_LARGE

45

The specified buffer

configuration is too large to fit

in the available space.
Applies to APP/NET buffers

on the network interface.

LDV_WARNING_APP_BUFFER_SIZE_MISMATCH 46

Warning message that the

buffer size mismatch might

cause problems.
Applies to APP/NET buffers

on the network interface.

Example: A Simple OpenLDV Application

The following code sample shows a very simple OpenLDV application that works

with an Echelon USB Network Interface. In this example, the application

performs the following tasks:

1. Opens the network interface
2. Writes a Query Status command to the interface to retrieve the

interface’s current state; from the current state, extracts the network

interface’s error log and prints a message

3. Reads the response to the Query Status command
4. Closes the network interface
5. Shuts down the OpenLDV driver

A real application would perform the same basic set of tasks, but typically for

additional devices beyond just the network interface. Also, a real application

would query the local device database to determine which network interface to

use; this example simply uses LON1. An application might also define the

network address for the network interface and for network devices; this example

uses local network addressing.
This example uses definitions found in the OpenLDVdefinitions.h header file,

which is included with the OpenLDV Developer Example; see Chapter 4, The

OpenLDV Developer Example, on page 89. It also includes the NetMgmt.h

header file, which is installed to the L

ON

W

ORKS

\NeuronC\Include directory

with the NodeBuilder FX Developer’s Kit or the Mini FX Evaluation Kit.

// Include Windows header file

#include <windows.h>

// Include OpenLDV header file

#include “ldv32.h”

// Include Neuron C Network Management header file

// (contains definition for ND_query_status_response)

#include “netmgmt.h”

Advertising