Sending a message – Echelon Neuron C User Manual
Page 137

Neuron C Programmer’s Guide
125
Example block transfer of data:
msg_tag motor;
#define MOTOR_ON 0
typedef enum {
MOTOR_FWD,
MOTOR_REV
} motor_dir;
struct {
long motor_speed;
motor_dir motor_direction;
int motor_ramp_up_rate;
} motor_on_message;
when(some_event) {
msg_out.tag = motor;
msg_out.code = MOTOR_ON;
motor_on_message.motor_direction = MOTOR_FWD;
motor_on_message.motor_speed = 500;
motor_on_message.motor_ramp_up_rate = 100;
memcpy(msg_out.data,
&motor_on_message,
sizeof
(motor_on_message));
msg_send();
}
Sending a Message
You can send and cancel sending a message using the following functions:
msg_send( )
msg_cancel( )
The msg_send( ) function has the following syntax:
void msg_send(void);
This function sends a message using the msg_out object (which must have
already been constructed prior to the call to the msg_send( ) function). It has no
parameters, and has no return value.
The following code fragment illustrates sending a message:
msg_tag motor;
#define MOTOR_ON 0
#define ON_FULL 100
// (100 percent)
when (io_changes(switch1) to ON)
{
// Send a message to the motor
msg_out.tag = motor;
msg_out.code = MOTOR_ON;
msg_out.data[0] = ON_FULL;
msg_send();
}
The msg_cancel( ) function cancels an outgoing message. It has the following
syntax: