Skip to content

Commit d72d3fd

Browse files
nits
1 parent 9d538c6 commit d72d3fd

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

libcanard/canard.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1067,7 +1067,7 @@ static byte_t rx_parse(const uint32_t can_id,
10671067
frame_t* const out_v0,
10681068
frame_t* const out_v1)
10691069
{
1070-
CANARD_ASSERT(can_id < (UINT32_C(1) << 29U));
1070+
CANARD_ASSERT(can_id <= CAN_EXT_ID_MASK);
10711071
CANARD_ASSERT(out_v0 != NULL);
10721072
CANARD_ASSERT(out_v1 != NULL);
10731073
memset(out_v0, 0, sizeof(*out_v0));
@@ -1461,6 +1461,7 @@ static void rx_session_update(canard_subscription_t* const sub,
14611461
CANARD_ASSERT(frame->end || (frame->payload.size >= 7));
14621462
CANARD_ASSERT(!frame->start || (frame->toggle == canard_kind_version(sub->kind)));
14631463
CANARD_ASSERT((frame->dst == CANARD_NODE_ID_ANONYMOUS) || (frame->dst == sub->owner->node_id));
1464+
CANARD_ASSERT((canard_kind_version(sub->kind) != 0) || (sub->extent >= 2)); // v0 CRC reservation
14641465

14651466
// Only start frames may create new states.
14661467
// The protocol version is observable on start frames by design, which makes this robust.
@@ -1688,7 +1689,7 @@ bool canard_ingest_frame(canard_t* const self,
16881689
const canard_bytes_t can_data)
16891690
{
16901691
const bool ok = (self != NULL) && (timestamp >= 0) && (iface_index < CANARD_IFACE_COUNT) &&
1691-
(extended_can_id < (UINT32_C(1) << 29U)) && ((can_data.size == 0) || (can_data.data != NULL));
1692+
(extended_can_id <= CAN_EXT_ID_MASK) && ((can_data.size == 0) || (can_data.data != NULL));
16921693
if (ok) {
16931694
frame_t frs[2] = { { 0 }, { 0 } };
16941695
const byte_t parsed = rx_parse(extended_can_id, can_data, &frs[0], &frs[1]);

libcanard/canard.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ void canard_destroy(canard_t* const self);
409409

410410
/// This can be invoked after initialization to manually assign the desired node-ID.
411411
/// This does not disable the occupancy/collision monitoring; the assigned ID will be changed if a collision is found.
412+
/// Returns false if any of the arguments are invalid. Anonymous node-ID is not allowed.
412413
bool canard_set_node_id(canard_t* const self, const uint_least8_t node_id);
413414

414415
/// This must be invoked periodically to ensure liveliness.
@@ -422,6 +423,7 @@ uint_least8_t canard_pending_ifaces(const canard_t* const self);
422423

423424
/// True if successfully processed, false if any of the arguments are invalid.
424425
/// Other failures are reported via the counters.
426+
/// This function should not be invoked from the callbacks.
425427
/// The lifetime of can_data can end after this function returns.
426428
bool canard_ingest_frame(canard_t* const self,
427429
const canard_us_t timestamp,

0 commit comments

Comments
 (0)