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.

关于Osal消息的覆盖

假如我在程序里头,短时间内调用了多次osal_msg_send( App_TaskID, (uint8 *)msg_ptr );那么请问会不会造成消息的覆盖,还是说Osal会保留每一次消息,从而保证应用层不遗漏每一次消息

  • 如果每次发送的msg_ptr是重复的就会覆盖;
  • 每次发送的msg_ptr都是新的osal_event_hdr_t,只是他们的TaskID都一样
  • 这个就不清楚了,可以把接收到的消息打印出来看看有没有被覆盖掉

  • 我記得是不會被覆盖掉
  • /*********************************************************************
     * @fn      osal_msg_receive
     *
     * @brief
     *
     *    This function is called by a task to retrieve a received command
     *    message. The calling task must deallocate the message buffer after
     *    processing the message using the osal_msg_deallocate() call.
     *
     * @param   uint8 task_id - receiving tasks ID
     *
     * @return  *uint8 - message information or NULL if no message
     */
    uint8 *osal_msg_receive( uint8 task_id )
    {
      osal_msg_hdr_t *listHdr;
      osal_msg_hdr_t *prevHdr = NULL;
      osal_msg_hdr_t *foundHdr = NULL;
      halIntState_t   intState;
    
      // Hold off interrupts
      HAL_ENTER_CRITICAL_SECTION(intState);
    
      // Point to the top of the queue
      listHdr = osal_qHead;
    
      // Look through the queue for a message that belongs to the asking task
      while ( listHdr != NULL )
      {
        if ( (listHdr - 1)->dest_id == task_id )
        {
          if ( foundHdr == NULL )
          {
            // Save the first one
            foundHdr = listHdr;
          }
          else
          {
            // Second msg found, stop looking
            break;
          }
        }
        if ( foundHdr == NULL )
        {
          prevHdr = listHdr;
        }
        listHdr = OSAL_MSG_NEXT( listHdr );
      }
    
      // Is there more than one?
      if ( listHdr != NULL )
      {
        // Yes, Signal the task that a message is waiting
        osal_set_event( task_id, SYS_EVENT_MSG );
      }
      else
      {
        // No more
        osal_clear_event( task_id, SYS_EVENT_MSG );
      }
    
      // Did we find a message?
      if ( foundHdr != NULL )
      {
        // Take out of the link list
        osal_msg_extract( &osal_qHead, foundHdr, prevHdr );
      }
    
      // Release interrupts
      HAL_EXIT_CRITICAL_SECTION(intState);
    
      return ( (uint8*) foundHdr );
    }

    我觉得若是taskid相同的话会覆盖