Recovering from a programming error, Declaring network variable arrays, Using the run_unconfigured compiler directive – Echelon ISI User Manual
Page 51
49
ISI Programmer’s Guide
E
XAMPLE
The following example deinstalls a device after the service pin is held for a
long period:
when (timer_expires(ServicePinHoldTimer)) {
nciNetConfig = CFG_LOCAL;
IsiReturnToFactoryDefaults();
}
Recovering from a Programming Error
The IsiReturnToFactoryDefaults() function described in the previous section
assists with recovering from some programming errors. For example, you can
safely remove incorrectly established connections with this tool. However, if the
application enters a state that causes it to malfunction on an algorithm level,
more application-specific code is needed to assist recovery from such a condition.
A typical implementation is to monitor the status of the Service button (see the
service_pin_state() function in the
Neuron C Reference Guide
) to determine if the
Service button is activated continuously for a prolonged period, e.g., five seconds,
and then call the IsiReturnToFactoryDefaults() function. This function call never
returns, as it resets the device. Control first returns to the application within the
when (reset) task. In this task, the application can also check the state of the
Service button using the same service_pin_state() function. If the Service button
is pressed while the device resets, the application can re-initialize the
application’s state and variables to return to orderly behaviour, and might use
the Neuron C active_service_led built-in variable to signal completion of recovery
operations without using any other application I/O.
Declaring Network Variable Arrays
Network variable arrays must be declared with the bind_info(expand_array_info)
modifier if you use the default implementation of IsiCreateCsmo(),
IsiGetAssembly(), or IsiGetNextAssembly(). This includes the forwardees
isiCreateCsmo(), isiGetAssembly(), and isiGetNextAssembly() functions (
See
Forwarders in Chapter 5
). Applications that override all of these forwarders with
application-specific implementations that do not use the related forwardees do
not need to specify the expand_array_info attribute. This attribute allows the ISI
library to determine the SNVT type ID for every network variable on the device,
at the expense of a larger amount of memory required for self-identification data.
Using the run_unconfigured Compiler Directive
ISI makes use of the run_unconfigured compiler directive to enable the device
application to run without network configuration. This is declared in the isi.h
standard header file and no extra steps are needed. Side-effects of this directive
are described in the
Neuron C Reference Guide
.