/* * BusEvent */ bool BusEvent::wait(uavcan::MonotonicDuration duration) { static const uavcan::int64_t MaxDelayMSec = 0x000FFFFF; const uavcan::int64_t msec = duration.toMSec(); msg_t ret = msg_t(); if (msec <= 0) { # if (CH_KERNEL_MAJOR == 2) ret = sem_.waitTimeout(TIME_IMMEDIATE); # else // ChibiOS 3 ret = sem_.wait(TIME_IMMEDIATE); # endif } else { # if (CH_KERNEL_MAJOR == 2) ret = sem_.waitTimeout((msec > MaxDelayMSec) ? MS2ST(MaxDelayMSec) : MS2ST(msec)); # else // ChibiOS 3 ret = sem_.wait((msec > MaxDelayMSec) ? MS2ST(MaxDelayMSec) : MS2ST(msec)); # endif } # if (CH_KERNEL_MAJOR == 2) return ret == RDY_OK; # else // ChibiOS 3 return ret == MSG_OK; # endif }
void spinAll(uavcan::MonotonicDuration duration = uavcan::MonotonicDuration::fromMSec(9)) { assert(!duration.isNegative()); unsigned nspins3 = unsigned(duration.toMSec() / 3); nspins3 = nspins3 ? nspins3 : 2; while (nspins3 --> 0) { ASSERT_LE(0, slave.node.spin(uavcan::MonotonicDuration::fromMSec(1))); ASSERT_LE(0, master_low.node.spin(uavcan::MonotonicDuration::fromMSec(1))); ASSERT_LE(0, master_high.node.spin(uavcan::MonotonicDuration::fromMSec(1))); } }
/* * BusEvent */ bool BusEvent::wait(uavcan::MonotonicDuration duration) { static const uavcan::int64_t MaxDelayMSec = 0x000FFFFF; const uavcan::int64_t msec = duration.toMSec(); msg_t ret = msg_t(); if (msec <= 0) { ret = sem_.waitTimeout(TIME_IMMEDIATE); } else { ret = sem_.waitTimeout((msec > MaxDelayMSec) ? MS2ST(MaxDelayMSec) : MS2ST(msec)); } return ret == RDY_OK; }