Additional predefined events – Echelon Neuron C User Manual

Page 163

Advertising
background image

Neuron C Programmer’s Guide

151

Additional Predefined Events

The following three predefined special events result from network management

messages:

offline
online
wink

The offline event occurs when an offline network management command is

received from a network tool. This event is always handled as the first priority

when clause. The online event occurs when an online message is received from a
network tool. The wink event occurs when a wink command is received from a

network tool.

The offline event can be used to place a device offline in case of an emergency, for

maintenance, or in response to some other system-wide condition. While offline,

a device responds only to network management messages until it is reset or
brought back online. Reset can occur by physically resetting the device by

activating the Neuron Chip or Smart Transceiver reset line, or through a

reset

network management message. After execution of the task associated with an
offline when clause, the application program does not run until the device is

either reset or brought back online.
A simple use of these two events is shown below:

when (offline)
{
x(); // Clean up before going offline.
}

// Device goes offline here; application

// program stops running.


when (online)
{
y(); // Start up again
}

The application has no means to refuse a change into the offline or online states,

respectively. The respective state becomes effective after the relevant task has
been completed, allowing the application to prepare for that state by disabling

peripheral hardware, stopping timers, and so on.
The device can change into the online state without the online when clause
evaluating to TRUE: If the device is being taken offline into the soft-offline state,

resetting the device loses, or discards, the soft-offline state and returns the device

to normal, online, operation. The technique shown below can be used to handle
this situation:

void HandleOnline (void)
{
...
}

when (reset)
{

// regular reset code here:

...

Advertising