Use node-red-node-serialport when you need to debug flexibly.
test code here:
[
{
"id": "e7e0acf8ed94f75e",
"type": "tab",
"label": "鍘嬪姏浼犳劅鍣ㄤ覆鍙d换鎰忔寚浠ゅ疄楠?",
"disabled": false,
"info": "",
"env": []
},
{
"id": "22f712114a9952dd",
"type": "serial-port",
"serialport": "/dev/ttyS4",
"serialbaud": "9600",
"databits": "8",
"parity": "none",
"stopbits": "1",
"waitfor": "",
"dtr": "none",
"rts": "none",
"cts": "none",
"dsr": "none",
"newline": "50",
"bin": "bin",
"out": "interbyte",
"addchar": "",
"responsetimeout": "10000"
},
{
"id": "067e0acd2d271669",
"type": "inject",
"z": "e7e0acf8ed94f75e",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "03030000000185E8",
"payloadType": "str",
"x": 130,
"y": 160,
"wires": [
[
"0e3b76dd644213b3"
]
]
},
{
"id": "0e3b76dd644213b3",
"type": "buffer-maker",
"z": "e7e0acf8ed94f75e",
"name": "",
"specification": "spec",
"specificationType": "ui",
"items": [
{
"name": "item1",
"type": "hex",
"length": 16,
"dataType": "msg",
"data": "payload"
}
],
"swap1": "",
"swap2": "swap16",
"swap3": "",
"swap1Type": "swap",
"swap2Type": "swap",
"swap3Type": "swap",
"msgProperty": "payload",
"msgPropertyType": "str",
"x": 330,
"y": 160,
"wires": [
[
"36921b79db22a4f2"
]
]
},
{
"id": "b30f1f7458ccaa75",
"type": "debug",
"z": "e7e0acf8ed94f75e",
"name": "debug 14",
"active": true,
"tosidebar": true,
"console": true,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 370,
"y": 260,
"wires": []
},
{
"id": "cd4fa16807afa3cd",
"type": "serial in",
"z": "e7e0acf8ed94f75e",
"name": "",
"serial": "22f712114a9952dd",
"x": 140,
"y": 260,
"wires": [
[
"b30f1f7458ccaa75"
]
]
},
{
"id": "36921b79db22a4f2",
"type": "serial out",
"z": "e7e0acf8ed94f75e",
"name": "",
"serial": "22f712114a9952dd",
"x": 560,
"y": 160,
"wires": []
},
{
"id": "067f998692c1474d",
"type": "function",
"z": "e7e0acf8ed94f75e",
"name": "浠绘剰16杩涘埗鎸囦护",
"func": "var buf = Buffer.from([0x03 ,0x03 ,0x00 ,0x00 ,0x00 ,0x01 ,0x85 ,0xE8 ]);\nmsg.payload = buf;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 360,
"y": 80,
"wires": [
[
"36921b79db22a4f2"
]
]
},
{
"id": "3a2436d910a2f28b",
"type": "inject",
"z": "e7e0acf8ed94f75e",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 150,
"y": 80,
"wires": [
[
"067f998692c1474d"
]
]
}
]