previous page next page reference home emBASIC home page

11 Communication with system tasks
11.1 Introduction
These functions are available to communicate with other system (mCAT) tasks. Generally, BASIC user SEQUENCEs will always have special msg queues and do not deal with the main (default) queue of the BASIC task.
The functions defined here follow the structure of mCAT message exchange in that a message type is defined by a logical server task (i.e. one that provides a service like reading a barcode reader and presenting the filtered number to other tasks).
Client (consumer) tasks now identify the message by its name and request a message (memory block in emBASIC’s memory) to be filled with the data, thereafter waiting for the answer.
On the other side, if emBASIC should be the server of data to mCAT tasks, a special type of message is created and a SEQUENCE has to wait for requests from other system tasks. The message variable has to be set up on the mCAT side and the emBASIC On Message just fills the attributes of this message and returns it with REPLY. emBASIC queries mCAT for name to message-ID resolution but tries to cache the message-IDs for subsequent calls - but not through power fails.
There are other system calls to just pull a message (if one is already there) which should be available but are of minor importance – they will be implemented on customers demand.
11.2 Define SYSTEM message type
To start SYSTEM message processing, the programmer must first define a message type and declare the associated variables, then create an appropriate message handler inside the desired sequence. This is similar to BITBUS messages described above.
To define a system message type use the following syntax:
$MSGID = [NEW] “string”
[attribute AS type]
[ . . . ]
Above, $MSGID is a special field that appears to define message IDs associated with this message. Once defined, this field cannot be changed. To create a new message ID in the system message pool, prepend the message name with the NEW keyword.
TYPE client_message_t AS SYSTEM MESSAGE
$MSGID = NEW “mytask/Message”
attribute AS LONG
data AS WORD
11.3 Requesting system messages
To send a system message request, use the REQUEST command
DECL my_message as client_message_t
my_message.attribute = 10 = 20
REQUEST my_message
11.4 Reply system messages[AS22]
In system message exchange the REPLY command is not mandatory[WLG23][NM24]. Use REPLY to send data to sender:
ticker.value = 0