Hi Barber,
I've taken the default FSLMQX/mqx/examples/lwmsgq project and modified it to operate in several ways by changine #if / #elif statements.
1)_lwmsgq_receive((pointer)server_queue, msg, LWMSGQ_TIMEOUT_FOR, 0, 0); //blocks while waiting for message...default code
2)_lwmsgq_receive((pointer)server_queue, msg, LWMSGQ_RECEIVE_BLOCK_ON_EMPTY, 1, &ticks); //blocks only 1 tick duration waiting for message
3) if (!LWMSGQ_IS_EMPTY(server_queue)){ //checks for message in queue
Server.c snippet:
while (TRUE) {
#if 1 //DES test code
if (!LWMSGQ_IS_EMPTY(server_queue)){ //checks for message in queue
printf("Queue has message....go get it... ");
_lwmsgq_receive((pointer)server_queue, msg, LWMSGQ_TIMEOUT_FOR, 0, 0);
printf(" %c \n", msg[0]);
_lwmsgq_send((pointer)client_queue, msg, LWMSGQ_SEND_BLOCK_ON_FULL);
}
else {
printf("\t\t***NO MESSAGE IN QUEUE***\n");
_time_delay_ticks(1); //DES block to give other task(s) chance to run
}
#elif 0 //DES test code
result = _lwmsgq_receive((pointer)server_queue, msg, LWMSGQ_RECEIVE_BLOCK_ON_EMPTY, 1, &ticks); //blocks only 1 tick duration waiting for message
if(result == MQX_OK){
printf(" %c \n", msg[0]);
_lwmsgq_send((pointer)client_queue, msg, LWMSGQ_SEND_BLOCK_ON_FULL);
}
else if(result == LWMSGQ_TIMEOUT){
printf("LWMSGQ_TIMEOUT\n");
}
else{
printf("error=0x%08X\n", result);
}
#else //DES default code
_lwmsgq_receive((pointer)server_queue, msg, LWMSGQ_TIMEOUT_FOR, 0, 0); //blocks while waiting for message
printf(" %c \n", msg[0]);
_lwmsgq_send((pointer)client_queue, msg, LWMSGQ_SEND_BLOCK_ON_FULL);
#endif
}
Client.c snippet:
_time_delay_ticks(5);
//DES _time_delay_ticks(1);
I tried attaching the files but system wasn't letting me do that :smileysad:
Hope this helps.
Regards,
David