Processing completion events for messages – Echelon Neuron C User Manual
Page 145

Neuron C Programmer’s Guide
133
Processing Completion Events for
Messages
When you send a message, you can optionally check the completion event.
Several restrictions apply, however, if you do check the completion event.
First, if you check for either msg_succeeds
or
msg_fails, you must check for
both
events. The alternative is simply to check for msg_completes.
Second, if you qualify a completion event with a particular message tag, then you
must
always
process completion events for that message tag. A program can
thus process completion events for some of its message tags, and ignore
completion events for other message tags. In the following example, completion
events for TAG1 are processed, and completion events for TAG2 are
not
processed:
when (io_changes(dev1))
{
...
msg_out.tag = TAG1;
...
msg_send();
}
when (msg_completes(TAG1))
{
...
}
when (io_changes(dev2))
{
...
msg_out.tag = TAG2;
...
msg_send();
}
A third restriction applies to use of the
unqualified
completion event, which
implicitly refers to
all
messages. When you use the unqualified completion event,
you must process all acknowledged messages, either explicitly for each message
tag, or implicitly through use of an unqualified event each time a message is sent.
The following code shows correct processing of completion events by message tag:
int failures[2], success;
msg_tag TAG1, TAG2;
when (io_changes(toggle))
{
msg_out.tag = TAG1;
msg_out.code = TOGGLE_STATE;
msg_out.data[0] = input_value;
msg_send();
msg_out.tag = TAG2;
msg_out.code = TOGGLE_STATE;
msg_out.data[0] = input_value;