The resp_receive( ) function, Format of a response – Echelon Neuron C User Manual

Page 151

Advertising
background image

Neuron C Programmer’s Guide

139

Its syntax is the following:

resp_arrives [(

msg-tag-name

)]

If a response arrives, this event evaluates to TRUE. The event can optionally be

qualified by a message tag name; this qualification limits the event to a response

message that corresponds to a previously sent request that used the named
message tag. When there is no message tag name qualifying the event, the event

evaluates to TRUE for each response message that arrives.

The resp_receive( ) Function

The resp_receive( ) function has the following syntax:

boolean resp_receive(void);

This function receives a response into the resp_in object. The function returns
TRUE if a response is received, otherwise it returns FALSE. The response is

automatically discarded at the end of the task that receives it.
Calling resp_receive( ) has the side-effect of calling post_events( ), so a call to
resp_receive( ) defines a critical section boundary.

Format of a Response

The name of the incoming response object is resp_in.
The incoming response structure is predefined in the Neuron C Compiler as
follows:

struct {

int code;

// message code

int len; // length of message data

int data[MAXDATA];

// message data

resp_in_addr addr;

// explicit address - see the

// <msg_addr.h> include file

} resp_in;

code

A numeric message code in the range 0 to 79. See

Message Codes

on

page 123.

len

The length of the message data.

data

The data contained in the message. This field is valid only if len is

greater than 0. MAXDATA is a function of the #pragma

app_buf_in_size (see Chapter 8,

Memory Management

, on page 173):

MAXDATA = app_buf_in_size – 6

or

MAXDATA = app_buf_in_size – 17
(if explicit addressing is used by any message or network variable in

this program)

addr

An optional field in the incoming message that an application

program can use to determine the source and destination of the

message. You can find the definition of the type resp_in_addr in the
<msg_addr.h> include file.

Advertising