19 len =
min(
unsigned(maxlen), len);
22 return static_cast<uint8_t>(len);
25 template <
int OFFSET,
int WIDTH>
28 StaticAssert<(OFFSET >= 0)>::
check();
29 StaticAssert<(WIDTH > 0)>::
check();
30 StaticAssert<((OFFSET + WIDTH) <= 29)>::check();
31 return (val >> OFFSET) & ((1UL << WIDTH) - 1);
38 UAVCAN_TRACE(
"Frame",
"Parsing failed at line %d", __LINE__);
42 if (can_frame.
dlc >
sizeof(can_frame.
data))
48 if (can_frame.
dlc < 1)
50 UAVCAN_TRACE(
"Frame",
"Parsing failed at line %d", __LINE__);
62 const bool service_not_message = bitunpack<7, 1>(id) != 0U;
63 if (service_not_message)
65 const bool request_not_response = bitunpack<15, 1>(id) != 0U;
95 toggle_ = (tail & (1U << 5)) != 0;
102 template <
int OFFSET,
int WIDTH>
105 StaticAssert<(OFFSET >= 0)>::
check();
106 StaticAssert<(WIDTH > 0)>::
check();
107 StaticAssert<((OFFSET + WIDTH) <= 29)>::check();
109 return uint32_t((field & ((1UL << WIDTH) - 1)) << OFFSET);
139 bitpack<15, 1>(request_not_response ? 1U : 0U) |
165 out_can_frame.
data[out_can_frame.
dlc] = tail;
174 crc.
add(out_can_frame.
data, out_can_frame.
dlc);
175 out_can_frame.
id |= bitpack<10, 14>(crc.
get() & ((1U << 14) - 1U));
188 UAVCAN_TRACE(
"Frame",
"Validness check failed at line %d", __LINE__);
197 UAVCAN_TRACE(
"Frame",
"Validness check failed at line %d", __LINE__);
203 UAVCAN_TRACE(
"Frame",
"Validness check failed at line %d", __LINE__);
212 UAVCAN_TRACE(
"Frame",
"Validness check failed at line %d", __LINE__);
218 UAVCAN_TRACE(
"Frame",
"Validness check failed at line %d", __LINE__);
226 UAVCAN_TRACE(
"Frame",
"Validness check failed at line %d", __LINE__);
235 UAVCAN_TRACE(
"Frame",
"Validness check failed at line %d", __LINE__);
244 UAVCAN_TRACE(
"Frame",
"Validness check failed at line %d", __LINE__);
253 UAVCAN_TRACE(
"Frame",
"Validness check failed at line %d", __LINE__);
279 static const int BUFLEN = 100;
281 int ofs =
snprintf(buf, BUFLEN,
"prio=%d dtid=%d tt=%d snid=%d dnid=%d sot=%d eot=%d togl=%d tid=%d payload=[",
291 if ((i + 1) < payload_len_)
293 ofs +=
snprintf(buf + ofs,
unsigned(BUFLEN - ofs),
" ");
296 (void)
snprintf(buf + ofs,
unsigned(BUFLEN - ofs),
"]");
297 return std::string(buf);
316 ts_utc_ = can_frame.
ts_utc;
326 out +=
" ts_m=" + ts_mono_.toString();
327 out +=
" ts_utc=" + ts_utc_.toString();
329 out += char(
'0' + iface_index_);
uint32_t id
CAN ID with flags (above)
bool isRemoteTransmissionRequest() const
static DataTypeKind getDataTypeKindForTransferType(const TransferType tt)
UAVCAN_EXPORT bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2)
bool operator==(const Frame &rhs) const
uint8_t getPayloadCapacity() const
static const uint32_t MaskExtID
static const NodeID Broadcast
TransferPriority transfer_priority_
static const uint32_t FlagEFF
Extended frame format.
bool parse(const CanFrame &can_frame)
uint8_t setPayload(const uint8_t *data, unsigned len)
uint8_t dlc
Data Length Code.
#define UAVCAN_TRACE(...)
static std::string toString(long x)
UAVCAN_EXPORT OutputIt copy(InputIt first, InputIt last, OutputIt result)
uint_fast8_t payload_len_
UAVCAN_EXPORT const T & min(const T &a, const T &b)
TransferType transfer_type_
bool compile(CanFrame &can_frame) const
bool isErrorFrame() const
bool parse(const CanRxFrame &can_frame)
static const uint8_t NumTransferTypes
static uint32_t bitpack(uint32_t field)
int snprintf(char *out, std::size_t maxlen, const char *format,...)
uint8_t payload_[PayloadCapacity]
bool isValidForDataTypeKind(DataTypeKind dtkind) const
static uint32_t bitunpack(uint32_t val)