Sending a response, Receiving a response, The resp_arrives event – Echelon Neuron C User Manual
Page 150

138
How Devices Communicate Using Application Messages
Because the response is returned to the origin of the request, no message tag is
necessary. For the same reason, you cannot explicitly address a response.
The built-in outgoing response object is defined as shown below:
struct {
int code;
// message code
int data[MAXDATA]; // message data
} resp_out;
code
A numeric message code in the range 0 to 79. This field is required.
See
on page 123 for a detailed description of numeric
ranges used in the code field.
data
The data contained in the message. This field is optional.
MAXDATA is a function of the #pragma app_buf_in_size directive
(see Chapter 8,
, on page 173):
MAXDATA = app_buf_in_size – 6
or
MAXDATA = app_buf_in_size – 17
(if explicit addressing is used)
Note: The Neuron firmware observes which locations in the data array have
assignments and automatically sets the length of the outgoing message
accordingly.
Sending a Response
You can send a response with the resp_send( ) function. You must send
responses from the same critical section that processed the incoming request.
The response is constructed in the application input buffer in which the request
arrived. Therefore, after you start response construction, you can no longer
examine the incoming request. Also, no other intervening messages can be sent
or received. This restriction only applies to the case in which an outgoing
message uses an input application buffer.
The syntax for the resp_send( ) function is the following:
void resp_send (void);
This function sends a response using the resp_out object.
Note: While the response is constructed in the application input buffer by the
application, the network processor uses a network output buffer to construct the
response packet. So, the network output buffer must be sized to accommodate
outgoing responses in addition to other outgoing messages.
Receiving a Response
A program usually receives a response through the predefined event
when(resp_arrives). The resp_receive( ) function can also be used to receive a
response.
The resp_arrives Event
The predefined event for receiving a response is resp_arrives.