# Receiving heartbeat message with pyuavcan cli

**URL:** <https://forum.opencyphal.org/t/receiving-heartbeat-message-with-pyuavcan-cli/1035>\
**Category:** PyCyphal\
**Created:** [December 18, 2020, 8:43am UTC](https://forum.opencyphal.org/t/receiving-heartbeat-message-with-pyuavcan-cli/1035 "2020-12-18T08:43:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![generationmake](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/generationmake/32/611_2.png) [@generationmake](https://forum.opencyphal.org/u/generationmake)\
**Post date:** [December 18, 2020, 8:43am UTC](https://forum.opencyphal.org/t/receiving-heartbeat-message-with-pyuavcan-cli/1035/1 "2020-12-18T08:43:09Z")

</div>

Hi.

I am testing with pyuavcan on a raspberry pi and **[107-Arduino-UAVCAN](https://github.com/107-systems/107-Arduino-UAVCAN)** on an Arduino MKR. They are connected via CAN bus using MCP2515 on both ends.  
I was able to set up pyuavcan and transmit messages using “pyuavcan publish …”. The Arduino is also at least transmitting heartbeat messages. And I can see all messages on the Arduino using candump.

Is it possible to receive the heartbeat messages of the Arduino and display them in pyuavcan cli? Maybe it is somewhere in the documentation but all my tries were not successful.  
Is it possible to display all messages from the Arduino node using pyuavcan cli?

Thank you for your help.  
Bernhard

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [December 18, 2020, 11:55am UTC](https://forum.opencyphal.org/t/receiving-heartbeat-message-with-pyuavcan-cli/1035/2 "2020-12-18T11:55:53Z")

</div>

> [@generationmake](#):
>
> Is it possible to receive the heartbeat messages of the Arduino and display them in pyuavcan cli? Maybe it is somewhere in the documentation but all my tries were not successful.

Yes, using `pyuavcan sub uavcan.node.Heartbeat.1.0`. Don’t forget to configure the transport either via `--tr=EXPRESSION` or `export PYUAVCAN_CLI_TRANSPORT=EXPRESSION`. Read `pyuavcan sub --help` for more info.

> [@generationmake](#):
>
> Is it possible to display all messages from the Arduino node using pyuavcan cli?

Not yet, but this is what I am working on.

---

<div class="post-metadata">

**Author:** ![generationmake](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/generationmake/32/611_2.png) [@generationmake](https://forum.opencyphal.org/u/generationmake)\
**Post date:** [December 20, 2020, 8:58am UTC](https://forum.opencyphal.org/t/receiving-heartbeat-message-with-pyuavcan-cli/1035/3 "2020-12-20T08:58:30Z")

</div>

Hi Pavel,

thank you for your answer.

I was able to send to send a heartbeat message with pyuavcan using

```auto
pyuavcan publish uavcan.node.Heartbeat.1.0 '{}' --tr='CAN(can.media.socketcan.SocketCANMedia("can0",8),59)'

```

and I am able to receive this message with pyuavcan using

```auto
pyuavcan sub uavcan.node.Heartbeat.1.0 --tr='CAN(can.media.socketcan.SocketCANMedia("can0",8),59)'

```

could you please verify that the commands used are correct?

Unfortunatelly I cannot decode the heartbeat messages of the arduino with the same commands.  
Candump shows the CAN data from the arduino as followed:

```auto
 (1608454224.262488) can0 RX - - 50D [8] 52 03 00 00 00 00 00 EC 'R.......'
 (1608454225.264198) can0 RX - - 50D [8] 53 03 00 00 00 00 00 ED 'S.......'
 (1608454226.265899) can0 RX - - 50D [8] 54 03 00 00 00 00 00 EE 'T.......'
 (1608454227.267606) can0 RX - - 50D [8] 55 03 00 00 00 00 00 EF 'U.......'
 (1608454228.269286) can0 RX - - 50D [8] 56 03 00 00 00 00 00 F0 'V.......'
 (1608454229.270956) can0 RX - - 50D [8] 57 03 00 00 00 00 00 F1 'W.......'

```

what am I doing wrong? why is it not decoded?

Thank you  
Bernhard

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [December 20, 2020, 2:10pm UTC](https://forum.opencyphal.org/t/receiving-heartbeat-message-with-pyuavcan-cli/1035/4 "2020-12-20T14:10:18Z")

</div>

> [@generationmake](#):
>
> I was able to send to send a heartbeat message with pyuavcan using

Notice that the documentation says that the publish command would always broadcast its own heartbeat so you shouldn’t specify it explicitly. Run **`pyuavcan pub --help`** to see it.

> [@generationmake](#):
>
> could you please verify that the commands used are correct?

Other than the above they are correct.

> [@generationmake](#):
>
> what am I doing wrong? why is it not decoded?

Because the CAN ID is incorrect. UAVCAN uses extended 29-bit CAN IDs, but yours are 11-bit.

---

<div class="post-metadata">

**Author:** ![generationmake](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/generationmake/32/611_2.png) [@generationmake](https://forum.opencyphal.org/u/generationmake)\
**Post date:** [December 20, 2020, 2:14pm UTC](https://forum.opencyphal.org/t/receiving-heartbeat-message-with-pyuavcan-cli/1035/5 "2020-12-20T14:14:16Z")

</div>

> [@pavel.kirienko](#):
>
> Because the CAN ID is incorrect. UAVCAN uses extended 29-bit CAN IDs, but yours are 11-bit.

@aentinger your turn 😉  
Could you please change the CAN IDs to 29-bit. I will generate an issue on github.

---

<div class="post-metadata">

**Author:** ![generationmake](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/generationmake/32/611_2.png) [@generationmake](https://forum.opencyphal.org/u/generationmake)\
**Post date:** [December 20, 2020, 4:19pm UTC](https://forum.opencyphal.org/t/receiving-heartbeat-message-with-pyuavcan-cli/1035/6 "2020-12-20T16:19:25Z")

</div>

Hi @pavel.kirienko  
@aentinger fixed the library and now I am able to receive the messages with pyuavcan.  
Here is my output:

```auto
---
7509:
  uptime: 55
  health:
    value: 0
  mode:
    value: 0
  vendor_specific_status_code: 0

---
7509:
  uptime: 56
  health:
    value: 0
  mode:
    value: 0
  vendor_specific_status_code: 0

```

Is it possible to see which node sent the heartbeat?  
On a system with multiple nodes the output gets a little bit confusing.

Thank you  
Bernhard

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [December 20, 2020, 4:20pm UTC](https://forum.opencyphal.org/t/receiving-heartbeat-message-with-pyuavcan-cli/1035/7 "2020-12-20T16:20:43Z")

</div>

> [@generationmake](#):
>
> Is it possible to see which node sent the heartbeat?

That’s what the flag `--metadata` / `-M` is for (or the docs in general).

---

<div class="post-metadata">

**Author:** ![generationmake](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/generationmake/32/611_2.png) [@generationmake](https://forum.opencyphal.org/u/generationmake)\
**Post date:** [December 20, 2020, 4:26pm UTC](https://forum.opencyphal.org/t/receiving-heartbeat-message-with-pyuavcan-cli/1035/8 "2020-12-20T16:26:37Z")

</div>

perfect, thank you.

output:

```auto
7509:
  _metadata_:
    timestamp:
      system: 1608481566.548898
      monotonic: 4595.125536
    priority: nominal
    transfer_id: 10
    source_node_id: 13
  uptime: 1066
  health:
    value: 0
  mode:
    value: 0
  vendor_specific_status_code: 0

```
