CRC 16XMODEM node

I don't know what this means. You have provided no context.

As for why the serial node might not work, it is possible due to setup. For example, you may be appending a carriage return or not appending a carriage return or whatever your protocol needs. You have not provided this information.

the serial works correctly and sending commands in text format works and returns the response you expect. some commands work without crc others require the crc but the serial configuration works properly, the wrap character is included in the serial node configuration.

Given the lack of detailed protocol information, I can only guess.

Perhaps you need to send the data as bytes (AKA a buffer) because sending 51550494753b7a9 is a string of HEXADECIMAL

Try setting the payload (the one that goes to the serial node) so that is sends a buffer.

e.g...

Function Node "Hex String to Buffer"

msg.payload = Buffer.from(msg.payload, 'hex')
return msg

This command requires the crc

Alternatively, convert the HEX string into a regular string

msg.payload = Buffer.from(msg.payload, 'hex').toString()
return msg

e.g:

51550494753b7a9 becomes → 'QU\x04�u;z'

in fact you guessed right! if I change in buffer it also works by sending the commands in hex

[
    {
        "id": "edf507bc4f9d5dec",
        "type": "serial out",
        "z": "2e439fa544a77ab5",
        "name": "VMIII-TX",
        "serial": "831becf24befe30b",
        "x": 860,
        "y": 1280,
        "wires": []
    },
    {
        "id": "e2beeb574d982801",
        "type": "inject",
        "z": "2e439fa544a77ab5",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "calculate",
        "payload": "5043565635352e36",
        "payloadType": "str",
        "x": 180,
        "y": 1280,
        "wires": [
            [
                "6154059a3dde693d",
                "642ae841afbc5196"
            ]
        ]
    },
    {
        "id": "a3644ecebee6a043",
        "type": "function",
        "z": "2e439fa544a77ab5",
        "name": "buffer",
        "func": "msg.payload = Buffer.from(msg.payload, 'hex')\nreturn msg",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 610,
        "y": 1280,
        "wires": [
            [
                "edf507bc4f9d5dec",
                "ec608cbea3497578"
            ]
        ]
    },
    {
        "id": "6154059a3dde693d",
        "type": "function",
        "z": "2e439fa544a77ab5",
        "name": "xmodem crc",
        "func": "const { crc16 } = easyCrc;\nmsg.inputData = msg.payload;\nmsg.buffer = Buffer.from(msg.payload, 'hex');\nmsg.crcDecimal = crc16('XMODEM', msg.buffer);\nmsg.crcHex = msg.crcDecimal.toString(16)\nmsg.payload = `${msg.inputData}${msg.crcHex}`\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [
            {
                "var": "easyCrc",
                "module": "easy-crc"
            }
        ],
        "x": 430,
        "y": 1280,
        "wires": [
            [
                "a3644ecebee6a043",
                "7914e91b46a9971c"
            ]
        ]
    },
    {
        "id": "7914e91b46a9971c",
        "type": "debug",
        "z": "2e439fa544a77ab5",
        "name": "debug 1",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 1320,
        "wires": []
    },
    {
        "id": "ec608cbea3497578",
        "type": "debug",
        "z": "2e439fa544a77ab5",
        "name": "debug 2",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 820,
        "y": 1320,
        "wires": []
    },
    {
        "id": "642ae841afbc5196",
        "type": "debug",
        "z": "2e439fa544a77ab5",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 420,
        "y": 1320,
        "wires": []
    },
    {
        "id": "31e7bfd73af61468",
        "type": "inject",
        "z": "2e439fa544a77ab5",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "calculate",
        "payload": "PCVV55.4",
        "payloadType": "str",
        "x": 150,
        "y": 1340,
        "wires": [
            []
        ]
    },
    {
        "id": "831becf24befe30b",
        "type": "serial-port",
        "name": "",
        "serialport": "/dev/ttyACM0",
        "serialbaud": "2400",
        "databits": 8,
        "parity": "none",
        "stopbits": 1,
        "waitfor": "(",
        "dtr": "none",
        "rts": "none",
        "cts": "none",
        "dsr": "none",
        "newline": "\\r",
        "bin": "false",
        "out": "char",
        "addchar": "\\r",
        "responsetimeout": 10000
    }
]


We are almost there, the merits are certainly yours, in my small I have however learned something more and thank you.
now works properly by sending a string containing hex values. a last step would be to send the commands in text format and turn them into hex string to give to crc and the game is done.
this because the crc node results only in hex, for what I understood, otherwise it would be better to do the crc directly with text and then make a buffer and send to the serial. but I have no idea if it’s feasible.
Thank you for your patience in supporting beginners like me!


[
    {
        "id": "007424808c9b6283",
        "type": "mqtt in",
        "z": "2e439fa544a77ab5",
        "name": "COMMAND/RX",
        "topic": "DATI FOTOVOLTAICO/NODE-RED/INVERTER_VOLTRONIC/COMMAND/TX",
        "qos": "2",
        "datatype": "auto-detect",
        "broker": "e276a877253691df",
        "nl": false,
        "rap": true,
        "rh": 0,
        "inputs": 0,
        "x": 120,
        "y": 1060,
        "wires": [
            [
                "289e35eef21e61a0",
                "7290101b4768b299"
            ]
        ]
    },
    {
        "id": "a409a644c23f12d9",
        "type": "cyclic counter",
        "z": "2e439fa544a77ab5",
        "name": "cyclic counter",
        "maxCount": "6",
        "timeoutDuration": 0,
        "timeoutUnit": "ms",
        "outputProperty": "payload",
        "x": 320,
        "y": 980,
        "wires": [
            [
                "9fbe16961891930f"
            ]
        ]
    },
    {
        "id": "3a9e655f2b972f20",
        "type": "inject",
        "z": "2e439fa544a77ab5",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "2",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 130,
        "y": 980,
        "wires": [
            [
                "a409a644c23f12d9"
            ]
        ]
    },
    {
        "id": "9fbe16961891930f",
        "type": "change",
        "z": "2e439fa544a77ab5",
        "name": "",
        "rules": [
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "1",
                "fromt": "num",
                "to": "QPIGS",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "2",
                "fromt": "num",
                "to": "QMOD",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "3",
                "fromt": "num",
                "to": "QPIGS",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "4",
                "fromt": "num",
                "to": "QPIWS",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "5",
                "fromt": "num",
                "to": "QPIGS",
                "tot": "str"
            },
            {
                "t": "change",
                "p": "payload",
                "pt": "msg",
                "from": "6",
                "fromt": "num",
                "to": "QPIRI",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 520,
        "y": 980,
        "wires": [
            [
                "d49e167477b1d0b1"
            ]
        ]
    },
    {
        "id": "289e35eef21e61a0",
        "type": "trigger",
        "z": "2e439fa544a77ab5",
        "name": "",
        "op1": "close",
        "op2": "open",
        "op1type": "str",
        "op2type": "str",
        "duration": "10",
        "extend": true,
        "overrideDelay": false,
        "units": "s",
        "reset": "",
        "bytopic": "all",
        "topic": "topic",
        "outputs": 1,
        "x": 330,
        "y": 1060,
        "wires": [
            [
                "67211f5b338da45d"
            ]
        ]
    },
    {
        "id": "67211f5b338da45d",
        "type": "change",
        "z": "2e439fa544a77ab5",
        "name": "move",
        "rules": [
            {
                "t": "set",
                "p": "topic",
                "pt": "msg",
                "to": "control",
                "tot": "str"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 1060,
        "wires": [
            [
                "d49e167477b1d0b1"
            ]
        ]
    },
    {
        "id": "d49e167477b1d0b1",
        "type": "gate",
        "z": "2e439fa544a77ab5",
        "name": "demo gate",
        "controlTopic": "control",
        "defaultState": "open",
        "openCmd": "open",
        "closeCmd": "close",
        "toggleCmd": "toggle",
        "defaultCmd": "default",
        "statusCmd": "status",
        "persist": false,
        "x": 730,
        "y": 1060,
        "wires": [
            [
                "f68aa936bb103d57"
            ]
        ]
    },
    {
        "id": "f68aa936bb103d57",
        "type": "switch",
        "z": "2e439fa544a77ab5",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "eq",
                "v": "close",
                "vt": "str"
            },
            {
                "t": "eq",
                "v": "open",
                "vt": "str"
            },
            {
                "t": "else"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 3,
        "x": 890,
        "y": 1060,
        "wires": [
            [],
            [],
            [
                "a99ad4b6bb706893"
            ]
        ]
    },
    {
        "id": "7290101b4768b299",
        "type": "delay",
        "z": "2e439fa544a77ab5",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "allowrate": false,
        "outputs": 1,
        "x": 320,
        "y": 1120,
        "wires": [
            [
                "a99ad4b6bb706893"
            ]
        ]
    },
    {
        "id": "edf507bc4f9d5dec",
        "type": "serial out",
        "z": "2e439fa544a77ab5",
        "name": "VMIII-TX",
        "serial": "831becf24befe30b",
        "x": 1320,
        "y": 1120,
        "wires": []
    },
    {
        "id": "3f6be7eed08ff7d8",
        "type": "debug",
        "z": "2e439fa544a77ab5",
        "name": "TX Seriale",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 1330,
        "y": 1180,
        "wires": []
    },
    {
        "id": "a99ad4b6bb706893",
        "type": "function",
        "z": "2e439fa544a77ab5",
        "name": "str>hex/crc/buffer",
        "func": "msg.payload = Buffer.from(msg.payload, 'utf-8').toString('hex');\n\nconst { crc16 } = easyCrc;\nmsg.inputData = msg.payload;\nmsg.buffer = Buffer.from(msg.payload, 'hex');\nmsg.crcDecimal = crc16('XMODEM', msg.buffer);\nmsg.crcHex = msg.crcDecimal.toString(16)\nmsg.payload = `${msg.inputData}${msg.crcHex}`\n\nmsg.payload = Buffer.from(msg.payload, 'hex')\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [
            {
                "var": "easyCrc",
                "module": "easy-crc"
            }
        ],
        "x": 1110,
        "y": 1120,
        "wires": [
            [
                "edf507bc4f9d5dec",
                "3f6be7eed08ff7d8"
            ]
        ]
    },
    {
        "id": "e276a877253691df",
        "type": "mqtt-broker",
        "name": "",
        "broker": "192.168.1.99",
        "port": "1883",
        "clientid": "",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "5",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthRetain": "false",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closeRetain": "false",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willRetain": "false",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "831becf24befe30b",
        "type": "serial-port",
        "name": "",
        "serialport": "/dev/ttyACM0",
        "serialbaud": "2400",
        "databits": 8,
        "parity": "none",
        "stopbits": 1,
        "waitfor": "(",
        "dtr": "none",
        "rts": "none",
        "cts": "none",
        "dsr": "none",
        "newline": "\\r",
        "bin": "false",
        "out": "char",
        "addchar": "\\r",
        "responsetimeout": 10000
    }
]

Good morning.
I have given a fix to the stream that I built with your help!
I publish in its completeness with the hope that it can be improved and also in the interest of others looking for a solution... as happened in my case.
Thanks again
flussoCRC .json (8.9 KB)