# How to check if data is running through a node (CANbus in this case)

**URL:** <https://discourse.nodered.org/t/how-to-check-if-data-is-running-through-a-node-canbus-in-this-case/66614>\
**Category:** General\
**Tags:** node-red-dashboard\
**Created:** [18 August 2022 13:55 UTC](https://discourse.nodered.org/t/how-to-check-if-data-is-running-through-a-node-canbus-in-this-case/66614 "2022-08-18T13:55:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kymc0](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@Kymc0](https://discourse.nodered.org/u/Kymc0)\
**Post date:** [18 August 2022 13:55 UTC](https://discourse.nodered.org/t/how-to-check-if-data-is-running-through-a-node-canbus-in-this-case/66614/1 "2022-08-18T13:55:24Z")

</div>

Hi all,

This will be my first post so I'll try to do everything by the book.

I'm working on a project that will make a conversion from canbus to modbus TCP. I'm almost finished but I was wondering about one thing. Would it be posible to detect a failure on the canbus. With other words, would it be possible to detect if bytes stopped coming in. For me this is important because I would like to set the modbus output registers to 0 when there are no canbus frames coming in. This is mainly a safety issue.

Below I included the nodes from the canbus side. I use the **node-red-contrib-socketcan** plugin to proces the can frames.

```auto
[
    {
        "id": "bcd75a93ad2fa670",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "0c7ef33bd1b8be2c",
        "type": "socketcan-out",
        "z": "bcd75a93ad2fa670",
        "name": "CAN Bus in",
        "config": "c9a5916d.73411",
        "x": 310,
        "y": 420,
        "wires": [
            [
                "1cc9a6d5f7438318"
            ]
        ]
    },
    {
        "id": "1cc9a6d5f7438318",
        "type": "switch",
        "z": "bcd75a93ad2fa670",
        "name": "Filter CAN ID",
        "property": "payload.canid",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "403105268",
                "vt": "num"
            },
            {
                "t": "eq",
                "v": "288",
                "vt": "num"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 2,
        "x": 550,
        "y": 420,
        "wires": [
            [
                "27cfc314f4ef45ef",
                "9f2e84a8a62b1cd2"
            ],
            [
                "d04083c7b3816a61"
            ]
        ]
    },
    {
        "id": "d04083c7b3816a61",
        "type": "function",
        "z": "bcd75a93ad2fa670",
        "name": "Array parser",
        "func": "\n\nreturn [\n{payload:msg.payload.data[0]},\n];",
        "outputs": 3,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 370,
        "y": 560,
        "wires": [
            [
                "816a16f996853301"
            ],
            [],
            []
        ]
    },
    {
        "id": "816a16f996853301",
        "type": "debug",
        "z": "bcd75a93ad2fa670",
        "name": "",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "x": 670,
        "y": 520,
        "wires": []
    },
    {
        "id": "7479d6b23b914e70",
        "type": "comment",
        "z": "bcd75a93ad2fa670",
        "name": "CAN ID 403105268 (0x1806e5f4)",
        "info": "",
        "x": 770,
        "y": 160,
        "wires": []
    },
    {
        "id": "a345b535a950510d",
        "type": "comment",
        "z": "bcd75a93ad2fa670",
        "name": "CAN ID 288 (0x120)",
        "info": "",
        "x": 310,
        "y": 500,
        "wires": []
    },
    {
        "id": "27cfc314f4ef45ef",
        "type": "function",
        "z": "bcd75a93ad2fa670",
        "name": "function 3",
        "func": "var chargevoltage = [msg.payload.data[1],msg.payload.data[0]];\nvar buff = new Buffer(chargevoltage);\nmsg.payload = buff.readInt16LE(0);\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 380,
        "y": 240,
        "wires": [
            [
                "eb535b22c047d464"
            ]
        ]
    },
    {
        "id": "eb535b22c047d464",
        "type": "debug",
        "z": "bcd75a93ad2fa670",
        "name": "Charge voltage",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 600,
        "y": 220,
        "wires": []
    },
    {
        "id": "9f2e84a8a62b1cd2",
        "type": "function",
        "z": "bcd75a93ad2fa670",
        "name": "function 4",
        "func": "var chargecurrent = [msg.payload.data[3],msg.payload.data[2]];\nvar buff = new Buffer(chargecurrent);\nmsg.payload = buff.readInt16LE(0);\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 420,
        "y": 300,
        "wires": [
            [
                "58361673de0d69a3"
            ]
        ]
    },
    {
        "id": "58361673de0d69a3",
        "type": "debug",
        "z": "bcd75a93ad2fa670",
        "name": "Charge current",
        "active": true,
        "tosidebar": false,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 640,
        "y": 280,
        "wires": []
    },
    {
        "id": "c9a5916d.73411",
        "type": "socketcan-config",
        "interface": "can0"
    }
]

```

I would love to hear your feedback.

Greeting, Marco

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [18 August 2022 15:01 UTC](https://discourse.nodered.org/t/how-to-check-if-data-is-running-through-a-node-canbus-in-this-case/66614/2 "2022-08-18T15:01:48Z")

</div>

> [@Kymc0](#):
>
> would it be possible to detect if bytes stopped coming in

Trigger node.

There is a built in demo...

`CTRL-I` → examples → node-red → function → trigger ...

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/2/423569a6d50b3ba3d4088f7894ed904dd7862735.png)

---

<div class="post-metadata">

**Author:** ![Kymc0](https://avatars.discourse-cdn.com/v4/letter/k/919ad9/32.png) [@Kymc0](https://discourse.nodered.org/u/Kymc0)\
**Post date:** [18 August 2022 15:14 UTC](https://discourse.nodered.org/t/how-to-check-if-data-is-running-through-a-node-canbus-in-this-case/66614/3 "2022-08-18T15:14:02Z")

</div>

Thanks! That was exactly what I was looking for.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 September 2022 15:14 UTC](https://discourse.nodered.org/t/how-to-check-if-data-is-running-through-a-node-canbus-in-this-case/66614/4 "2022-09-01T15:14:10Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
