Exemple #1
0
/**
 * @brief   Posts an high priority message into a mailbox.
 * @details The invoking thread waits until a empty slot in the mailbox becomes
 *          available or the specified time runs out.
 *
 * @param[in] mbp       the pointer to an initialized @p mailbox_t object
 * @param[in] msg       the message to be posted on the mailbox
 * @param[in] time      the number of ticks before the operation timeouts,
 *                      the following special values are allowed:
 *                      - @a TIME_IMMEDIATE immediate timeout.
 *                      - @a TIME_INFINITE no timeout.
 *                      .
 * @return              The operation status.
 * @retval MSG_OK       if a message has been correctly posted.
 * @retval MSG_RESET    if the mailbox has been reset while waiting.
 * @retval MSG_TIMEOUT  if the operation has timed out.
 *
 * @api
 */
msg_t chMBPostAhead(mailbox_t *mbp, msg_t msg, systime_t time) {
  msg_t rdymsg;

  chSysLock();
  rdymsg = chMBPostAheadS(mbp, msg, time);
  chSysUnlock();
  return rdymsg;
}
/**
 * @brief               Queues a sensor read to the reading thread.
 * 
 * @param[in] srdp      Pointer to the SensorReadDriver object.
 * @param[in] senp      Pointer the generic_sensor_t object to be queued.
 * @param[in] time      The number of ticks before the operation timeouts.
 *                      TIME_IMMEDIATE and TIME_INFINITE is allowed.
 * 
 * @return              The operation status.
 * @retval MSG_OK       If a read request has been correctly queued.
 * @retval MSG_RESET    If the queue has been reset while waiting.
 * @retval MSG_TIMEOUT  If the queue operation timed out and the request
 *                      cannot be queued.
 * 
 * @sclass
 */
msg_t SensorReadInjectReadS(SensorReadDriver *srdp,
                            const generic_sensor_t *senp,
                            systime_t time)
{
    if (senp->priority_sensor == true)
        /* Priority sensor, put it at the front of the queue */
        return chMBPostAheadS(&srdp->srd_mailbox, (msg_t)senp, time);
    else
        /* Not a priority sensor, put it at the end of the queue */
        return chMBPostS(&srdp->srd_mailbox, (msg_t)senp, time);
}
Exemple #3
0
msg_t Mailbox::postAheadS(msg_t msg, systime_t time) {

    return chMBPostAheadS(&mb, msg, time);
}