some examples how to work with Modbus and HTTP requests and response ...
-
-
Save biancode/2ddc22598c0b86d057ead2f454aeed97 to your computer and use it in GitHub Desktop.
Modbus via HTTP requests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "934a0213.59b38", | |
"type": "tab", | |
"label": "Modbus HTTP", | |
"disabled": false, | |
"info": "" | |
}, | |
{ | |
"id": "84ee0e0b.ed5c9", | |
"type": "modbus-getter", | |
"z": "934a0213.59b38", | |
"name": "", | |
"showStatusActivities": false, | |
"showErrors": false, | |
"unitid": "", | |
"dataType": "HoldingRegister", | |
"adr": "0", | |
"quantity": "4", | |
"server": "7e257e6c.0c55", | |
"x": 410, | |
"y": 190, | |
"wires": [ | |
[ | |
"52cb7240.5c223c", | |
"95a8b25.2972b5" | |
], | |
[ | |
"1f9d545f.1fd4fc" | |
] | |
] | |
}, | |
{ | |
"id": "44d50ac8.4bea94", | |
"type": "http in", | |
"z": "934a0213.59b38", | |
"name": "", | |
"url": "/modbus/flex/read", | |
"method": "get", | |
"upload": false, | |
"swaggerDoc": "", | |
"x": 190, | |
"y": 340, | |
"wires": [ | |
[ | |
"6fd20edd.9d64a" | |
] | |
] | |
}, | |
{ | |
"id": "52cb7240.5c223c", | |
"type": "debug", | |
"z": "934a0213.59b38", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "true", | |
"x": 770, | |
"y": 130, | |
"wires": [] | |
}, | |
{ | |
"id": "1f9d545f.1fd4fc", | |
"type": "modbus-response", | |
"z": "934a0213.59b38", | |
"name": "", | |
"registerShowMax": 20, | |
"x": 680, | |
"y": 170, | |
"wires": [] | |
}, | |
{ | |
"id": "6fd20edd.9d64a", | |
"type": "modbus-flex-getter", | |
"z": "934a0213.59b38", | |
"name": "", | |
"showStatusActivities": false, | |
"showErrors": false, | |
"server": "7e257e6c.0c55", | |
"x": 430, | |
"y": 340, | |
"wires": [ | |
[ | |
"6190d094.4b69d", | |
"90057f47.6116a" | |
], | |
[ | |
"2ab12c2e.248074" | |
] | |
] | |
}, | |
{ | |
"id": "2ab12c2e.248074", | |
"type": "modbus-response", | |
"z": "934a0213.59b38", | |
"name": "", | |
"registerShowMax": 20, | |
"x": 670, | |
"y": 330, | |
"wires": [] | |
}, | |
{ | |
"id": "6190d094.4b69d", | |
"type": "debug", | |
"z": "934a0213.59b38", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "true", | |
"x": 750, | |
"y": 290, | |
"wires": [] | |
}, | |
{ | |
"id": "ff16b6ed.33d458", | |
"type": "catch", | |
"z": "934a0213.59b38", | |
"name": "", | |
"scope": null, | |
"x": 650, | |
"y": 80, | |
"wires": [ | |
[ | |
"13def922.564957" | |
] | |
] | |
}, | |
{ | |
"id": "bd6165cf.5556f8", | |
"type": "modbus-flex-server", | |
"z": "934a0213.59b38", | |
"name": "", | |
"logEnabled": false, | |
"serverPort": "10502", | |
"responseDelay": 100, | |
"unitId": 1, | |
"delayUnit": "ms", | |
"coilsBufferSize": 20000, | |
"registersBufferSize": 20000, | |
"minAddress": 0, | |
"splitAddress": 10000, | |
"funcGetCoil": "function getFlexCoil(addr, unitID) {\n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\treturn node.coils.readUInt8(addr * node.bufferFactor) \n\t} \n}", | |
"funcGetInputRegister": "function getFlexInputRegister(addr, unitID) { \n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress) { \n\n\t\treturn node.registers.readUInt16BE(addr * node.bufferFactor) \n\t} \n}", | |
"funcGetHoldingRegister": "function getFlexHoldingRegsiter(addr, unitID) { \n\tif (unitID === node.unitId && \n\t\taddr > node.splitAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\treturn node.registers.readUInt16BE(addr * node.bufferFactor) \n\t} \n}", | |
"funcSetCoil": "function setFlexCoil(addr, value, unitID) { \n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\tnode.coils.writeUInt8(value, addr * node.bufferFactor) \n\t} \n}", | |
"funcSetRegister": "function setFlexRegister(addr, value, unitID) { \n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\tnode.registers.writeUInt16BE(value, addr * node.bufferFactor) \n\t} \n}", | |
"x": 200, | |
"y": 70, | |
"wires": [ | |
[], | |
[], | |
[] | |
] | |
}, | |
{ | |
"id": "90057f47.6116a", | |
"type": "http response", | |
"z": "934a0213.59b38", | |
"name": "", | |
"statusCode": "", | |
"headers": {}, | |
"x": 630, | |
"y": 290, | |
"wires": [] | |
}, | |
{ | |
"id": "3e76ce1b.ecce22", | |
"type": "http in", | |
"z": "934a0213.59b38", | |
"name": "", | |
"url": "/modbus/read", | |
"method": "get", | |
"upload": false, | |
"swaggerDoc": "", | |
"x": 180, | |
"y": 190, | |
"wires": [ | |
[ | |
"84ee0e0b.ed5c9" | |
] | |
] | |
}, | |
{ | |
"id": "95a8b25.2972b5", | |
"type": "http response", | |
"z": "934a0213.59b38", | |
"name": "", | |
"statusCode": "", | |
"headers": {}, | |
"x": 640, | |
"y": 130, | |
"wires": [] | |
}, | |
{ | |
"id": "13def922.564957", | |
"type": "debug", | |
"z": "934a0213.59b38", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "true", | |
"x": 800, | |
"y": 80, | |
"wires": [] | |
}, | |
{ | |
"id": "a5d36532.8f2178", | |
"type": "modbus-flex-write", | |
"z": "934a0213.59b38", | |
"name": "", | |
"showStatusActivities": false, | |
"showErrors": false, | |
"server": "7e257e6c.0c55", | |
"x": 420, | |
"y": 530, | |
"wires": [ | |
[ | |
"8e948598.d4e568" | |
], | |
[ | |
"1e6cd079.e072b" | |
] | |
] | |
}, | |
{ | |
"id": "82fbb199.0ffde", | |
"type": "modbus-write", | |
"z": "934a0213.59b38", | |
"name": "", | |
"showStatusActivities": false, | |
"showErrors": false, | |
"unitid": "", | |
"dataType": "HoldingRegister", | |
"adr": "0", | |
"quantity": "1", | |
"server": "7e257e6c.0c55", | |
"x": 410, | |
"y": 440, | |
"wires": [ | |
[ | |
"26dccb4e.a20d54" | |
], | |
[ | |
"8281dfc5.214a5" | |
] | |
] | |
}, | |
{ | |
"id": "837d3e77.7e547", | |
"type": "http in", | |
"z": "934a0213.59b38", | |
"name": "", | |
"url": "/modbus/write", | |
"method": "get", | |
"upload": false, | |
"swaggerDoc": "", | |
"x": 180, | |
"y": 440, | |
"wires": [ | |
[ | |
"82fbb199.0ffde" | |
] | |
] | |
}, | |
{ | |
"id": "26dccb4e.a20d54", | |
"type": "http response", | |
"z": "934a0213.59b38", | |
"name": "", | |
"statusCode": "", | |
"headers": {}, | |
"x": 640, | |
"y": 400, | |
"wires": [] | |
}, | |
{ | |
"id": "8281dfc5.214a5", | |
"type": "modbus-response", | |
"z": "934a0213.59b38", | |
"name": "", | |
"registerShowMax": 20, | |
"x": 680, | |
"y": 440, | |
"wires": [] | |
}, | |
{ | |
"id": "eb0c0441.6acc08", | |
"type": "http in", | |
"z": "934a0213.59b38", | |
"name": "", | |
"url": "/modbus/flex/write", | |
"method": "get", | |
"upload": false, | |
"swaggerDoc": "", | |
"x": 190, | |
"y": 530, | |
"wires": [ | |
[ | |
"a5d36532.8f2178" | |
] | |
] | |
}, | |
{ | |
"id": "8e948598.d4e568", | |
"type": "http response", | |
"z": "934a0213.59b38", | |
"name": "", | |
"statusCode": "", | |
"headers": {}, | |
"x": 640, | |
"y": 490, | |
"wires": [] | |
}, | |
{ | |
"id": "1e6cd079.e072b", | |
"type": "modbus-response", | |
"z": "934a0213.59b38", | |
"name": "", | |
"registerShowMax": 20, | |
"x": 680, | |
"y": 530, | |
"wires": [] | |
}, | |
{ | |
"id": "c0a27f1a.38377", | |
"type": "comment", | |
"z": "934a0213.59b38", | |
"name": "HTTP request GET working examples", | |
"info": "## Read\n\n### Flex Read\n\nhttp://localhost:1880/modbus/flex/read?value=0&unitid=1&fc=3&address=0&quantity=1\n\nhttp://localhost:1880/modbus/flex/read?value=0&unitid=1&fc=4&address=0&quantity=1\n\nhttp://localhost:1880/modbus/flex/read?value=0&unitid=1&fc=3&address=0&quantity=5\n\nhttp://localhost:1880/modbus/flex/read?value=0&unitid=1&fc=4&address=0&quantity=5\n\n### Read\n\nhttp://localhost:1880/modbus/read\n\n## Write\n\n### Test HTTP without Modbus\n\nhttp://localhost:1880/modbus/flex/write/test?value=[1,2,3,4,5]&unitid=1&fc=16&address=0&quantity=5\n\n\n### Flex Write\n\nhttp://localhost:1880/modbus/flex/write?value=10&unitid=1&fc=6&address=0&quantity=1\n\nhttp://localhost:1880/modbus/flex/write?value=[1,2,3,4,5]&unitid=1&fc=16&address=0&quantity=5\n\n### Write\n\nhttp://localhost:1880/modbus/write\n", | |
"x": 240, | |
"y": 140, | |
"wires": [] | |
}, | |
{ | |
"id": "11651dd7.39ac22", | |
"type": "http in", | |
"z": "934a0213.59b38", | |
"name": "", | |
"url": "/modbus/flex/write/test", | |
"method": "get", | |
"upload": false, | |
"swaggerDoc": "", | |
"x": 220, | |
"y": 620, | |
"wires": [ | |
[ | |
"18b385b6.4daf0a" | |
] | |
] | |
}, | |
{ | |
"id": "1fafc9da.7e6216", | |
"type": "debug", | |
"z": "934a0213.59b38", | |
"name": "", | |
"active": true, | |
"console": "false", | |
"complete": "true", | |
"x": 590, | |
"y": 620, | |
"wires": [] | |
}, | |
{ | |
"id": "18b385b6.4daf0a", | |
"type": "function", | |
"z": "934a0213.59b38", | |
"name": "", | |
"func": "if (msg.payload.value && msg.payload.value.indexOf(',') > -1) {\n msg.payload.value = JSON.parse(msg.payload.value)\n}\n\nif (msg.value && msg.value.indexOf(',') > -1) {\n msg.value = JSON.parse(msg.payload.value)\n}\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 450, | |
"y": 620, | |
"wires": [ | |
[ | |
"1fafc9da.7e6216", | |
"5ba40073.7997a" | |
] | |
] | |
}, | |
{ | |
"id": "5ba40073.7997a", | |
"type": "http response", | |
"z": "934a0213.59b38", | |
"name": "", | |
"statusCode": "", | |
"headers": {}, | |
"x": 590, | |
"y": 660, | |
"wires": [] | |
}, | |
{ | |
"id": "7e257e6c.0c55", | |
"type": "modbus-client", | |
"z": "934a0213.59b38", | |
"name": "", | |
"clienttype": "tcp", | |
"bufferCommands": true, | |
"stateLogEnabled": false, | |
"tcpHost": "127.0.0.1", | |
"tcpPort": "10502", | |
"tcpType": "DEFAULT", | |
"serialPort": "/dev/ttyUSB", | |
"serialType": "RTU-BUFFERD", | |
"serialBaudrate": "9600", | |
"serialDatabits": "8", | |
"serialStopbits": "1", | |
"serialParity": "none", | |
"serialConnectionDelay": "100", | |
"unit_id": 1, | |
"commandDelay": 1, | |
"clientTimeout": 1000, | |
"reconnectTimeout": 2000 | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http responce
"No response object"
show this error after modbus get request