This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2538: OSAL message transfer

Part Number: CC2538

Hi,

I am trying to send message between task's sending is fine but receiving is not happening, I was getting some unknown value, please look at my code

  kiko_msg *kiko_msg_ptr; 
kiko_msg_ptr = (kiko_msg*)osal_msg_allocate(sizeof(kiko_msg_ptr));
      if ( kiko_msg_ptr )
      {
    
    kiko_msg_ptr->sub = KIKO_REMOTE_CMD;
    kiko_msg_ptr->msg = 105;
      
    osal_msg_send( Kiko_Activity_TaskID, (uint8 *)kiko_msg_ptr );
    osal_msg_deallocate( (void *)kiko_msg_ptr );
    
      }

and while receiving:

 kiko_msg *kiko_msg_ptr; 
  char NWK_BuffferNew[64];
  
  if( events & SYS_EVENT_MSG )
  {
      kiko_msg_ptr = (kiko_msg*)osal_msg_receive( Kiko_Post_TaskID );
      char abc[64];
      sprintf(abc, "sts=%d , msg=%d\r\n", kiko_msg_ptr->status, kiko_msg_ptr->msg);
      HalUARTWrite ( MT_UART_DEFAULT_PORT, abc, strlen(abc) );

      if(kiko_msg_ptr->msg == KIKO_REMOTE_CMD){
      HalUARTWrite ( MT_UART_DEFAULT_PORT, "if\r\n", strlen("if\r\n") );
      }
      
      switch(kiko_msg_ptr->msg)
    {
    case KIKO_REMOTE_CMD:
      HalUARTWrite ( MT_UART_DEFAULT_PORT, "case\r\n", strlen("case\r\n") );
     break;
     
    default:
      break;
    }
      osal_msg_deallocate( (void *)kiko_msg_ptr );

the status or msg I was sending is not matching at reciever task.

Can you any one please tell me how can Send message between one task to another in OSAL

Thank you.

  • Are Kiko_Activity_TaskID and Kiko_Post_TaskID two separate tasks? You appear to be sending the message to Kiko_Activity_TaskID and receiving to Kiko_Post_TaskID, not sure if this was intentional or not in your example code.

    The first parameter of osal_msg_send is destination_id, and the first parameter of osal_msg_receive is task_id (i.e., my task id), so if for instance you wish to send a message from Task1 to Task2,

    Task1 would do:
    osal_msg_send(Task2, msg);

    and Task2 would do:
    msg = osal_msg_receive(Task2);
  • hi its my mistake I am trying to receive with different Task ID.