node-redmodbus

Why is Modbus getter not receiving data from Modbus server?


Workflow as follows:

[
    {
        "id": "8433851b34033b3b",
        "type": "modbus-read",
        "z": "1ba6b61acf69773f",
        "name": "test",
        "topic": "test",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "0",
        "dataType": "Coil",
        "adr": "1",
        "quantity": "1",
        "rate": "1",
        "rateUnit": "m",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "b242b402bba0f67f",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "x": 370,
        "y": 60,
        "wires": [
            [
                "17c8a4504ad23109"
            ],
            []
        ]
    },
    {
        "id": "17c8a4504ad23109",
        "type": "debug",
        "z": "1ba6b61acf69773f",
        "name": "debug 6",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 600,
        "y": 60,
        "wires": []
    },
    {
        "id": "f1c9a936ac0bce42",
        "type": "debug",
        "z": "1ba6b61acf69773f",
        "name": "DO格式",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 580,
        "y": 100,
        "wires": []
    },
    {
        "id": "dc61d5bb20b3e373",
        "type": "modbus-getter",
        "z": "1ba6b61acf69773f",
        "name": "modbus getter",
        "showStatusActivities": true,
        "showErrors": true,
        "showWarnings": true,
        "logIOActivities": false,
        "unitid": "0",
        "dataType": "Coil",
        "adr": "1",
        "quantity": "1",
        "server": "b242b402bba0f67f",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "emptyMsgOnFail": false,
        "keepMsgProperties": true,
        "delayOnStart": false,
        "startDelayTime": "",
        "x": 220,
        "y": 160,
        "wires": [
            [
                "f1c9a936ac0bce42",
                "5b83066048133419"
            ],
            []
        ]
    },
    {
        "id": "b242b402bba0f67f",
        "type": "modbus-client",
        "name": "Modbus server",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "failureLogEnabled": true,
        "tcpHost": "127.0.0.1",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "serialAsciiResponseStartDelimiter": "0x3A",
        "unit_id": "0",
        "commandDelay": "1",
        "clientTimeout": "1000",
        "reconnectOnTimeout": false,
        "reconnectTimeout": "2000",
        "parallelUnitIdsAllowed": true,
        "showWarnings": true,
        "showLogs": true
    }
]

I am using a Modbus Client Simulator to connect to the Modbus server. Initially, I was using Modbus read to fetch the data, but now I want to replace it with Modbus getter. However, in my tests, only Modbus read is detecting changes from the Modbus server node, while Modbus getter is not. The output is as follows:

2023/8/29 9:54:01 node: debug 6
test : msg.payload : array[8]
[true, false, false, false, false, false, false, false]

2023/8/29 9:55:01 node: debug 6
test : msg.payload : array[8]
[false, false, false, false, false, false, false, false]

I have already tried comparing the corresponding nodes, and they should be correctly pointing to the Modbus server. The output from the simulator and debug6 is also consistent, so the only remaining issue is why the Modbus getter is not receiving any messages.

What I expect: I would like assistance in getting the Modbus getter to correctly receive information from the Modbus server.


Solution

  • I imported your flow and tried it out with the modbus server of the same package.

    The difference between the Getter and Read Nodes is that the Getter reacts on an input message while the Read node can be triggered by the button press or the options in the editor.

    Therefore, you just have to add an Inject node in front of the Getter node which injects any kind of message. Now you can either start the Getter with a button press on the Inject node or set an interval there.