msg_read
Previous Topic  Next Topic 

Synopsis: 

       msg_str=msg_read(timeout[,ms_flag]);


Arguments: 

       timeout - This is the time to wait for a message to arrive in seconds (or millisecs if ms_flag is set)

       [ms_flag] - If this is set to a non-zero value then the timeout

       

Description:  This function blocks and waits for an incoming message.     The timeout argument specifies the time that the function should wait for a message to arrive in seconds (or if ms_flag is set then the timeout is specified in milliseconds).        If there is already a message waiting for the task in the message queue then the function will return immediately with the received message.   If the timeout period is exceeded before a message is received then the function returns an empty string.


For example:


               // Loop forever waiting for messages

               while(1)

                       // Wait 60 seconds for a message to arrive

                       msg_str=msg_read(60);

                       if(msg_str streq "")

                               applog("No message received yet!");

                               continue;

                       else

                               // we have got a message so process it..

                               .... ETC

                       endif

               endwhile



Returns:   Returns the received message or a blank string it timeout occurs