nros C API
Lightweight ROS 2 client for embedded real-time systems
Loading...
Searching...
No Matches
rclc_node_ref_t Struct Reference

#include <nros_generated.h>

Data Fields

bool executor_bound
uint32_t generation
uint8_t node_id

Detailed Description

phase-379 W4 — a checkable reference to the node an entity was created on.

Replaces the *const rcl_node_t each entity used to store. That pointer was never dereferenced anywhere in the C API — it was assigned, nulled, and asserted on — so it bought provenance nobody could use while leaving a raw pointer that invites a dereference the platform cannot support:

  • bare metal is safe (no MMU, no relocation, handles in .bss), but
  • an RTOS node declared on a task stack dies with vTaskDelete, and
  • rcl_node_t a = b; is legal and silent — C has no move semantics, and we have no allocator to hide an indirection behind.

rcl's alternative (rcl_publisher_fini(&pub, &node)) does not remove that assumption; it relocates it to a caller who cannot check it either.

So the entity stores an IDENTITY instead: the executor slot the node is bound to, plus the generation that slot carried when the entity was created. rcl_node_fini bumps the generation, which makes "finalise an entity after its node" a return code rather than a silent success.

generation == 0 is reserved and never issued, so a zeroed struct — the common C mistake — can never resolve.

Field Documentation

◆ executor_bound

bool rclc_node_ref_t::executor_bound

Was the node bound to an EXECUTOR (rclc_executor_node_init) rather than initialised on the legacy support path? (issue 1405)

Both carry slot 0 when they are the first node, so node_id alone cannot say whether there is a NodeRecord to register under. The registration paths used node_id != 0 for that, which sent an executor's PRIMARY node down the legacy arm: its entities registered on session 0 even when the node itself lives on another session. This field occupies what was padding, so the struct's size and alignment are unchanged, and a zeroed struct reads as "not executor-bound".

◆ generation

uint32_t rclc_node_ref_t::generation

Slot generation when the entity was created. 0 = no node bound.

◆ node_id

uint8_t rclc_node_ref_t::node_id

Executor node slot (rcl_node_t::node_id). 0 = the primary node.


The documentation for this struct was generated from the following file: