Get Remote node ID when heartbeat is recevied

Hi!

I’m currently migrating all our CAN devices from a previous version of 107-Arduino-Cyphal (data types were still .uavcan). In the previous version the callback function for a subscription also passed through the CanardRxTransfer where I could extract the remote_node_id from the metadata. I’d like to do the same with the latest 107-Arduino-Cyphal, I’ve had a look around and can’t see anything that tells me how to do this… Is this possible? If so how do I get retrieve it. I’ve put the code below where I initialise the Node, subscription and its callback function for reference.

Node node_hdl(
  node_heap.data(),
  node_heap.size(),
  micros,
  [] (CanardFrame const & frame) { return mcp2515.transmit(frame); },
  OPEN_CYPHAL_NODE_ID);

Subscription heartbeat_subscription = node_hdl.create_subscription<uavcan::node::Heartbeat_1_0>(
  heartbeat::on_heartbeat_received);
void on_heartbeat_received(const uavcan::node::Heartbeat_1_0 & msg)
{
  if (DEBUG) {
    char msg_buf[64];
    snprintf(msg_buf, sizeof(msg_buf),
            "Uptime = %d, Health = %d, Mode = %d, VSSC = %d",
            msg.uptime, msg.health.value, msg.mode.value, msg.vendor_specific_status_code);

    Serial.println(msg_buf);
  }

* this is where i'd like to be able to do some filtering based on the remote node id *

Thanks
Rebecca

1 Like

That’s a good question, but it’s not really related to libcanard. It is rather related to @aentinger’s Arduino library built on top of it (libcanard itself does not issue any callbacks). It might even be worthy of an issue at Issues · 107-systems/107-Arduino-Cyphal · GitHub

Ok will do.

Thank Pavel

Issue, design rationale and further discussion over here. :wink: :bowing_man: .

Implemented by @rebeccaRossRobotics (thank you :bowing_man: :rocket: ) and merged in #235 :arrow_forward: and a new version of 107-Arduino-Cyphal has been released here (v3.2.0).

2 Likes