36
K
A
DAK
Application Tasks
3.9 Message Passing
AMX supports the passing of a message to a task mailbox or message exchange.
Messages can be sent to a task by:
Application Tasks
Interrupt Service Procedures
Timer Procedures
Restart Procedures
Exit Procedures
You can send a message to a task mailbox or message exchange using the AMX
procedure ajsend (or its variation ajsendp) or ajmxsnd respectively. The maximum
number of parameter bytes that can be sent in a message is configured by you in your
System Configuration Module. The parameter bytes are completely application
dependent.
Messages must be integer aligned. In the following examples, it is assumed that your C
compiler aligns arrays and structures on boundaries that are integer aligned.
int i;
short int iarray[6];
char carray[12];
struct msg {
char m1;
char m2;
short int m3;
long m4;
} msga;
The following calls will send the specified message to the mailbox of the task with id
taskid or to the message exchange with exchange id mxid . The messages are sent at
priority 3.
int priority = 3;
ajsend(taskid, priority, &c); /* Send c */
ajsend(taskid, priority, &i); /* Send i */
ajsend(taskid, priority, iarray); /* Send iarray */
ajmxsnd(mxid, priority, carray); /* Send carray */
ajmxsnd(mxid, priority, &msga); /* Send msga */
The messages are stored in FIFO order in the task mailbox or message exchange message
queue. The caller specifies the priority level of the message. The priority level (0, 1, 2 or
3) determines the message queue (mailbox) into which the message will be placed.
If the caller is a task sending a message to another task, it can request AMX to suspend
its operation until the called task has executed in response to the request. This is
accomplished by calling ajsenw (or its variation ajsenwp) rather than ajsend.