Preemption mode and messages – Echelon Neuron C User Manual

Page 146

Advertising
background image

134

How Devices Communicate Using Application Messages

msg_send();
}

when (msg_fails(TAG1))
{
failures[0]++;
}

when (msg_fails(TAG2))
{
failures[1]++;
}

when (msg_succeeds)

// any message qualifies

{
success++;
}

Preemption Mode and Messages

The Neuron firmware enters

preemption mode

when there is no application

buffer available for an outgoing message. If the system needs a free application

buffer, it causes the application program to wait and processes only completion
events, responses, and incoming network variables and messages to facilitate

application buffers’ becoming free.
No other predefined or user-defined events are processed unless the
preempt_safe keyword is used in conjunction with a when clause containing an

event expression. The syntax for the when clause is explained in Chapter 2,

Focusing on a Single Device

, on page 15.

The watchdog timer is automatically updated during this wait. If the program

waits for more than a configurable number of seconds, the device is reset. This
configurable timer is controlled by the preemption_timeout field of the

configuration structure (config_data_struct), which you can modify using the

update_config_data() function; see appendix B of the ISO/IEC 14908-1

Control

Network Protocol

specification for information about this structure. A

buffer

wait timeout

(also known as

preemption mode timeout

) should only occur if a

device is totally blocked from transmitting. This situation could occur under
extreme network congestion or with certain network failures.
A buffer wait timeout could also occur if a program is not properly freeing

completion events. The most common error is to check for completion events in
bypass mode (for example, if (nv_update_completes) ) and not to have a

corresponding completion event check in a when clause.
With network variables, the system can only enter preemption mode if:

• synchronous output network variables are updated, or
• flush_wait( ) is called.

When the system is in preemption mode, further attempts to send a message

from a task associated with a message completion event when

clause cause a

device reset if no buffer is available for the new message.
The following sequence is therefore

not

recommended:

when (TOGGLE_ON)

Advertising