Beispiel #1
0
/**
 * @brief   Retrieves a message from a mailbox.
 * @details The invoking thread waits until a message is posted in the mailbox
 *          or the specified time runs out.
 *
 * @param[in] mbp       the pointer to an initialized @p mailbox_t object
 * @param[out] msgp     pointer to a message variable for the received message
 * @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 fetched.
 * @retval MSG_RESET    if the mailbox has been reset while waiting.
 * @retval MSG_TIMEOUT  if the operation has timed out.
 *
 * @api
 */
msg_t chMBFetch(mailbox_t *mbp, msg_t *msgp, systime_t time) {
  msg_t rdymsg;

  chSysLock();
  rdymsg = chMBFetchS(mbp, msgp, time);
  chSysUnlock();
  return rdymsg;
}
Beispiel #2
0
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) {
  systime_t time, tmo;

  osalSysLock();
  tmo = timeout > 0 ? (systime_t)timeout : TIME_INFINITE;
  time = osalOsGetSystemTimeX();
  if (chMBFetchS(*mbox, (msg_t *)msg, tmo) != MSG_OK)
    time = SYS_ARCH_TIMEOUT;
  else
    time = osalOsGetSystemTimeX() - time;
  osalSysUnlock();
  return time;
}
Beispiel #3
0
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) {
  systime_t time, tmo;

  chSysLock();
  tmo = timeout > 0 ? (systime_t)timeout : TIME_INFINITE;
  time = chTimeNow();
  if (chMBFetchS(*mbox, (msg_t *)msg, tmo) != RDY_OK)
    time = SYS_ARCH_TIMEOUT;
  else
    time = chTimeNow() - time;
  chSysUnlock();
  return time;
}
Beispiel #4
0
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout) {
  systime_t tmo, start, remaining;

  osalSysLock();
  tmo = timeout > 0 ? MS2ST((systime_t)timeout) : TIME_INFINITE;
  start = osalOsGetSystemTimeX();
  if (chMBFetchS(*mbox, (msg_t *)msg, tmo) != MSG_OK) {
    osalSysUnlock();
    return SYS_ARCH_TIMEOUT;
  }
  remaining = osalOsGetSystemTimeX() - start;
  osalSysUnlock();
  return (u32_t)ST2MS(remaining);
}
Beispiel #5
0
msg_t Mailbox::fetchS(msg_t *msgp, systime_t time) {

    return chMBFetchS(&mb, msgp, time);
}