@@ -487,41 +487,50 @@ bool canard_respond(canard_t* const self,
487487/// truncated per the implicit truncation rule (see the Spec).
488488/// Subscription updates are log-time; per-remote RX session state is allocated lazily on demand.
489489///
490- /// Returns true on success, false if any of the arguments are invalid or if there is already a subscription for the
491- /// given subject-ID .
492- bool canard_subscribe_16b (canard_t * const self ,
493- canard_subscription_t * const subscription ,
494- const uint16_t subject_id ,
495- const size_t extent ,
496- const canard_us_t transfer_id_timeout ,
497- const canard_subscription_vtable_t * const vtable );
498- bool canard_subscribe_13b (canard_t * const self ,
499- canard_subscription_t * const subscription ,
500- const uint16_t subject_id , // [0,8191]
501- const size_t extent ,
502- const canard_us_t transfer_id_timeout ,
503- const canard_subscription_vtable_t * const vtable );
490+ /// Returns the passed subscription on success, the incumbent if there is already a subscription for the same subject,
491+ /// or NULL if any of the arguments are invalid .
492+ canard_subscription_t * canard_subscribe_16b (canard_t * const self ,
493+ canard_subscription_t * const subscription ,
494+ const uint16_t subject_id ,
495+ const size_t extent ,
496+ const canard_us_t transfer_id_timeout ,
497+ const canard_subscription_vtable_t * const vtable );
498+ canard_subscription_t * canard_subscribe_13b (canard_t * const self ,
499+ canard_subscription_t * const subscription ,
500+ const uint16_t subject_id , // [0,8191]
501+ const size_t extent ,
502+ const canard_us_t transfer_id_timeout ,
503+ const canard_subscription_vtable_t * const vtable );
504504
505505/// Unicast transfers in Cyphal/CAN v1.1 are supposed to be modeled as requests to service-ID 511, with a 128-element
506506/// array of transfer-ID counters, one per remote. Some large nonzero transfer-ID timeout is required to satisfy the
507507/// deduplication requirement. This is outside of the scope of this library so it's not implemented here.
508508/// There may be at most one request subscription per service-ID.
509509/// Subscription updates are log-time; per-remote RX session state is allocated lazily on demand.
510- bool canard_subscribe_request (canard_t * const self ,
511- canard_subscription_t * const subscription ,
512- const uint16_t service_id ,
513- const size_t extent ,
514- const canard_us_t transfer_id_timeout ,
515- const canard_subscription_vtable_t * const vtable );
510+ /// Return semantics match canard_subscribe_16b().
511+ canard_subscription_t * canard_subscribe_request (canard_t * const self ,
512+ canard_subscription_t * const subscription ,
513+ const uint16_t service_id ,
514+ const size_t extent ,
515+ const canard_us_t transfer_id_timeout ,
516+ const canard_subscription_vtable_t * const vtable );
516517
517518/// There may be at most one response subscription per service-ID.
518519/// Response transfers necessarily have a zero transfer-ID timeout: https://github.com/OpenCyphal/libcanard/issues/247.
519520/// Subscription updates are log-time; per-remote RX session state is allocated lazily on demand.
520- bool canard_subscribe_response (canard_t * const self ,
521- canard_subscription_t * const subscription ,
522- const uint16_t service_id ,
523- const size_t extent ,
524- const canard_subscription_vtable_t * const vtable );
521+ /// Return semantics match canard_subscribe_16b().
522+ canard_subscription_t * canard_subscribe_response (canard_t * const self ,
523+ canard_subscription_t * const subscription ,
524+ const uint16_t service_id ,
525+ const size_t extent ,
526+ const canard_subscription_vtable_t * const vtable );
527+
528+ /// Find an installed subscription by transfer kind and port-ID.
529+ /// Returns the installed subscription if found, otherwise NULL. Invalid kind values also return NULL.
530+ /// Complexity is log-time in the subscription set of the requested kind.
531+ canard_subscription_t * canard_find_subscription (const canard_t * const self ,
532+ const canard_kind_t kind ,
533+ const uint16_t port_id );
525534
526535/// This can be used to undo all kinds of subscriptions, incl. v0.
527536/// Complexity is log-time in the subscription set plus linear in the number of remote sessions owned by it.
@@ -599,33 +608,36 @@ bool canard_v0_respond(canard_t* const self,
599608
600609/// Register a legacy v0 message subscription.
601610/// Subscription updates are log-time; per-remote RX session state is allocated lazily on demand.
602- bool canard_v0_subscribe (canard_t * const self ,
603- canard_subscription_t * const subscription ,
604- const uint16_t data_type_id ,
605- const uint16_t crc_seed ,
606- const size_t extent ,
607- const canard_us_t transfer_id_timeout ,
608- const canard_subscription_vtable_t * const vtable );
611+ /// Return semantics match canard_subscribe_16b().
612+ canard_subscription_t * canard_v0_subscribe (canard_t * const self ,
613+ canard_subscription_t * const subscription ,
614+ const uint16_t data_type_id ,
615+ const uint16_t crc_seed ,
616+ const size_t extent ,
617+ const canard_us_t transfer_id_timeout ,
618+ const canard_subscription_vtable_t * const vtable );
609619
610620/// Register a legacy v0 request subscription.
611621/// Subscription updates are log-time; per-remote RX session state is allocated lazily on demand.
612- bool canard_v0_subscribe_request (canard_t * const self ,
613- canard_subscription_t * const subscription ,
614- const uint_least8_t data_type_id ,
615- const uint16_t crc_seed ,
616- const size_t extent ,
617- const canard_us_t transfer_id_timeout ,
618- const canard_subscription_vtable_t * const vtable );
622+ /// Return semantics match canard_subscribe_16b().
623+ canard_subscription_t * canard_v0_subscribe_request (canard_t * const self ,
624+ canard_subscription_t * const subscription ,
625+ const uint_least8_t data_type_id ,
626+ const uint16_t crc_seed ,
627+ const size_t extent ,
628+ const canard_us_t transfer_id_timeout ,
629+ const canard_subscription_vtable_t * const vtable );
619630
620631/// Register a legacy v0 response subscription.
621632/// Response transfers necessarily have a zero transfer-ID timeout.
622633/// Subscription updates are log-time; per-remote RX session state is allocated lazily on demand.
623- bool canard_v0_subscribe_response (canard_t * const self ,
624- canard_subscription_t * const subscription ,
625- const uint_least8_t data_type_id ,
626- const uint16_t crc_seed ,
627- const size_t extent ,
628- const canard_subscription_vtable_t * const vtable );
634+ /// Return semantics match canard_subscribe_16b().
635+ canard_subscription_t * canard_v0_subscribe_response (canard_t * const self ,
636+ canard_subscription_t * const subscription ,
637+ const uint_least8_t data_type_id ,
638+ const uint16_t crc_seed ,
639+ const size_t extent ,
640+ const canard_subscription_vtable_t * const vtable );
629641
630642/// Computes the CRC-16/CCITT-FALSE checksum of the data type signature in the little-endian byte order.
631643/// This value is then used to seed the transfer CRC for UAVCAN v0 and DroneCAN transfers.
0 commit comments