Echelon IzoT NodeBuilder User Manual

Page 196

Advertising
background image

The method used by the Neuron firmware to change the size of a network variable uses an NV length
override system image extension
that is managed by the application. Whenever the firmware needs the
length of a network variable, it calls the network variable length override system image extension to
get it. This method provides reliable updates to network variable sizes.

For more information about changeable-type network variables and the NV length override system
image extension, as well as a commented source code example that illustrates all aspects of creating an
application that uses changeable-type network variables, see Chapter 3 of the Neuron C Programmer’s
Guide
.

To implement a changeable-type network variable in your device application, follow these steps (see
Chapter 3 of the Neuron C Programmer’s Guide for a more detailed discussion of step 4):

1. Create a device template that has a changeable interface. See Specifying the Program ID in

Chapter 5 for more information on how to do this.

2. In the Code Wizard, create a new network variable or edit an existing one and select the

Changeable Type checkbox in the dialog for creating or editing the network variable. See
Editing Mandatory Network Variables, Implementing Optional Network Variables, or Adding
Implementation-specific Network Variables
in Chapter 6 for more information on how to do this.

3. Generate Neuron C code for your device interface. See Generating Code with the Code Wizard in

Chapter 6 for more information on how to do this

1. In the Neuron C code generated by the Code Wizard, do the following:

a. Complete the implementation of the get_nv_length_override function. The Code Wizard

provides an empty implementation of this function in the device template’s main source file.
This function should return the length of any changeable-type network variable in the device.

b. The Code Wizard uses the #pragma unknown_system_image_extension_isa_warning

directive to generate Neuron C source code that will compile. The Code Wizard enables this
directive in the device template’s main header file. If you use a combination of Code Wizard
generated code and your own code, you can edit the relevant portion of the main header file.

You should only use the older nv_len() function to support debugging of an application
containing changeable-type network variables on platforms that do not support the system
image extension. For production release, the more robust system image extension method
should be used, and both methods should not coexist in a production device.

You can use the get_current_nv_length() function to determine the current length of a
network variable at any time (see the Neuron C Reference Guide for more information about
this method).

c. Define the behavior of the application when a request to change the network variable type is

received. The application must validate that the requested type change is supported. If it is
not, it must reject the request (either by setting invalid_request or by setting an
application-specific error and putting the device offline) and set the network variable type
back to the last valid type. If the type change is valid, it must implement the type and size
change.

The Code Wizard does not provide framework code for this task, but a commented source
code example is provided in the Neuron C Programmer’s Guide.

d. Define how the functional block behaves when sending or receiving values on

changeable-type network variables. For each valid type, the functional block must perform
any necessary conversion before operating on the value.

The Code Wizard does not provide framework code for this task, but a commented source
code example is provided in the Neuron C Programmer’s Guide.

182

Developing Device Applications

Advertising