Go to the documentation of this file.
69 if (
frame.isStartOfTransfer() &&
frame.getToggle())
71 UAVCAN_TRACE(
"TransferReceiver",
"Toggle bit is not cleared, %s",
frame.toString().c_str());
77 UAVCAN_TRACE(
"TransferReceiver",
"Unexpected start of transfer, %s",
frame.toString().c_str());
82 UAVCAN_TRACE(
"TransferReceiver",
"Unexpected toggle bit (not %i), %s",
99 const unsigned payload_len =
frame.getPayloadLen();
101 if (
frame.isStartOfTransfer())
112 const bool success = res ==
static_cast<int>(effective_payload_len);
122 const bool success = res ==
static_cast<int>(payload_len);
134 if (
frame.isStartOfTransfer())
140 if (
frame.isStartOfTransfer() &&
frame.isEndOfTransfer())
157 UAVCAN_TRACE(
"TransferReceiver",
"Failed to access the buffer, %s",
frame.toString().c_str());
164 UAVCAN_TRACE(
"TransferReceiver",
"Payload write failed, %s",
frame.toString().c_str());
172 if (
frame.isEndOfTransfer())
188 if ((
frame.getMonotonicTimestamp().isZero()) ||
199 const bool first_frame =
frame.isStartOfTransfer();
201 const bool not_previous_tid =
frame.getTransferID().computeForwardDistance(
tid_) > 1;
205 const bool need_restart =
208 (same_iface && first_frame && not_previous_tid) ||
209 (iface_switch_allowed && first_frame && non_wrapped_tid);
213 if (!not_initialized && (
tid_ !=
frame.getTransferID()))
217 UAVCAN_TRACE(
"TransferReceiver",
"Restart [ni=%d, isa=%d, tt=%d, si=%d, ff=%d, nwtid=%d, nptid=%d, tid=%d], %s",
218 int(not_initialized),
int(iface_switch_allowed),
int(tid_timed_out),
int(same_iface),
219 int(first_frame),
int(non_wrapped_tid),
int(not_previous_tid),
int(
tid_.
get()),
220 frame.toString().c_str());
MonotonicTime prev_transfer_ts_
ITransferBuffer * create()
ITransferBuffer * access()
MonotonicTime this_transfer_ts_
bool isMidTransfer() const
static const uint16_t MaxTransferIntervalMSec
bool writePayload(const RxFrame &frame, ITransferBuffer &buf)
MonotonicDuration getIfaceSwitchDelay() const
static MonotonicDuration fromMSec(int64_t ms)
static const uint16_t DefaultTransferIntervalMSec
ResultCode receive(const RxFrame &frame, TransferBufferAccessor &tba)
void prepareForNextTransfer()
#define UAVCAN_TRACE(...)
uint8_t yieldErrorCount()
ResultCode addFrame(const RxFrame &frame, TransferBufferAccessor &tba)
bool validate(const RxFrame &frame) const
int computeForwardDistance(TransferID rhs) const
void registerError() const
const UAVCAN_EXPORT T & max(const T &a, const T &b)
static const uint8_t Half
virtual int write(unsigned offset, const uint8_t *data, unsigned len)=0
MonotonicDuration getTidTimeout() const
const UAVCAN_EXPORT T & min(const T &a, const T &b)
uint16_t buffer_write_pos_
void updateTransferTimings()
uint16_t this_transfer_crc_
bool isInitialized() const
uint16_t transfer_interval_msec_
static const uint16_t DefaultTidTimeoutMSec
bool isTimedOut(MonotonicTime current_ts) const
static const uint16_t MinTransferIntervalMSec