Skip to content

Commit 604457e

Browse files
docs
1 parent 7847945 commit 604457e

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

libcanard/canard.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
/// The library is designed to be compatible with any target platform and instruction set architecture, from 8 to 64
1111
/// bit, little- and big-endian, RTOS-based or baremetal, etc., as long as there is a standards-compliant C compiler.
1212
///
13+
/// The library offers a non-blocking callback-based API.
14+
///
1315
/// The library is intended to be integrated into the end application by simply copying its source files into the
1416
/// source tree of the project; it does not require any special compilation options and should work out of the box.
1517
/// There are build-time configuration parameters defined near the top of canard.c, but they are safe to ignore.
@@ -364,7 +366,7 @@ struct canard_t
364366
canard_mem_set_t mem;
365367
uint64_t prng_state;
366368

367-
/// Unicast subscription.
369+
/// Unicast subscription used to process messages received with the service-ID set to CANARD_SERVICE_ID_UNICAST.
368370
canard_subscription_t unicast_sub;
369371

370372
/// Unicast transfer-ID tracking for transmission per remote node.
@@ -434,8 +436,11 @@ bool canard_ingest_frame(canard_t* const self,
434436
void canard_refcount_inc(const canard_bytes_t obj);
435437
void canard_refcount_dec(canard_t* const self, const canard_bytes_t obj);
436438

439+
/// Enqueue a message transfer on the specified interfaces.
437440
/// Message ordering observed on the bus is guaranteed per subject as long as the priority of later messages is
438441
/// not higher (numerically not lower) than that of earlier messages.
442+
/// The context is passed into the tx() vtable function.
443+
/// Returns zero on success, false on OOM (error counters updated) or if any of the arguments are invalid.
439444
bool canard_publish(canard_t* const self,
440445
const canard_us_t deadline,
441446
const uint_least8_t iface_bitmap,
@@ -445,13 +450,18 @@ bool canard_publish(canard_t* const self,
445450
const canard_bytes_chain_t payload,
446451
const canard_user_context_t context);
447452

453+
/// Enqueue a unicast message transfer to the specified destination node.
454+
/// See publish function for details.
448455
bool canard_unicast(canard_t* const self,
449456
const canard_us_t deadline,
450457
const uint_least8_t destination_node_id,
451458
const canard_prio_t priority,
452459
const canard_bytes_chain_t payload,
453460
const canard_user_context_t context);
454461

462+
/// Register a new subscription on a v1.1 subject. The subscription instance must not be moved while in use.
463+
/// The extent specifies the maximum message size that can be received from the subject; longer messages will be
464+
/// truncated per the implicit truncation rule (see the Spec).
455465
bool canard_subscribe(canard_t* const self,
456466
canard_subscription_t* const subscription,
457467
const uint16_t subject_id,
@@ -464,6 +474,7 @@ void canard_unsubscribe(canard_t* const self, canard_subscription_t* const subsc
464474

465475
// ----------------------------------------- Cyphal v1.0 compatibility API -----------------------------------------
466476

477+
/// Cyphal v1.0 limits the subject-ID to [0, CANARD_SUBJECT_ID_MAX_1v0].
467478
bool canard_1v0_publish(canard_t* const self,
468479
const canard_us_t deadline,
469480
const uint_least8_t iface_bitmap,
@@ -540,7 +551,11 @@ bool canard_1v0_subscribe_response(canard_t* const sel
540551
/// as the above emission constraints are satisfied.
541552

542553
/// The legacy UAVCAN v0 protocol has 5-bit priority, which is obtained from 3-bit priority by left-shifting.
554+
///
543555
/// All legacy transfers are always sent in Classic CAN mode regardless of the FD flag.
556+
///
557+
/// To obtain the CRC seed, use canard_0v1_crc_seed_from_data_type_signature(); if the payload does not exceed 7 bytes,
558+
/// the CRC seed can be arbitrary since it is not needed for single-frame transfers.
544559
bool canard_0v1_publish(canard_t* const self,
545560
const canard_us_t deadline,
546561
const uint_least8_t iface_bitmap,

0 commit comments

Comments
 (0)