Author Topic: inter task communication  (Read 8028 times)

Offline lthyagar

  • Newbie
  • *
  • Posts: 21
    • View Profile
inter task communication
« on: September 09, 2009, 01:33:40 AM »
Hello Mark, I was playing with the inter task communication using queues.

This is what I am doing:

fnDoLCD_com_text(E_LCD_TEXT, (unsigned char *)LCDdsp, (sizeof(LCDdsp) - 1));

The code above is executed in my task(source task). I am using the character LCD. I have disabled fnDoLCD every where else in the code to ensure that there is only one task writing to the LCD.(using the task queue).

The string is correctly displayed on the LCD in the simulator.
Question: How does the LCD task get the string from "MY TASK"?
I am confused because:
switch ( ucInputMessage[ MSG_SOURCE_TASK ] )  in the LCD task:
MSG_SOURCE_TASK= "L" meaning LCD task.
I checked the above using a breakpoint.
But the code below that:
case TASK_APPLICATION: is looking for "a"
meaning application task.
Thanks in advance.

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3236
    • View Profile
    • uTasker
Re: inter task communication
« Reply #1 on: September 09, 2009, 10:21:04 PM »
Hi

When the message is sent, its header is built up like this:

    ucMessage[ MSG_DESTINATION_NODE ] = INTERNAL_ROUTE;                  // destination node
    ucMessage[ MSG_SOURCE_NODE ]      = INTERNAL_ROUTE;                  // own node
    ucMessage[ MSG_DESTINATION_TASK ] = TASK_LCD;                        // destination task
    ucMessage[ MSG_SOURCE_TASK ]      = OWN_TASK;                        // own task
    ucMessage[ MSG_CONTENT_LENGTH ]   = ucLength+1;                      // message length
    ucMessage[ MSG_CONTENT_COMMAND ]  = ucType;                          // command(s) or text for LCD


where ucType is E_LCD_TEXT. The string follows in the message.
When send from the application task OWN_TASK is 'a' and TASK_LCD is 'L'.

When the message is received at the LCD task it checks ucInputMessage[ MSG_SOURCE_TASK ] (looking for TASK_APPLICATION).

Maybe you confused the MSG_SOURCE_TASK, which is the offset in the header (3) with the task definition?

Regards

Mark