Go to the documentation of this file.
19 len =
min(
unsigned(maxlen), len);
22 return static_cast<uint8_t>(len);
25 template <
int OFFSET,
int WIDTH>
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>
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=[",
293 ofs +=
snprintf(buf + ofs,
unsigned(BUFLEN - ofs),
" ");
296 (void)
snprintf(buf + ofs,
unsigned(BUFLEN - ofs),
"]");
297 return std::string(buf);
uint8_t setPayload(const uint8_t *data, unsigned len)
bool parse(const CanRxFrame &can_frame)
static const uint32_t FlagEFF
Extended frame format.
uint8_t getPayloadCapacity() const
TransferType transfer_type_
bool compile(CanFrame &can_frame) const
@ TransferTypeServiceResponse
uint8_t dlc
Data Length Code.
#define UAVCAN_TRACE(...)
struct UAVCAN_EXPORT StaticAssert
uint32_t id
CAN ID with flags (above)
@ TransferTypeServiceRequest
bool isErrorFrame() const
static const uint8_t NumTransferTypes
TransferPriority transfer_priority_
static uint32_t bitpack(uint32_t field)
int snprintf(char *out, std::size_t maxlen, const char *format,...)
@ TransferTypeMessageBroadcast
UAVCAN_EXPORT bool equal(InputIt1 first1, InputIt1 last1, InputIt2 first2)
static const uint32_t MaskExtID
static uint32_t bitunpack(uint32_t val)
static std::string toString(long x)
bool isRemoteTransmissionRequest() const
const UAVCAN_EXPORT T & min(const T &a, const T &b)
static const NodeID Broadcast
bool operator==(const Frame &rhs) const
static DataTypeKind getDataTypeKindForTransferType(const TransferType tt)
uint8_t payload_[PayloadCapacity]
bool isValidForDataTypeKind(DataTypeKind dtkind) const
bool parse(const CanFrame &can_frame)
void toString(char buf[StringBufSize]) const
Prints time in seconds with microsecond resolution.
UAVCAN_EXPORT OutputIt copy(InputIt first, InputIt last, OutputIt result)
uint_fast8_t payload_len_