User guide

74 How Devices Communicate Using Network Variables
Your application must always support the NVT_CAT_INITIAL type category. If
the requested type is of that category, your application must ignore all other
content of the SCPTnvType configuration property and change the related
network variable’s type back to its initial type. The network variable’s initial
type is the type the network variable was declared with in Neuron C
(SNVT_volt_f in the earlier example).
Processing a Size Change
If a supported change to the SCPTnvType configuration property results in a
change in the size of a network variable type, your application must provide code
to memorize the current length of the network variable. It must further provide
code to inform the Neuron firmware about the current length of the changeable-
type network variable. The current length information must be kept in non-
volatile storage, but details of the required implementation depend on the chosen
mechanism for supporting the Neuron firmware.
Two such mechanisms are supported, a legacy one called the
nv_len method
, and
a more robust
NV length override system image extension
method.
You can explicitly set and maintain the new length of the network variable using
the built-in nv_len property of the network variable. You can access and modify
the built-in nv_len property as shown below:
Example of legacy nv_len property:
size_t oldNVLen, newNVLen;
oldNVLen = nv-name::nv_len;
nv-name::nv_len = newNVLen;
Important: When the Neuron C compiler detects use of the nv_len property to
modify a network variable's length, it requests that the linker place the network
variable fixed configuration table in writeable memory. This could make it
difficult to fit such an application into the memory of a device based on a Neuron
3150 Chip or an FT 3150 Smart Transceiver if the device has no writeable
external memory for the application, such as EEPROM or flash memory.
Starting with version 14, the Neuron firmware implements 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
get_nv_length_override( ) system image extension to get it. Compared to writing
to the nv_len property, this new method provides more reliable updates to
network variable sizes, because the old method could cause a device to go
applicationless if a power failure occurred in the middle of a network variable
size update.
You can enable the NV length override system image extension
with the
following compiler directive:
#pragma system_image_extensions nv_length_override
Using this compiler directive with a version of the Neuron firmware that does not
support system extensions causes an NLD#477 linker error.
To implement a NV length override system image extension, provide a function
with the following prototype:
unsigned get_nv_length_override(unsigned uNvIndex);